Bugzilla – Attachment 1335 Details for
Bug 1349
race condition with ControlMaster=auto
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Fix race in ControlMaster=auto
master-race.patch (text/plain), 2.28 KB, created by
Tony Finch
on 2007-08-05 04:18:14 AEST
(
hide
)
Description:
Fix race in ControlMaster=auto
Filename:
MIME Type:
Creator:
Tony Finch
Created:
2007-08-05 04:18:14 AEST
Size:
2.28 KB
patch
obsolete
>--- ssh.c~ Fri Jan 5 05:30:17 2007 >+++ ssh.c Fri Aug 3 19:21:18 2007 >@@ -1045,18 +1045,19 @@ > } > } > >-static void >-ssh_control_listener(void) >+static int >+ssh_control_listener(int test) > { > struct sockaddr_un addr; > mode_t old_umask; > int addr_len; > > if (options.control_path == NULL || >- options.control_master == SSHCTL_MASTER_NO) >- return; >+ options.control_master == SSHCTL_MASTER_NO || >+ control_fd != -1) >+ return 1; > >- debug("setting up multiplex master socket"); >+ debug("trying to set up multiplex master socket"); > > memset(&addr, '\0', sizeof(addr)); > addr.sun_family = AF_UNIX; >@@ -1073,11 +1074,9 @@ > old_umask = umask(0177); > if (bind(control_fd, (struct sockaddr *)&addr, addr_len) == -1) { > control_fd = -1; >- if (errno == EINVAL || errno == EADDRINUSE) >- fatal("ControlSocket %s already exists", >- options.control_path); >- else >+ if (errno != EINVAL && errno != EADDRINUSE) > fatal("%s bind(): %s", __func__, strerror(errno)); >+ return 0; > } > umask(old_umask); > >@@ -1085,6 +1084,9 @@ > fatal("%s listen(): %s", __func__, strerror(errno)); > > set_nonblock(control_fd); >+ >+ debug("control master listening on %s", options.control_path); >+ return 1; > } > > /* request pty/x11/agent/tcpfwd/shell for channel */ >@@ -1201,7 +1203,9 @@ > > /* XXX should be pre-session */ > ssh_init_forwarding(); >- ssh_control_listener(); >+ if (!ssh_control_listener(0)) >+ fatal("control master socket %s already exists", >+ options.control_path); > > if (!no_shell_flag || (datafellows & SSH_BUG_DUMMYCHAN)) > id = ssh_session2_open(); >@@ -1319,7 +1323,13 @@ > switch (options.control_master) { > case SSHCTL_MASTER_AUTO: > case SSHCTL_MASTER_AUTO_ASK: >- debug("auto-mux: Trying existing master"); >+ /* see if we can create a control master socket >+ to avoid a race between two auto clients */ >+ if (mux_command == SSHMUX_COMMAND_OPEN && >+ ssh_control_listener(1)) >+ return; >+ debug("trying to connect to control master socket %s", >+ options.control_path); > /* FALLTHROUGH */ > case SSHCTL_MASTER_NO: > break; >@@ -1452,6 +1462,8 @@ > signal(SIGINT, control_client_sighandler); > signal(SIGTERM, control_client_sighandler); > signal(SIGWINCH, control_client_sigrelay); >+ >+ debug("connected to control master; waiting for exit"); > > if (tty_flag) > enter_raw_mode();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1349
:
1335
|
1461
|
1462