On 2020/01/23 21:20, Damien Miller wrote:
> On Thu, 23 Jan 2020, Damien Miller wrote:
>
> > On Thu, 23 Jan 2020, Damien Miller wrote:
> >
> > > What information would you like there? We could put the first N listen
> > > addrs in the proctitle if that would help.
> >
> > Maybe like this:
> >
> > 63817 ?? S 0:00.05 sshd: [listen] on [0.0.0.0]:22, [::]:22, 0 of
> > 10-100
>
> antoine@ said this was not sufficient, so please try the following:
>
> 63817 ?? I 0:00.09 sshd: /usr/sbin/sshd [listener] 0 of 10-100
> startups
That works - etc/rc.d/sshd diff to match as follows:
Index: sshd
===================================================================
RCS file: /cvs/src/etc/rc.d/sshd,v
retrieving revision 1.5
diff -u -p -r1.5 sshd
--- sshd 22 Jan 2020 13:14:51 -0000 1.5
+++ sshd 24 Jan 2020 11:59:52 -0000
@@ -6,7 +6,7 @@ daemon="/usr/sbin/sshd"
. /etc/rc.d/rc.subr
-pexp="sshd: \[listener\].*"
+pexp="sshd: ${daemon}${daemon_flags:+ ${daemon_flags}} \[listener\].*"
rc_reload() {
${daemon} ${daemon_flags} -t && pkill -HUP -xf "${pexp}"
>
> diff --git a/sshd.c b/sshd.c
> index f6139fe..b7ed0f3 100644
> --- a/sshd.c
> +++ b/sshd.c
> @@ -240,6 +240,8 @@ void destroy_sensitive_data(void);
> void demote_sensitive_data(void);
> static void do_ssh2_kex(struct ssh *);
>
> +static char *listener_proctitle;
> +
> /*
> * Close all listening sockets
> */
> @@ -1032,9 +1034,9 @@ server_accept_loop(int *sock_in, int *sock_out, int
> *newsock, int *config_s)
> */
> for (;;) {
> if (ostartups != startups) {
> - setproctitle("[listener] %d of %d-%d startups",
> - startups, options.max_startups_begin,
> - options.max_startups);
> + setproctitle("%s [listener] %d of %d-%d startups",
> + listener_proctitle, startups,
> + options.max_startups_begin, options.max_startups);
> ostartups = startups;
> }
> if (received_sighup) {
> @@ -1347,6 +1349,41 @@ accumulate_host_timing_secret(struct sshbuf
> *server_cfg,
> sshbuf_free(buf);
> }
>
> +static void
> +xextendf(char **s, const char *sep, const char *fmt, ...)
> + __attribute__((__format__ (printf, 3, 4))) __attribute__((__nonnull__
> (3)));
> +static void
> +xextendf(char **sp, const char *sep, const char *fmt, ...)
> +{
> + va_list ap;
> + char *tmp1, *tmp2;
> +
> + va_start(ap, fmt);
> + xvasprintf(&tmp1, fmt, ap);
> + va_end(ap);
> +
> + if (*sp == NULL || **sp == '\0') {
> + free(*sp);
> + *sp = tmp1;
> + return;
> + }
> + xasprintf(&tmp2, "%s%s%s", *sp, sep, tmp1);
> + free(tmp1);
> + free(*sp);
> + *sp = tmp2;
> +}
> +
> +static char *
> +prepare_proctitle(int ac, char **av)
> +{
> + char *ret = NULL;
> + int i;
> +
> + for (i = 0; i < ac; i++)
> + xextendf(&ret, " ", "%s", av[i]);
> + return ret;
> +}
> +
> /*
> * Main program for the daemon.
> */
> @@ -1774,6 +1811,7 @@ main(int ac, char **av)
> rexec_argv[rexec_argc] = "-R";
> rexec_argv[rexec_argc + 1] = NULL;
> }
> + listener_proctitle = prepare_proctitle(ac, av);
>
> /* Ensure that umask disallows at least group and world write */
> new_umask = umask(0077) | 0022;
>