diff options
author | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-08 19:49:04 +0000 |
---|---|---|
committer | Nicholas Marriott <nicholas.marriott@gmail.com> | 2008-06-08 19:49:04 +0000 |
commit | d00914ff2b6e6ee6789e6343e74807632efc4018 (patch) | |
tree | 34d1c918687e301a82f6255e5cb368fa3bc77dbb /server.c | |
parent | 2a2a9760eeb263066d5585e906124605e2697e2e (diff) | |
download | rtmux-d00914ff2b6e6ee6789e6343e74807632efc4018.tar.gz rtmux-d00914ff2b6e6ee6789e6343e74807632efc4018.tar.bz2 rtmux-d00914ff2b6e6ee6789e6343e74807632efc4018.zip |
Set socket mode +x if sessions attached.
Diffstat (limited to 'server.c')
-rw-r--r-- | server.c | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $Id: server.c,v 1.60 2008-06-07 07:33:03 nicm Exp $ */ +/* $Id: server.c,v 1.61 2008-06-08 19:49:04 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -56,6 +56,7 @@ void server_lost_client(struct client *); void server_lost_window(struct window *); void server_check_redraw(struct client *); void server_check_status(struct client *); +void server_update_socket(const char *); /* Fork new server. */ int @@ -213,6 +214,9 @@ server_main(const char *srv_path, int srv_fd) server_handle_windows(&pfd); server_handle_clients(&pfd); + /* Update socket permissions. */ + server_update_socket(srv_path); + /* * If we have no sessions and clients left, let's get out * of here... @@ -592,3 +596,28 @@ server_lost_window(struct window *w) recalculate_sizes(); } +void +server_update_socket(const char *path) +{ + struct session *s; + u_int i; + static int last = -1; + int n; + + n = 0; + for (i = 0; i < ARRAY_LENGTH(&sessions); i++) { + s = ARRAY_ITEM(&sessions, i); + if (!(s->flags & SESSION_UNATTACHED)) { + n++; + break; + } + } + + if (n != last) { + last = n; + if (n != 0) + chmod(path, S_IRWXU); + else + chmod(path, S_IRUSR|S_IWUSR); + } +} |