s4:smbd: call setproctitle_init
authorGary Lockyer <gary@catalyst.net.nz>
Wed, 13 Sep 2017 21:36:21 +0000 (09:36 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Mon, 25 Sep 2017 22:41:16 +0000 (00:41 +0200)
Call setproctitle_init() in main which suppresses the
  "samba: setproctitle not initialized, please either call
   setproctitle_init() or link against libbsd-ctor."
messages, but more importantly it displays meaningful details in ps
output.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=9816

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
lib/replace/replace.c
lib/replace/replace.h
lib/replace/wscript
source4/smbd/server.c

index 9351b6c94e31623e6e6213ee888debc285b1fd38..dc81e9cd5aba524d0925201f0496eff82cf080bc 100644 (file)
@@ -942,3 +942,8 @@ void rep_setproctitle(const char *fmt, ...)
 {
 }
 #endif
+#ifndef HAVE_SETPROCTITLE_INIT
+void rep_setproctitle_init(int argc, char *argv[], char *envp[])
+{
+}
+#endif
index a41e9f89d20cf21712bb9424cb3b2520c43e9fa5..128978c561ec815b4136e20727787a23dd434e04 100644 (file)
@@ -918,6 +918,10 @@ int usleep(useconds_t);
 void rep_setproctitle(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
 #endif
 
+#ifndef HAVE_SETPROCTITLE_INIT
+#define setproctitle_init rep_setproctitle_init
+void rep_setproctitle_init(int argc, char *argv[], char *envp[]);
+#endif
 bool nss_wrapper_enabled(void);
 bool nss_wrapper_hosts_enabled(void);
 bool socket_wrapper_enabled(void);
index 6972f2d6e40d72e45a9f88c5e15ea7ee8c8921f0..952663257fa52cd82855613cdedc1ccb07ae93cc 100644 (file)
@@ -271,6 +271,8 @@ def configure(conf):
         conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h')
     if not conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h'):
         conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h')
+    if not conf.CHECK_FUNCS('setproctitle_init'):
+        conf.CHECK_FUNCS_IN('setproctitle_init', 'bsd', headers='sys/types.h bsd/unistd.h')
 
     if not conf.CHECK_FUNCS('closefrom'):
         conf.CHECK_FUNCS_IN('closefrom', 'bsd', headers='bsd/unistd.h')
index ba520e0a8f50e42b0ef70bf6f048fce6b96e4263..dccc826d595566ad39f0e28a88b846c6b43f3455 100644 (file)
@@ -631,5 +631,7 @@ static int binary_smbd_main(const char *binary_name,
 
 int main(int argc, const char *argv[])
 {
+       setproctitle_init(argc, discard_const(argv), environ);
+
        return binary_smbd_main("samba", argc, argv);
 }