summaryrefslogtreecommitdiff
path: root/usr.bin/tmux
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@cvs.openbsd.org>2010-09-26 18:51:49 +0000
committerNicholas Marriott <nicm@cvs.openbsd.org>2010-09-26 18:51:49 +0000
commitf02a78f076a3f9ec15d43cb4ae02e410a5e41ce3 (patch)
treed25a74e555b4617d32e7a4c09695fbdf7fb03439 /usr.bin/tmux
parent12886a63affd2596f6df003f827e5ae36b4fc5fd (diff)
Modify the permissions on the socket when adding or removing +x to show
attached sessions, rather than replacing them.
Diffstat (limited to 'usr.bin/tmux')
-rw-r--r--usr.bin/tmux/server.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/usr.bin/tmux/server.c b/usr.bin/tmux/server.c
index a8899394035..973f0c40a65 100644
--- a/usr.bin/tmux/server.c
+++ b/usr.bin/tmux/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.92 2010/08/19 18:29:01 nicm Exp $ */
+/* $OpenBSD: server.c,v 1.93 2010/09/26 18:51:48 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@@ -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);
}
}