Bugzilla – Attachment 1461 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]
updated patch
master-race.patch (text/plain), 3.77 KB, created by
David Woodhouse
on 2008-03-06 23:43:32 AEDT
(
hide
)
Description:
updated patch
Filename:
MIME Type:
Creator:
David Woodhouse
Created:
2008-03-06 23:43:32 AEDT
Size:
3.77 KB
patch
obsolete
>https://bugzilla.mindrot.org/show_bug.cgi?id=1349 > >--- openssh-4.7p1/ssh.c.masterrace 2008-03-06 12:19:46.000000000 +0000 >+++ openssh-4.7p1/ssh.c 2008-03-06 12:39:40.000000000 +0000 >@@ -886,6 +886,50 @@ check_agent_present(void) > } > > static int >+ssh_control_listener(void) >+{ >+ struct sockaddr_un addr; >+ mode_t old_umask; >+ int addr_len; >+ >+ if (options.control_path == NULL || >+ options.control_master == SSHCTL_MASTER_NO || >+ control_fd != -1) >+ return 1; >+ >+ debug("trying to set up multiplex master socket"); >+ >+ memset(&addr, '\0', sizeof(addr)); >+ addr.sun_family = AF_UNIX; >+ addr_len = offsetof(struct sockaddr_un, sun_path) + >+ strlen(options.control_path) + 1; >+ >+ if (strlcpy(addr.sun_path, options.control_path, >+ sizeof(addr.sun_path)) >= sizeof(addr.sun_path)) >+ fatal("ControlPath too long"); >+ >+ if ((control_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) >+ fatal("%s socket(): %s", __func__, strerror(errno)); >+ >+ old_umask = umask(0177); >+ if (bind(control_fd, (struct sockaddr *)&addr, addr_len) == -1) { >+ control_fd = -1; >+ if (errno != EINVAL && errno != EADDRINUSE) >+ fatal("%s bind(): %s", __func__, strerror(errno)); >+ return 0; >+ } >+ umask(old_umask); >+ >+ if (listen(control_fd, 64) == -1) >+ fatal("%s listen(): %s", __func__, strerror(errno)); >+ >+ set_nonblock(control_fd); >+ >+ debug("control master listening on %s", options.control_path); >+ return 1; >+} >+ >+static int > ssh_session(void) > { > int type; >@@ -994,6 +1038,9 @@ ssh_session(void) > > /* Initiate port forwardings. */ > ssh_init_forwarding(); >+ if (!ssh_control_listener()) >+ fatal("control master socket %s already exists", >+ options.control_path); > > /* If requested, let ssh continue in the background. */ > if (fork_after_authentication_flag) >@@ -1065,48 +1112,6 @@ client_global_request_reply_fwd(int type > } > } > >-static void >-ssh_control_listener(void) >-{ >- struct sockaddr_un addr; >- mode_t old_umask; >- int addr_len; >- >- if (options.control_path == NULL || >- options.control_master == SSHCTL_MASTER_NO) >- return; >- >- debug("setting up multiplex master socket"); >- >- memset(&addr, '\0', sizeof(addr)); >- addr.sun_family = AF_UNIX; >- addr_len = offsetof(struct sockaddr_un, sun_path) + >- strlen(options.control_path) + 1; >- >- if (strlcpy(addr.sun_path, options.control_path, >- sizeof(addr.sun_path)) >= sizeof(addr.sun_path)) >- fatal("ControlPath too long"); >- >- if ((control_fd = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) >- fatal("%s socket(): %s", __func__, strerror(errno)); >- >- 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 >- fatal("%s bind(): %s", __func__, strerror(errno)); >- } >- umask(old_umask); >- >- if (listen(control_fd, 64) == -1) >- fatal("%s listen(): %s", __func__, strerror(errno)); >- >- set_nonblock(control_fd); >-} >- > /* request pty/x11/agent/tcpfwd/shell for channel */ > static void > ssh_session2_setup(int id, void *arg) >@@ -1375,7 +1380,13 @@ control_client(const char *path) > 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()) >+ return; >+ debug("trying to connect to control master socket %s", >+ options.control_path); > /* FALLTHROUGH */ > case SSHCTL_MASTER_NO: > break; >@@ -1522,6 +1533,8 @@ control_client(const char *path) > 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