summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2011-06-03 12:10:22 +1000
committerDamien Miller <djm@mindrot.org>2011-06-03 12:10:22 +1000
commitea2c1a4dc6b0568ec1c74f94adee124ad8a60c68 (patch)
tree1f1f182f236559bebeea7638fafc6e2063bd4a5c
parentc3c7227ccc4443a0b9bf180ee660fef47a064cdf (diff)
- djm@cvs.openbsd.org 2011/06/03 00:54:38
[ssh.c] bz#1883 - setproctitle() to identify mux master; patch from Bert.Wesarg AT googlemail.com; ok dtucker@ NB. includes additional portability code to enable setproctitle emulation on platforms that don't support it.
-rw-r--r--ChangeLog6
-rw-r--r--ssh.c20
2 files changed, 25 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index cf4da712..d5a62dcc 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,6 +9,12 @@
- (dtucker) [monitor.c] Remove the !HAVE_SOCKETPAIR case. We use socketpair
unconditionally in other places and the survey data we have does not show
any systems that use it. "nuke it" djm@
+ - djm@cvs.openbsd.org 2011/06/03 00:54:38
+ [ssh.c]
+ bz#1883 - setproctitle() to identify mux master; patch from Bert.Wesarg
+ AT googlemail.com; ok dtucker@
+ NB. includes additional portability code to enable setproctitle emulation
+ on platforms that don't support it.
20110529
- (djm) OpenBSD CVS Sync
diff --git a/ssh.c b/ssh.c
index e7e15cd6..90053758 100644
--- a/ssh.c
+++ b/ssh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh.c,v 1.361 2011/05/24 07:15:47 djm Exp $ */
+/* $OpenBSD: ssh.c,v 1.362 2011/06/03 00:54:38 djm Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -111,6 +111,11 @@
extern char *__progname;
+/* Saves a copy of argv for setproctitle emulation */
+#ifndef HAVE_SETPROCTITLE
+static char **saved_av;
+#endif
+
/* Flag indicating whether debug mode is on. May be set on the command line. */
int debug_flag = 0;
@@ -240,6 +245,7 @@ main(int ac, char **av)
int dummy, timeout_ms;
extern int optind, optreset;
extern char *optarg;
+
struct servent *sp;
Forward fwd;
@@ -248,6 +254,17 @@ main(int ac, char **av)
__progname = ssh_get_progname(av[0]);
+#ifndef HAVE_SETPROCTITLE
+ /* Prepare for later setproctitle emulation */
+ /* Save argv so it isn't clobbered by setproctitle() emulation */
+ saved_av = xcalloc(ac + 1, sizeof(*saved_av));
+ for (i = 0; i < ac; i++)
+ saved_av[i] = xstrdup(av[i]);
+ saved_av[i] = NULL;
+ compat_init_setproctitle(ac, av);
+ av = saved_av;
+#endif
+
/*
* Discard other fds that are hanging around. These can cause problem
* with backgrounded ssh processes started by ControlPersist.
@@ -977,6 +994,7 @@ control_persist_detach(void)
if (devnull > STDERR_FILENO)
close(devnull);
}
+ setproctitle("%s [mux]", options.control_path);
}
/* Do fork() after authentication. Used by "ssh -f" */