Bugzilla – Attachment 1513 Details for
Bug 1329
stale control sockets prevent connection multiplexing.
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
fall back from mux client to TCP connection on error
muxfallback.diff (text/plain), 3.29 KB, created by
Damien Miller
on 2008-06-12 16:55:07 AEST
(
hide
)
Description:
fall back from mux client to TCP connection on error
Filename:
MIME Type:
Creator:
Damien Miller
Created:
2008-06-12 16:55:07 AEST
Size:
3.29 KB
patch
obsolete
>Index: mux.c >=================================================================== >RCS file: /cvs/src/usr.bin/ssh/mux.c,v >retrieving revision 1.3 >diff -u -p -r1.3 mux.c >--- mux.c 12 Jun 2008 05:32:30 -0000 1.3 >+++ mux.c 12 Jun 2008 06:45:05 -0000 >@@ -132,10 +132,16 @@ muxserver_listen(void) > old_umask = umask(0177); > if (bind(muxserver_sock, (struct sockaddr *)&addr, addr.sun_len) == -1) { > muxserver_sock = -1; >- if (errno == EINVAL || errno == EADDRINUSE) >- fatal("ControlSocket %s already exists", >- options.control_path); >- else >+ if (errno == EINVAL || errno == EADDRINUSE) { >+ error("ControlSocket %s already exists, " >+ "disabling multiplexing", options.control_path); >+ close(muxserver_sock); >+ muxserver_sock = -1; >+ xfree(options.control_path); >+ options.control_path = NULL; >+ options.control_master = SSHCTL_MASTER_NO; >+ return; >+ } else > fatal("%s bind(): %s", __func__, strerror(errno)); > } > umask(old_umask); >@@ -487,7 +493,7 @@ muxclient(const char *path) > Buffer m; > char *term; > extern char **environ; >- u_int flags; >+ u_int allowed, flags; > > if (muxclient_command == 0) > muxclient_command = SSHMUX_COMMAND_OPEN; >@@ -558,17 +564,38 @@ muxclient(const char *path) > /* Send our command to server */ > buffer_put_int(&m, muxclient_command); > buffer_put_int(&m, flags); >- if (ssh_msg_send(sock, SSHMUX_VER, &m) == -1) >- fatal("%s: msg_send", __func__); >+ if (ssh_msg_send(sock, SSHMUX_VER, &m) == -1) { >+ error("%s: msg_send", __func__); >+ muxerr: >+ close(sock); >+ buffer_free(&m); >+ if (muxclient_command != SSHMUX_COMMAND_OPEN) >+ cleanup_exit(255); >+ logit("Falling back to non-multiplexed connection"); >+ xfree(options.control_path); >+ options.control_path = NULL; >+ options.control_master = SSHCTL_MASTER_NO; >+ return; >+ } > buffer_clear(&m); > > /* Get authorisation status and PID of controlee */ >- if (ssh_msg_recv(sock, &m) == -1) >- fatal("%s: msg_recv", __func__); >- if (buffer_get_char(&m) != SSHMUX_VER) >- fatal("%s: wrong version", __func__); >- if (buffer_get_int(&m) != 1) >- fatal("Connection to master denied"); >+ if (ssh_msg_recv(sock, &m) == -1) { >+ error("%s: msg_recv", __func__); >+ goto muxerr; >+ } >+ if (buffer_get_char(&m) != SSHMUX_VER) { >+ error("%s: wrong version", __func__); >+ goto muxerr; >+ } >+ if (buffer_get_int_ret(&allowed, &m) != 0) { >+ error("%s: bad server reply", __func__); >+ goto muxerr; >+ } >+ if (allowed != 1) { >+ error("Connection to master denied"); >+ goto muxerr; >+ } > muxserver_pid = buffer_get_int(&m); > > buffer_clear(&m); >@@ -612,13 +639,22 @@ muxclient(const char *path) > fatal("unrecognised muxclient_command %d", muxclient_command); > } > >- if (ssh_msg_send(sock, SSHMUX_VER, &m) == -1) >- fatal("%s: msg_send", __func__); >+ if (ssh_msg_send(sock, SSHMUX_VER, &m) == -1) { >+ error("%s: msg_send", __func__); >+ goto muxerr; >+ } > > if (mm_send_fd(sock, STDIN_FILENO) == -1 || > mm_send_fd(sock, STDOUT_FILENO) == -1 || >- mm_send_fd(sock, STDERR_FILENO) == -1) >- fatal("%s: send fds failed", __func__); >+ mm_send_fd(sock, STDERR_FILENO) == -1) { >+ error("%s: send fds failed", __func__); >+ goto muxerr; >+ } >+ >+ /* >+ * Mux errors are non-recoverable from this point as the master >+ * has ownership of the session now. >+ */ > > /* Wait for reply, so master has a chance to gather ttymodes */ > buffer_clear(&m);
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 1329
:
1318
|
1513
|
1514
|
2050
|
2051