The Samba-Bugzilla – Bug 9816
support setproctitle on linux via prset(PR_SET_NAME
Last modified: 2015-03-06 12:18:18 UTC
Created attachment 8790 [details]
patch to provide setproctitle support in lib/replace.c for linux
Samba does not set process titles on Linux systems because GNU/Linux systems do not provide the setproctitle library function.
However on Linux systems the library call prset allows the process title to be set up to 16 characters.
As long as samba calls to setproctitle put the more relevant information first, this should be a adequate replacement.
Attached is a patch to a recent samba 4.0.5 release that adds this support to lib/replace.c if prset is available and PR_SET_NAME is defined
There is setproctitle library that can be detected and used by samba:
Now prctl way should be always preffered over external setproctitle (less dependencies etc) and currently samba with your patch will preffer external setproctitle.
I would think that if a package builder has installed a setproctitle library and also chooses to link samba to it, that they would know what they are doing.
prctl only allows 16 character process names; if someone has a library that can overcome this limitation they should be allowed to use it.
it seems reasonable for libreplace to provide the alternative implementation as a fallback because it has this length restriction.
That library seems magic, but the blunt reality is that it isn't used because it does all the dangerous things (as I understand it) that prevent us implementing that this way in libreplace. See bug 9121.
In our previous discussion on setproctitle you said this prctl needed a static string. Can you work out with Sam if his patch is mistaken (using a malloc'ed buffer later free'ed) or if it is actually fine? I would like to include this patch, even with the limitations.
man prctl makes no such assertion:
PR_SET_NAME (since Linux 2.6.9)
Set the process name for the calling process, using the value in the location pointed to by (char *) arg2. The name can be up to 16 bytes long, and should be null-termi‐
nated if it contains fewer bytes.
It's still on my todo list but I haven't had time to work on it. All I have at the moment is:
There is some argument to abstract this in a modified standard_set_title() and modifying the signature of the model_ops.set_title function on the grounds that more care is needed in constructing a meaningful title with only 16 characters.
setproctitle is supported via libbsd. The remaining task is to link our binaries to libbsd-ctor or call the magic init routine in our popt code (provided we know we never call that popt code from libraries - need to check DLZ_BIND9).
I note that since this bug was filed, there have been other bugs filed over the same issue, and that an alternative resolution still does not exist.
Can I propose this patch for when libbsd is not available or desirable?
It has the benefit of delivering value now, and simply, without dependancy on libbsd's convoluted immplementation and all the attendant difficulties and risks.
It also seems very legitimate that lib_replace should be able to provide a replacement to setproctitle when libbsd is not present.
And therefore this patch has value independant of any libbsd solution whenever it might arrive