]> andersk Git - openssh.git/blob - mux.c
- djm@cvs.openbsd.org 2008/06/12 15:19:17
[openssh.git] / mux.c
1 /* $OpenBSD: mux.c,v 1.4 2008/06/12 15:19:17 djm Exp $ */
2 /*
3  * Copyright (c) 2002-2008 Damien Miller <djm@openbsd.org>
4  *
5  * Permission to use, copy, modify, and distribute this software for any
6  * purpose with or without fee is hereby granted, provided that the above
7  * copyright notice and this permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16  */
17
18 /* ssh session multiplexing support */
19
20 #include "includes.h"
21
22 /*
23  * TODO:
24  *   1. partial reads in muxserver_accept_control (maybe make channels
25  *      from accepted connections)
26  *   2. Better signalling from master to slave, especially passing of
27  *      error messages
28  *   3. Better fall-back from mux slave error to new connection.
29  *   3. Add/delete forwardings via slave
30  *   4. ExitOnForwardingFailure (after #3 obviously)
31  *   5. Maybe extension mechanisms for multi-X11/multi-agent forwarding
32  *   6. Document the mux mini-protocol somewhere.
33  *   7. Support ~^Z in mux slaves.
34  *   8. Inspect or control sessions in master.
35  *   9. If we ever support the "signal" channel request, send signals on
36  *      sessions in master.
37  */
38
39 #include <sys/types.h>
40 #include <sys/param.h>
41 #include <sys/stat.h>
42 #include <sys/socket.h>
43 #include <sys/un.h>
44
45 #include <errno.h>
46 #include <fcntl.h>
47 #include <signal.h>
48 #include <stdarg.h>
49 #include <stddef.h>
50 #include <stdlib.h>
51 #include <stdio.h>
52 #include <string.h>
53 #include <unistd.h>
54 #ifdef HAVE_PATHS_H
55 #include <paths.h>
56 #endif
57
58 #ifdef HAVE_UTIL_H
59 # include <util.h>
60 #endif
61
62 #ifdef HAVE_LIBUTIL_H
63 # include <libutil.h>
64 #endif
65
66 #include "openbsd-compat/sys-queue.h"
67 #include "xmalloc.h"
68 #include "log.h"
69 #include "ssh.h"
70 #include "pathnames.h"
71 #include "misc.h"
72 #include "match.h"
73 #include "buffer.h"
74 #include "channels.h"
75 #include "msg.h"
76 #include "packet.h"
77 #include "monitor_fdpass.h"
78 #include "sshpty.h"
79 #include "key.h"
80 #include "readconf.h"
81 #include "clientloop.h"
82
83 /* from ssh.c */
84 extern int tty_flag;
85 extern Options options;
86 extern int stdin_null_flag;
87 extern char *host;
88 int subsystem_flag;
89 extern Buffer command;
90
91 /* Context for session open confirmation callback */
92 struct mux_session_confirm_ctx {
93         int want_tty;
94         int want_subsys;
95         int want_x_fwd;
96         int want_agent_fwd;
97         Buffer cmd;
98         char *term;
99         struct termios tio;
100         char **env;
101 };
102
103 /* fd to control socket */
104 int muxserver_sock = -1;
105
106 /* Multiplexing control command */
107 u_int muxclient_command = 0;
108
109 /* Set when signalled. */
110 static volatile sig_atomic_t muxclient_terminate = 0;
111
112 /* PID of multiplex server */
113 static u_int muxserver_pid = 0;
114
115
116 /* ** Multiplexing master support */
117
118 /* Prepare a mux master to listen on a Unix domain socket. */
119 void
120 muxserver_listen(void)
121 {
122         struct sockaddr_un addr;
123         mode_t old_umask;
124         int addr_len;
125
126         if (options.control_path == NULL ||
127             options.control_master == SSHCTL_MASTER_NO)
128                 return;
129
130         debug("setting up multiplex master socket");
131
132         memset(&addr, '\0', sizeof(addr));
133         addr.sun_family = AF_UNIX;
134         addr_len = offsetof(struct sockaddr_un, sun_path) +
135             strlen(options.control_path) + 1;
136
137         if (strlcpy(addr.sun_path, options.control_path,
138             sizeof(addr.sun_path)) >= sizeof(addr.sun_path))
139                 fatal("ControlPath too long");
140
141         if ((muxserver_sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
142                 fatal("%s socket(): %s", __func__, strerror(errno));
143
144         old_umask = umask(0177);
145         if (bind(muxserver_sock, (struct sockaddr *)&addr, addr_len) == -1) {
146                 muxserver_sock = -1;
147                 if (errno == EINVAL || errno == EADDRINUSE)
148                         fatal("ControlSocket %s already exists",
149                             options.control_path);
150                 else
151                         fatal("%s bind(): %s", __func__, strerror(errno));
152         }
153         umask(old_umask);
154
155         if (listen(muxserver_sock, 64) == -1)
156                 fatal("%s listen(): %s", __func__, strerror(errno));
157
158         set_nonblock(muxserver_sock);
159 }
160
161 /* Callback on open confirmation in mux master for a mux client session. */
162 static void
163 mux_session_confirm(int id, void *arg)
164 {
165         struct mux_session_confirm_ctx *cctx = arg;
166         const char *display;
167         Channel *c;
168         int i;
169
170         if (cctx == NULL)
171                 fatal("%s: cctx == NULL", __func__);
172         if ((c = channel_lookup(id)) == NULL)
173                 fatal("%s: no channel for id %d", __func__, id);
174
175         display = getenv("DISPLAY");
176         if (cctx->want_x_fwd && options.forward_x11 && display != NULL) {
177                 char *proto, *data;
178                 /* Get reasonable local authentication information. */
179                 client_x11_get_proto(display, options.xauth_location,
180                     options.forward_x11_trusted, &proto, &data);
181                 /* Request forwarding with authentication spoofing. */
182                 debug("Requesting X11 forwarding with authentication spoofing.");
183                 x11_request_forwarding_with_spoofing(id, display, proto, data);
184                 /* XXX wait for reply */
185         }
186
187         if (cctx->want_agent_fwd && options.forward_agent) {
188                 debug("Requesting authentication agent forwarding.");
189                 channel_request_start(id, "auth-agent-req@openssh.com", 0);
190                 packet_send();
191         }
192
193         client_session2_setup(id, cctx->want_tty, cctx->want_subsys,
194             cctx->term, &cctx->tio, c->rfd, &cctx->cmd, cctx->env);
195
196         c->open_confirm_ctx = NULL;
197         buffer_free(&cctx->cmd);
198         xfree(cctx->term);
199         if (cctx->env != NULL) {
200                 for (i = 0; cctx->env[i] != NULL; i++)
201                         xfree(cctx->env[i]);
202                 xfree(cctx->env);
203         }
204         xfree(cctx);
205 }
206
207 /*
208  * Accept a connection on the mux master socket and process the
209  * client's request. Returns flag indicating whether mux master should
210  * begin graceful close.
211  */
212 int
213 muxserver_accept_control(void)
214 {
215         Buffer m;
216         Channel *c;
217         int client_fd, new_fd[3], ver, allowed, window, packetmax;
218         socklen_t addrlen;
219         struct sockaddr_storage addr;
220         struct mux_session_confirm_ctx *cctx;
221         char *cmd;
222         u_int i, j, len, env_len, mux_command, flags, escape_char;
223         uid_t euid;
224         gid_t egid;
225         int start_close = 0;
226
227         /*
228          * Accept connection on control socket
229          */
230         memset(&addr, 0, sizeof(addr));
231         addrlen = sizeof(addr);
232         if ((client_fd = accept(muxserver_sock,
233             (struct sockaddr*)&addr, &addrlen)) == -1) {
234                 error("%s accept: %s", __func__, strerror(errno));
235                 return 0;
236         }
237
238         if (getpeereid(client_fd, &euid, &egid) < 0) {
239                 error("%s getpeereid failed: %s", __func__, strerror(errno));
240                 close(client_fd);
241                 return 0;
242         }
243         if ((euid != 0) && (getuid() != euid)) {
244                 error("control mode uid mismatch: peer euid %u != uid %u",
245                     (u_int) euid, (u_int) getuid());
246                 close(client_fd);
247                 return 0;
248         }
249
250         /* XXX handle asynchronously */
251         unset_nonblock(client_fd);
252
253         /* Read command */
254         buffer_init(&m);
255         if (ssh_msg_recv(client_fd, &m) == -1) {
256                 error("%s: client msg_recv failed", __func__);
257                 close(client_fd);
258                 buffer_free(&m);
259                 return 0;
260         }
261         if ((ver = buffer_get_char(&m)) != SSHMUX_VER) {
262                 error("%s: wrong client version %d", __func__, ver);
263                 buffer_free(&m);
264                 close(client_fd);
265                 return 0;
266         }
267
268         allowed = 1;
269         mux_command = buffer_get_int(&m);
270         flags = buffer_get_int(&m);
271
272         buffer_clear(&m);
273
274         switch (mux_command) {
275         case SSHMUX_COMMAND_OPEN:
276                 if (options.control_master == SSHCTL_MASTER_ASK ||
277                     options.control_master == SSHCTL_MASTER_AUTO_ASK)
278                         allowed = ask_permission("Allow shared connection "
279                             "to %s? ", host);
280                 /* continue below */
281                 break;
282         case SSHMUX_COMMAND_TERMINATE:
283                 if (options.control_master == SSHCTL_MASTER_ASK ||
284                     options.control_master == SSHCTL_MASTER_AUTO_ASK)
285                         allowed = ask_permission("Terminate shared connection "
286                             "to %s? ", host);
287                 if (allowed)
288                         start_close = 1;
289                 /* FALLTHROUGH */
290         case SSHMUX_COMMAND_ALIVE_CHECK:
291                 /* Reply for SSHMUX_COMMAND_TERMINATE and ALIVE_CHECK */
292                 buffer_clear(&m);
293                 buffer_put_int(&m, allowed);
294                 buffer_put_int(&m, getpid());
295                 if (ssh_msg_send(client_fd, SSHMUX_VER, &m) == -1) {
296                         error("%s: client msg_send failed", __func__);
297                         close(client_fd);
298                         buffer_free(&m);
299                         return start_close;
300                 }
301                 buffer_free(&m);
302                 close(client_fd);
303                 return start_close;
304         default:
305                 error("Unsupported command %d", mux_command);
306                 buffer_free(&m);
307                 close(client_fd);
308                 return 0;
309         }
310
311         /* Reply for SSHMUX_COMMAND_OPEN */
312         buffer_clear(&m);
313         buffer_put_int(&m, allowed);
314         buffer_put_int(&m, getpid());
315         if (ssh_msg_send(client_fd, SSHMUX_VER, &m) == -1) {
316                 error("%s: client msg_send failed", __func__);
317                 close(client_fd);
318                 buffer_free(&m);
319                 return 0;
320         }
321
322         if (!allowed) {
323                 error("Refused control connection");
324                 close(client_fd);
325                 buffer_free(&m);
326                 return 0;
327         }
328
329         buffer_clear(&m);
330         if (ssh_msg_recv(client_fd, &m) == -1) {
331                 error("%s: client msg_recv failed", __func__);
332                 close(client_fd);
333                 buffer_free(&m);
334                 return 0;
335         }
336         if ((ver = buffer_get_char(&m)) != SSHMUX_VER) {
337                 error("%s: wrong client version %d", __func__, ver);
338                 buffer_free(&m);
339                 close(client_fd);
340                 return 0;
341         }
342
343         cctx = xcalloc(1, sizeof(*cctx));
344         cctx->want_tty = (flags & SSHMUX_FLAG_TTY) != 0;
345         cctx->want_subsys = (flags & SSHMUX_FLAG_SUBSYS) != 0;
346         cctx->want_x_fwd = (flags & SSHMUX_FLAG_X11_FWD) != 0;
347         cctx->want_agent_fwd = (flags & SSHMUX_FLAG_AGENT_FWD) != 0;
348         cctx->term = buffer_get_string(&m, &len);
349         escape_char = buffer_get_int(&m);
350
351         cmd = buffer_get_string(&m, &len);
352         buffer_init(&cctx->cmd);
353         buffer_append(&cctx->cmd, cmd, strlen(cmd));
354
355         env_len = buffer_get_int(&m);
356         env_len = MIN(env_len, 4096);
357         debug3("%s: receiving %d env vars", __func__, env_len);
358         if (env_len != 0) {
359                 cctx->env = xcalloc(env_len + 1, sizeof(*cctx->env));
360                 for (i = 0; i < env_len; i++)
361                         cctx->env[i] = buffer_get_string(&m, &len);
362                 cctx->env[i] = NULL;
363         }
364
365         debug2("%s: accepted tty %d, subsys %d, cmd %s", __func__,
366             cctx->want_tty, cctx->want_subsys, cmd);
367         xfree(cmd);
368
369         /* Gather fds from client */
370         for(i = 0; i < 3; i++) {
371                 if ((new_fd[i] = mm_receive_fd(client_fd)) == -1) {
372                         error("%s: failed to receive fd %d from slave",
373                             __func__, i);
374                         for (j = 0; j < i; j++)
375                                 close(new_fd[j]);
376                         for (j = 0; j < env_len; j++)
377                                 xfree(cctx->env[j]);
378                         if (env_len > 0)
379                                 xfree(cctx->env);
380                         xfree(cctx->term);
381                         buffer_free(&cctx->cmd);
382                         close(client_fd);
383                         xfree(cctx);
384                         return 0;
385                 }
386         }
387
388         debug2("%s: got fds stdin %d, stdout %d, stderr %d", __func__,
389             new_fd[0], new_fd[1], new_fd[2]);
390
391         /* Try to pick up ttymodes from client before it goes raw */
392         if (cctx->want_tty && tcgetattr(new_fd[0], &cctx->tio) == -1)
393                 error("%s: tcgetattr: %s", __func__, strerror(errno));
394
395         /* This roundtrip is just for synchronisation of ttymodes */
396         buffer_clear(&m);
397         if (ssh_msg_send(client_fd, SSHMUX_VER, &m) == -1) {
398                 error("%s: client msg_send failed", __func__);
399                 close(client_fd);
400                 close(new_fd[0]);
401                 close(new_fd[1]);
402                 close(new_fd[2]);
403                 buffer_free(&m);
404                 xfree(cctx->term);
405                 if (env_len != 0) {
406                         for (i = 0; i < env_len; i++)
407                                 xfree(cctx->env[i]);
408                         xfree(cctx->env);
409                 }
410                 return 0;
411         }
412         buffer_free(&m);
413
414         /* enable nonblocking unless tty */
415         if (!isatty(new_fd[0]))
416                 set_nonblock(new_fd[0]);
417         if (!isatty(new_fd[1]))
418                 set_nonblock(new_fd[1]);
419         if (!isatty(new_fd[2]))
420                 set_nonblock(new_fd[2]);
421
422         set_nonblock(client_fd);
423
424         window = CHAN_SES_WINDOW_DEFAULT;
425         packetmax = CHAN_SES_PACKET_DEFAULT;
426         if (cctx->want_tty) {
427                 window >>= 1;
428                 packetmax >>= 1;
429         }
430         
431         c = channel_new("session", SSH_CHANNEL_OPENING,
432             new_fd[0], new_fd[1], new_fd[2], window, packetmax,
433             CHAN_EXTENDED_WRITE, "client-session", /*nonblock*/0);
434
435         c->ctl_fd = client_fd;
436         if (cctx->want_tty && escape_char != 0xffffffff) {
437                 channel_register_filter(c->self,
438                     client_simple_escape_filter, NULL,
439                     client_filter_cleanup,
440                     client_new_escape_filter_ctx((int)escape_char));
441         }
442
443         debug3("%s: channel_new: %d", __func__, c->self);
444
445         channel_send_open(c->self);
446         channel_register_open_confirm(c->self, mux_session_confirm, cctx);
447         return 0;
448 }
449
450 /* ** Multiplexing client support */
451
452 /* Exit signal handler */
453 static void
454 control_client_sighandler(int signo)
455 {
456         muxclient_terminate = signo;
457 }
458
459 /*
460  * Relay signal handler - used to pass some signals from mux client to
461  * mux master.
462  */
463 static void
464 control_client_sigrelay(int signo)
465 {
466         int save_errno = errno;
467
468         if (muxserver_pid > 1)
469                 kill(muxserver_pid, signo);
470
471         errno = save_errno;
472 }
473
474 /* Check mux client environment variables before passing them to mux master. */
475 static int
476 env_permitted(char *env)
477 {
478         int i, ret;
479         char name[1024], *cp;
480
481         if ((cp = strchr(env, '=')) == NULL || cp == env)
482                 return (0);
483         ret = snprintf(name, sizeof(name), "%.*s", (int)(cp - env), env);
484         if (ret <= 0 || (size_t)ret >= sizeof(name))
485                 fatal("env_permitted: name '%.100s...' too long", env);
486
487         for (i = 0; i < options.num_send_env; i++)
488                 if (match_pattern(name, options.send_env[i]))
489                         return (1);
490
491         return (0);
492 }
493
494 /* Multiplex client main loop. */
495 void
496 muxclient(const char *path)
497 {
498         struct sockaddr_un addr;
499         int i, r, fd, sock, exitval[2], num_env, addr_len;
500         Buffer m;
501         char *term;
502         extern char **environ;
503         u_int  flags;
504
505         if (muxclient_command == 0)
506                 muxclient_command = SSHMUX_COMMAND_OPEN;
507
508         switch (options.control_master) {
509         case SSHCTL_MASTER_AUTO:
510         case SSHCTL_MASTER_AUTO_ASK:
511                 debug("auto-mux: Trying existing master");
512                 /* FALLTHROUGH */
513         case SSHCTL_MASTER_NO:
514                 break;
515         default:
516                 return;
517         }
518
519         memset(&addr, '\0', sizeof(addr));
520         addr.sun_family = AF_UNIX;
521         addr_len = offsetof(struct sockaddr_un, sun_path) +
522             strlen(path) + 1;
523
524         if (strlcpy(addr.sun_path, path,
525             sizeof(addr.sun_path)) >= sizeof(addr.sun_path))
526                 fatal("ControlPath too long");
527
528         if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
529                 fatal("%s socket(): %s", __func__, strerror(errno));
530
531         if (connect(sock, (struct sockaddr *)&addr, addr_len) == -1) {
532                 if (muxclient_command != SSHMUX_COMMAND_OPEN) {
533                         fatal("Control socket connect(%.100s): %s", path,
534                             strerror(errno));
535                 }
536                 if (errno == ENOENT)
537                         debug("Control socket \"%.100s\" does not exist", path);
538                 else {
539                         error("Control socket connect(%.100s): %s", path,
540                             strerror(errno));
541                 }
542                 close(sock);
543                 return;
544         }
545
546         if (stdin_null_flag) {
547                 if ((fd = open(_PATH_DEVNULL, O_RDONLY)) == -1)
548                         fatal("open(/dev/null): %s", strerror(errno));
549                 if (dup2(fd, STDIN_FILENO) == -1)
550                         fatal("dup2: %s", strerror(errno));
551                 if (fd > STDERR_FILENO)
552                         close(fd);
553         }
554
555         term = getenv("TERM");
556
557         flags = 0;
558         if (tty_flag)
559                 flags |= SSHMUX_FLAG_TTY;
560         if (subsystem_flag)
561                 flags |= SSHMUX_FLAG_SUBSYS;
562         if (options.forward_x11)
563                 flags |= SSHMUX_FLAG_X11_FWD;
564         if (options.forward_agent)
565                 flags |= SSHMUX_FLAG_AGENT_FWD;
566
567         signal(SIGPIPE, SIG_IGN);
568
569         buffer_init(&m);
570
571         /* Send our command to server */
572         buffer_put_int(&m, muxclient_command);
573         buffer_put_int(&m, flags);
574         if (ssh_msg_send(sock, SSHMUX_VER, &m) == -1)
575                 fatal("%s: msg_send", __func__);
576         buffer_clear(&m);
577
578         /* Get authorisation status and PID of controlee */
579         if (ssh_msg_recv(sock, &m) == -1)
580                 fatal("%s: msg_recv", __func__);
581         if (buffer_get_char(&m) != SSHMUX_VER)
582                 fatal("%s: wrong version", __func__);
583         if (buffer_get_int(&m) != 1)
584                 fatal("Connection to master denied");
585         muxserver_pid = buffer_get_int(&m);
586
587         buffer_clear(&m);
588
589         switch (muxclient_command) {
590         case SSHMUX_COMMAND_ALIVE_CHECK:
591                 fprintf(stderr, "Master running (pid=%d)\r\n",
592                     muxserver_pid);
593                 exit(0);
594         case SSHMUX_COMMAND_TERMINATE:
595                 fprintf(stderr, "Exit request sent.\r\n");
596                 exit(0);
597         case SSHMUX_COMMAND_OPEN:
598                 buffer_put_cstring(&m, term ? term : "");
599                 if (options.escape_char == SSH_ESCAPECHAR_NONE)
600                         buffer_put_int(&m, 0xffffffff);
601                 else
602                         buffer_put_int(&m, options.escape_char);
603                 buffer_append(&command, "\0", 1);
604                 buffer_put_cstring(&m, buffer_ptr(&command));
605
606                 if (options.num_send_env == 0 || environ == NULL) {
607                         buffer_put_int(&m, 0);
608                 } else {
609                         /* Pass environment */
610                         num_env = 0;
611                         for (i = 0; environ[i] != NULL; i++) {
612                                 if (env_permitted(environ[i]))
613                                         num_env++; /* Count */
614                         }
615                         buffer_put_int(&m, num_env);
616                 for (i = 0; environ[i] != NULL && num_env >= 0; i++) {
617                                 if (env_permitted(environ[i])) {
618                                         num_env--;
619                                         buffer_put_cstring(&m, environ[i]);
620                                 }
621                         }
622                 }
623                 break;
624         default:
625                 fatal("unrecognised muxclient_command %d", muxclient_command);
626         }
627
628         if (ssh_msg_send(sock, SSHMUX_VER, &m) == -1)
629                 fatal("%s: msg_send", __func__);
630
631         if (mm_send_fd(sock, STDIN_FILENO) == -1 ||
632             mm_send_fd(sock, STDOUT_FILENO) == -1 ||
633             mm_send_fd(sock, STDERR_FILENO) == -1)
634                 fatal("%s: send fds failed", __func__);
635
636         /* Wait for reply, so master has a chance to gather ttymodes */
637         buffer_clear(&m);
638         if (ssh_msg_recv(sock, &m) == -1)
639                 fatal("%s: msg_recv", __func__);
640         if (buffer_get_char(&m) != SSHMUX_VER)
641                 fatal("%s: wrong version", __func__);
642         buffer_free(&m);
643
644         signal(SIGHUP, control_client_sighandler);
645         signal(SIGINT, control_client_sighandler);
646         signal(SIGTERM, control_client_sighandler);
647         signal(SIGWINCH, control_client_sigrelay);
648
649         if (tty_flag)
650                 enter_raw_mode();
651
652         /*
653          * Stick around until the controlee closes the client_fd.
654          * Before it does, it is expected to write this process' exit
655          * value (one int). This process must read the value and wait for
656          * the closure of the client_fd; if this one closes early, the 
657          * multiplex master will terminate early too (possibly losing data).
658          */
659         exitval[0] = 0;
660         for (i = 0; !muxclient_terminate && i < (int)sizeof(exitval);) {
661                 r = read(sock, (char *)exitval + i, sizeof(exitval) - i);
662                 if (r == 0) {
663                         debug2("Received EOF from master");
664                         break;
665                 }
666                 if (r == -1) {
667                         if (errno == EINTR)
668                                 continue;
669                         fatal("%s: read %s", __func__, strerror(errno));
670                 }
671                 i += r;
672         }
673
674         close(sock);
675         leave_raw_mode();
676         if (i > (int)sizeof(int))
677                 fatal("%s: master returned too much data (%d > %lu)",
678                     __func__, i, sizeof(int));
679         if (muxclient_terminate) {
680                 debug2("Exiting on signal %d", muxclient_terminate);
681                 exitval[0] = 255;
682         } else if (i < (int)sizeof(int)) {
683                 debug2("Control master terminated unexpectedly");
684                 exitval[0] = 255;
685         } else
686                 debug2("Received exit status from master %d", exitval[0]);
687
688         if (tty_flag && options.log_level != SYSLOG_LEVEL_QUIET)
689                 fprintf(stderr, "Shared connection to %s closed.\r\n", host);
690
691         exit(exitval[0]);
692 }
This page took 0.090174 seconds and 5 git commands to generate.