summaryrefslogtreecommitdiffstats
path: root/server.c
diff options
context:
space:
mode:
authorTiago Cunha <tcunha@gmx.com>2010-10-09 14:26:29 +0000
committerTiago Cunha <tcunha@gmx.com>2010-10-09 14:26:29 +0000
commit7874b00d4c207dc82d075d64631aa87f22771af9 (patch)
tree34dd4a50fa1568ffefc2b9d98767d2d96e4e483a /server.c
parent6139fac10dab60bf29436b8ea0a346ba358fe762 (diff)
Sync OpenBSD patchset 765:
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.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/server.c b/server.c
index 6d89fd01..2cee2f29 100644
--- a/server.c
+++ b/server.c
@@ -1,4 +1,4 @@
-/* $Id: server.c,v 1.243 2010-08-29 14:42:11 tcunha Exp $ */
+/* $Id: server.c,v 1.244 2010-10-09 14:26:29 tcunha Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -300,7 +300,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++) {
@@ -313,10 +314,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);
}
}