[PATCH] Use setproctitle in winbindd
Christof Schmitt
cs at samba.org
Tue Jan 9 19:07:18 UTC 2018
On Tue, Jan 09, 2018 at 11:17:57AM +0100, Ralph Böhme via samba-technical wrote:
> Hi!
>
> Looking at the process list on a Samba DC with all those accurately named samba
> processes, I got jealous and wanted the same in winbindd as well.
>
> Patch attached, already reviewed by Andreas, so I'm going to push later if noone
> objects.
>
> How does it look like? Eg:
>
> root 31717 0.0 0.9 436076 20028 ? Ss Jan06 0:07 ./bin/winbindd -D
> root 31724 0.0 0.7 316200 15152 ? S Jan06 0:01 \_ winbindd: domain child [TITAN]
> root 31727 0.0 0.8 436080 18200 ? S Jan06 0:00 \_ winbindd: domain child [WDOM2]
> root 31728 0.0 0.9 443576 19112 ? S Jan06 0:01 \_ winbindd: idmap child
> root 31729 0.0 0.4 309044 9004 ? S Jan06 0:01 \_ winbindd: domain child [BUILTIN]
>
> -slow
Hi,
i think this is a good idea. Sometimes it is important to identify a
domain child process and currently the only method is checking the open
files of the processes for a log file with the domain name.
Have you looked how other parts of the code set the title? For smbd,
this is done from reinit_after_fork that then passes the last parameter
to prctl_set_comment which then calls prctl(PR_SET_NAME).
It would be good to have a common path to set the process names.
Christof
>
> --
> Ralph Boehme, Samba Team https://samba.org/
> Samba Developer, SerNet GmbH https://sernet.de/en/samba/
> From 01761d6ee07fe159ec9c76803bbaa89f789fa133 Mon Sep 17 00:00:00 2001
> From: Ralph Boehme <slow at samba.org>
> Date: Wed, 20 Dec 2017 17:42:45 +0100
> Subject: [PATCH] winbindd: use setproctitle
>
> Signed-off-by: Ralph Boehme <slow at samba.org>
> Reviewed-by: Andreas Schneider <asn at samba.org>
> ---
> source3/winbindd/winbindd.c | 4 ++++
> source3/winbindd/winbindd_cm.c | 2 ++
> source3/winbindd/winbindd_dual.c | 6 ++++++
> 3 files changed, 12 insertions(+)
>
> diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
> index 460ee4b7ce4..74b240c5af3 100644
> --- a/source3/winbindd/winbindd.c
> +++ b/source3/winbindd/winbindd.c
> @@ -508,6 +508,8 @@ static void winbind_msg_validate_cache(struct messaging_context *msg_ctx,
> /* install default SIGCHLD handler: validation code uses fork/waitpid */
> CatchSignal(SIGCHLD, SIG_DFL);
>
> + setproctitle("validate cache child");
> +
> ret = (uint8_t)winbindd_validate_cache_nobackup();
> DEBUG(10, ("winbindd_msg_validata_cache: got return value %d\n", ret));
> messaging_send_buf(msg_ctx, server_id, MSG_WINBIND_VALIDATE_CACHE, &ret,
> @@ -1482,6 +1484,8 @@ int main(int argc, const char **argv)
> NTSTATUS status;
> bool ok;
>
> + setproctitle_init(argc, discard_const(argv), environ);
> +
> /*
> * Do this before any other talloc operation
> */
> diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
> index 16836bd05b5..4d3a372dd25 100644
> --- a/source3/winbindd/winbindd_cm.c
> +++ b/source3/winbindd/winbindd_cm.c
> @@ -256,6 +256,8 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
> }
> SAFE_FREE(lfile);
>
> + setproctitle("dc-connect child");
> +
> mem_ctx = talloc_init("fork_child_dc_connect");
> if (!mem_ctx) {
> DEBUG(0,("talloc_init failed.\n"));
> diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
> index 3b25e53e786..a05644d2c34 100644
> --- a/source3/winbindd/winbindd_dual.c
> +++ b/source3/winbindd/winbindd_dual.c
> @@ -1491,6 +1491,12 @@ static bool fork_domain_child(struct winbindd_child *child)
> _exit(0);
> }
>
> + if (child_domain != NULL) {
> + setproctitle("domain child [%s]", child_domain->name);
> + } else if (child == idmap_child()) {
> + setproctitle("idmap child");
> + }
> +
> /* Handle online/offline messages. */
> messaging_register(server_messaging_context(), NULL,
> MSG_WINBIND_OFFLINE, child_msg_offline);
> --
> 2.13.6
>
More information about the samba-technical
mailing list