smbd: set long process name of smbd child processes to "smbd: <CLIENT IP>"
authorRalph Boehme <slow@samba.org>
Fri, 2 Dec 2022 08:49:11 +0000 (09:49 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 14 Dec 2022 02:47:24 +0000 (02:47 +0000)
The resulting process listings, depending on the format chosen for the process
name, show the relevant smbd processes like this:

$ ps faxo pid,uid,comm | egrep "\_.*smbd" | grep -v grep
1690322     0  \_ smbd
1690326     0      \_ smbd-notifyd
1690327     0      \_ smbd-cleanupd
1690337     0      \_ smbd[::1]

$ ps faxo pid,uid,args | egrep "\_.*smbd" | grep -v grep
1690322     0  \_ ./bin/smbd -D
1690326     0      \_ smbd: notifyd
1690327     0      \_ smbd: cleanupd
1690337     0      \_ smbd: client [::1]

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Dec 14 02:47:24 UTC 2022 on sn-devel-184

source3/smbd/server.c

index b1c9e219e1692498de2263fd293df775b7072675..155d220760999594dfc65193866e68a052fb048c 100644 (file)
@@ -35,6 +35,7 @@
 #include "secrets.h"
 #include "../lib/util/memcache.h"
 #include "ctdbd_conn.h"
+#include "lib/util/util_process.h"
 #include "util_cluster.h"
 #include "printing/queue_process.h"
 #include "rpc_server/rpc_config.h"
@@ -1001,6 +1002,7 @@ static void smbd_accept_connection(struct tevent_context *ev,
 
        pid = fork();
        if (pid == 0) {
+               char addrstr[INET6_ADDRSTRLEN];
                NTSTATUS status = NT_STATUS_OK;
 
                /*
@@ -1038,6 +1040,9 @@ static void smbd_accept_connection(struct tevent_context *ev,
                        smb_panic("reinit_after_fork() failed");
                }
 
+               print_sockaddr(addrstr, sizeof(addrstr), &addr);
+               process_set_title("smbd[%s]", "client [%s]", addrstr);
+
                smbd_process(ev, msg_ctx, fd, false);
         exit:
                exit_server_cleanly("end of child");