diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2010-09-26 18:51:48 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2010-09-26 18:51:48 +0000 |
commit | 66152010a7e03a10780815b074cd0b4d47fc1cdc (patch) | |
tree | 11d1ac60008cde76e076b3d75b5002df6e853f75 /server.c | |
parent | 2772557d154b7773fb5f6a2bc48fe43a26e7c7e4 (diff) |
Modify the permissions on the socket when adding or removing +x to show
attached sessions, rather than replacing them.
Diffstat (limited to 'server.c')
-rw-r--r-- | server.c | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -296,7 +296,8 @@ server_update_socket(void) struct session *s; u_int i; static int last = -1; - int n; + int n, mode; + struct stat sb; n = 0; for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { @@ -309,10 +310,20 @@ server_update_socket(void) if (n != last) { last = n; - if (n != 0) - chmod(socket_path, S_IRWXU|S_IRWXG); - else - chmod(socket_path, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP); + + if (stat(socket_path, &sb) != 0) + return; + mode = sb.st_mode; + if (n != 0) { + if (mode & S_IRUSR) + mode |= S_IXUSR; + if (mode & S_IRGRP) + mode |= S_IXGRP; + if (mode & S_IROTH) + mode |= S_IXOTH; + } else + mode &= ~(S_IXUSR|S_IXGRP|S_IXOTH); + chmod(socket_path, mode); } } |