- 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.
This commit is contained in:
Damien Miller 2011-06-03 12:10:22 +10:00
parent c3c7227ccc
commit ea2c1a4dc6
2 changed files with 25 additions and 1 deletions

View File

@ -9,6 +9,12 @@
- (dtucker) [monitor.c] Remove the !HAVE_SOCKETPAIR case. We use socketpair - (dtucker) [monitor.c] Remove the !HAVE_SOCKETPAIR case. We use socketpair
unconditionally in other places and the survey data we have does not show unconditionally in other places and the survey data we have does not show
any systems that use it. "nuke it" djm@ 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 20110529
- (djm) OpenBSD CVS Sync - (djm) OpenBSD CVS Sync

20
ssh.c
View File

@ -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> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -111,6 +111,11 @@
extern char *__progname; 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. */ /* Flag indicating whether debug mode is on. May be set on the command line. */
int debug_flag = 0; int debug_flag = 0;
@ -240,6 +245,7 @@ main(int ac, char **av)
int dummy, timeout_ms; int dummy, timeout_ms;
extern int optind, optreset; extern int optind, optreset;
extern char *optarg; extern char *optarg;
struct servent *sp; struct servent *sp;
Forward fwd; Forward fwd;
@ -248,6 +254,17 @@ main(int ac, char **av)
__progname = ssh_get_progname(av[0]); __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 * Discard other fds that are hanging around. These can cause problem
* with backgrounded ssh processes started by ControlPersist. * with backgrounded ssh processes started by ControlPersist.
@ -977,6 +994,7 @@ control_persist_detach(void)
if (devnull > STDERR_FILENO) if (devnull > STDERR_FILENO)
close(devnull); close(devnull);
} }
setproctitle("%s [mux]", options.control_path);
} }
/* Do fork() after authentication. Used by "ssh -f" */ /* Do fork() after authentication. Used by "ssh -f" */