summaryrefslogtreecommitdiff
path: root/sshd.c
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2020-01-24 23:56:01 +0000
committerDamien Miller <djm@mindrot.org>2020-01-25 11:27:29 +1100
commita8c05c640873621681ab64d2e47a314592d5efa2 (patch)
tree947a102da5aabb9a30f11facb61bf757b4706302 /sshd.c
parent8075fccbd4f70a4371acabcfb47562471ff0de6f (diff)
upstream: tweak proctitle to include sshd arguments, as these are
frequently used to distinguish between multiple independent instances of the server. New proctitle looks like this: $ pgrep -lf sshd 12844 sshd: /usr/sbin/sshd -f /etc/ssh/sshd_config [listener] 0 of 10-100 startups requested by sthen@ and aja@; ok aja@ OpenBSD-Commit-ID: cf235a561c655a3524a82003cf7244ecb48ccc1e
Diffstat (limited to 'sshd.c')
-rw-r--r--sshd.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/sshd.c b/sshd.c
index c447edfe1..46fdf7ee3 100644
--- a/sshd.c
+++ b/sshd.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshd.c,v 1.544 2020/01/23 07:10:22 dtucker Exp $ */ 1/* $OpenBSD: sshd.c,v 1.545 2020/01/24 23:56:01 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -262,6 +262,8 @@ void destroy_sensitive_data(void);
262void demote_sensitive_data(void); 262void demote_sensitive_data(void);
263static void do_ssh2_kex(struct ssh *); 263static void do_ssh2_kex(struct ssh *);
264 264
265static char *listener_proctitle;
266
265/* 267/*
266 * Close all listening sockets 268 * Close all listening sockets
267 */ 269 */
@@ -1087,9 +1089,9 @@ server_accept_loop(int *sock_in, int *sock_out, int *newsock, int *config_s)
1087 */ 1089 */
1088 for (;;) { 1090 for (;;) {
1089 if (ostartups != startups) { 1091 if (ostartups != startups) {
1090 setproctitle("[listener] %d of %d-%d startups", 1092 setproctitle("%s [listener] %d of %d-%d startups",
1091 startups, options.max_startups_begin, 1093 listener_proctitle, startups,
1092 options.max_startups); 1094 options.max_startups_begin, options.max_startups);
1093 ostartups = startups; 1095 ostartups = startups;
1094 } 1096 }
1095 if (received_sighup) { 1097 if (received_sighup) {
@@ -1435,6 +1437,17 @@ accumulate_host_timing_secret(struct sshbuf *server_cfg,
1435 sshbuf_free(buf); 1437 sshbuf_free(buf);
1436} 1438}
1437 1439
1440static char *
1441prepare_proctitle(int ac, char **av)
1442{
1443 char *ret = NULL;
1444 int i;
1445
1446 for (i = 0; i < ac; i++)
1447 xextendf(&ret, " ", "%s", av[i]);
1448 return ret;
1449}
1450
1438/* 1451/*
1439 * Main program for the daemon. 1452 * Main program for the daemon.
1440 */ 1453 */
@@ -1911,6 +1924,7 @@ main(int ac, char **av)
1911 rexec_argv[rexec_argc] = "-R"; 1924 rexec_argv[rexec_argc] = "-R";
1912 rexec_argv[rexec_argc + 1] = NULL; 1925 rexec_argv[rexec_argc + 1] = NULL;
1913 } 1926 }
1927 listener_proctitle = prepare_proctitle(ac, av);
1914 1928
1915 /* Ensure that umask disallows at least group and world write */ 1929 /* Ensure that umask disallows at least group and world write */
1916 new_umask = umask(0077) | 0022; 1930 new_umask = umask(0077) | 0022;