Skip to content

Commit

Permalink
Restore umask in file descriptor server after creating the socket. Fi…
Browse files Browse the repository at this point in the history
…xes issue 3661
  • Loading branch information
gnachman committed Jul 8, 2015
1 parent 841d3c5 commit ee23c36
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sources/iTermFileDescriptorServer.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ int iTermFileDescriptorServerSocketBindListen(const char *path) {
}

// Mask off all permissions for group and other. Only user can use this socket.
umask(S_IRWXG | S_IRWXO);
mode_t oldMask = umask(S_IRWXG | S_IRWXO);

struct sockaddr_un local;
local.sun_family = AF_UNIX;
Expand All @@ -168,13 +168,16 @@ int iTermFileDescriptorServerSocketBindListen(const char *path) {
int len = strlen(local.sun_path) + sizeof(local.sun_family) + 1;
if (bind(socketFd, (struct sockaddr *)&local, len) == -1) {
syslog(LOG_NOTICE, "bind() failed: %s", strerror(errno));
umask(oldMask);
return -1;
}

if (listen(socketFd, kMaxConnections) == -1) {
syslog(LOG_NOTICE, "listen() failed: %s", strerror(errno));
umask(oldMask);
return -1;
}
umask(oldMask);
return socketFd;
}

Expand Down

0 comments on commit ee23c36

Please sign in to comment.