mirror of
https://github.com/tmate-io/tmate.git
synced 2025-01-24 14:58:39 +01:00
Do not die on USR1 if any of the socket parent directories are
missing. Reported by Robin Powell.
This commit is contained in:
parent
7a72eff4a4
commit
93b2871cab
22
server.c
22
server.c
@ -79,24 +79,22 @@ server_create_socket(void)
|
|||||||
size = strlcpy(sa.sun_path, socket_path, sizeof sa.sun_path);
|
size = strlcpy(sa.sun_path, socket_path, sizeof sa.sun_path);
|
||||||
if (size >= sizeof sa.sun_path) {
|
if (size >= sizeof sa.sun_path) {
|
||||||
errno = ENAMETOOLONG;
|
errno = ENAMETOOLONG;
|
||||||
fatal("socket failed");
|
return (-1);
|
||||||
}
|
}
|
||||||
unlink(sa.sun_path);
|
unlink(sa.sun_path);
|
||||||
|
|
||||||
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) == -1)
|
||||||
fatal("socket failed");
|
return (-1);
|
||||||
|
|
||||||
mask = umask(S_IXUSR|S_IXGRP|S_IRWXO);
|
mask = umask(S_IXUSR|S_IXGRP|S_IRWXO);
|
||||||
if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1)
|
if (bind(fd, (struct sockaddr *) &sa, SUN_LEN(&sa)) == -1)
|
||||||
fatal("bind failed");
|
return (-1);
|
||||||
umask(mask);
|
umask(mask);
|
||||||
|
|
||||||
if (listen(fd, 16) == -1)
|
if (listen(fd, 16) == -1)
|
||||||
fatal("listen failed");
|
return (-1);
|
||||||
setblocking(fd, 0);
|
setblocking(fd, 0);
|
||||||
|
|
||||||
server_update_socket();
|
|
||||||
|
|
||||||
return (fd);
|
return (fd);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,6 +153,9 @@ server_start(int lockfd, char *lockfile)
|
|||||||
setproctitle("server (%s)", socket_path);
|
setproctitle("server (%s)", socket_path);
|
||||||
|
|
||||||
server_fd = server_create_socket();
|
server_fd = server_create_socket();
|
||||||
|
if (server_fd == -1)
|
||||||
|
fatal("couldn't create socket");
|
||||||
|
server_update_socket();
|
||||||
server_client_create(pair[1]);
|
server_client_create(pair[1]);
|
||||||
|
|
||||||
unlink(lockfile);
|
unlink(lockfile);
|
||||||
@ -387,6 +388,7 @@ server_add_accept(int timeout)
|
|||||||
void
|
void
|
||||||
server_signal_callback(int sig, unused short events, unused void *data)
|
server_signal_callback(int sig, unused short events, unused void *data)
|
||||||
{
|
{
|
||||||
|
int fd;
|
||||||
switch (sig) {
|
switch (sig) {
|
||||||
case SIGTERM:
|
case SIGTERM:
|
||||||
server_shutdown = 1;
|
server_shutdown = 1;
|
||||||
@ -397,8 +399,12 @@ server_signal_callback(int sig, unused short events, unused void *data)
|
|||||||
break;
|
break;
|
||||||
case SIGUSR1:
|
case SIGUSR1:
|
||||||
event_del(&server_ev_accept);
|
event_del(&server_ev_accept);
|
||||||
close(server_fd);
|
fd = server_create_socket();
|
||||||
server_fd = server_create_socket();
|
if (fd != -1) {
|
||||||
|
close(server_fd);
|
||||||
|
server_fd = fd;
|
||||||
|
server_update_socket();
|
||||||
|
}
|
||||||
server_add_accept(0);
|
server_add_accept(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
6
tmux.1
6
tmux.1
@ -163,7 +163,8 @@ If the socket is accidentally removed, the
|
|||||||
.Dv SIGUSR1
|
.Dv SIGUSR1
|
||||||
signal may be sent to the
|
signal may be sent to the
|
||||||
.Nm
|
.Nm
|
||||||
server process to recreate it.
|
server process to recreate it (note that this will fail if any parent
|
||||||
|
directories are missing).
|
||||||
.It Fl l
|
.It Fl l
|
||||||
Behave as a login shell.
|
Behave as a login shell.
|
||||||
This flag currently has no effect and is for compatibility with other shells
|
This flag currently has no effect and is for compatibility with other shells
|
||||||
@ -2004,7 +2005,8 @@ is bound in
|
|||||||
.Ar mode-table :
|
.Ar mode-table :
|
||||||
the binding for command mode with
|
the binding for command mode with
|
||||||
.Fl c
|
.Fl c
|
||||||
or for normal mode without. See the
|
or for normal mode without.
|
||||||
|
See the
|
||||||
.Sx WINDOWS AND PANES
|
.Sx WINDOWS AND PANES
|
||||||
section and the
|
section and the
|
||||||
.Ic list-keys
|
.Ic list-keys
|
||||||
|
Loading…
Reference in New Issue
Block a user