Skip to content

Commit

Permalink
Fix permissions for socket.
Browse files Browse the repository at this point in the history
Only running user can read (or write) data.
  • Loading branch information
rdebath committed Jun 21, 2017
1 parent 748020b commit b71dfb2
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions master.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,14 +183,17 @@ create_socket(char *name)
{
int s;
struct sockaddr_un sockun;
mode_t omask;

if (strlen(name) > sizeof(sockun.sun_path) - 1)
{
errno = ENAMETOOLONG;
return -1;
}

omask = umask(077);
s = socket(PF_UNIX, SOCK_STREAM, 0);
umask(omask); /* umask always succeeds, errno is untouched. */
if (s < 0)
return -1;
sockun.sun_family = AF_UNIX;
Expand Down

0 comments on commit b71dfb2

Please sign in to comment.