From fbd82ed99af93bb7efa41b0aabb5c3784ea3e8a4 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Sep 2012 09:20:46 +0200 Subject: [PATCH 1/3] replace: Support setproctitle(). This uses the setproctitle() from libc, libsetproctitle or libbsd. If none is available it provides a dummy implementation. (cherry picked from commit fd8d4ec34785e71de3f8458222d196d454d0e723) --- lib/replace/README | 1 + lib/replace/replace.c | 7 +++++++ lib/replace/replace.h | 9 +++++++++ lib/replace/wscript | 2 ++ source4/scripting/python/samba/netcmd/domain.py | 4 ++-- source4/smbd/process_onefork.c | 13 ------------- 6 files changed, 21 insertions(+), 15 deletions(-) diff --git a/lib/replace/README b/lib/replace/README index 5399971..e960dc8 100644 --- a/lib/replace/README +++ b/lib/replace/README @@ -73,6 +73,7 @@ readlink symlink realpath poll +setproctitle Types: bool diff --git a/lib/replace/replace.c b/lib/replace/replace.c index 322bf49..bbfb7cf 100644 --- a/lib/replace/replace.c +++ b/lib/replace/replace.c @@ -904,3 +904,10 @@ int rep_usleep(useconds_t sec) return 0; } #endif /* HAVE_USLEEP */ + +#ifndef HAVE_SETPROCTITLE +void rep_setproctitle(const char *fmt, ...) +{ + return 0; +} +#endif diff --git a/lib/replace/replace.h b/lib/replace/replace.h index c7f9c71..bbea0fc 100644 --- a/lib/replace/replace.h +++ b/lib/replace/replace.h @@ -128,6 +128,10 @@ #include #endif +#ifdef HAVE_SETPROCTITLE_H +#include +#endif + #if STDC_HEADERS #include #include @@ -845,4 +849,9 @@ typedef long useconds_t; int usleep(useconds_t); #endif +#ifndef HAVE_SETPROCTITLE +#define setproctitle rep_setproctitle +void rep_setproctitle(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2); +#endif + #endif /* _LIBREPLACE_REPLACE_H */ diff --git a/lib/replace/wscript b/lib/replace/wscript index 2f632e1..0dbac06 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -183,6 +183,8 @@ def configure(conf): checklibc=True) if not conf.CHECK_FUNCS('getpeereid'): conf.CHECK_FUNCS_IN('getpeereid', 'bsd', headers='sys/types.h bsd/unistd.h') + if not conf.CHECK_FUNCS_IN('setproctitle', 'bsd', headers='sys/types.h bsd/unistd.h'): + conf.CHECK_FUNCS_IN('setproctitle', 'setproctitle', headers='setproctitle.h') conf.CHECK_CODE(''' struct ucred cred; diff --git a/source4/scripting/python/samba/netcmd/domain.py b/source4/scripting/python/samba/netcmd/domain.py index 0ace70f..de529ba 100644 --- a/source4/scripting/python/samba/netcmd/domain.py +++ b/source4/scripting/python/samba/netcmd/domain.py @@ -393,8 +393,8 @@ class cmd_domain_provision(Command): serverrole=server_role, dom_for_fun_level=dom_for_fun_level, backend_type=ldap_backend_type, ldapadminpass=ldapadminpass, ol_mmr_urls=ol_mmr_urls, - useeadb=eadb, next_rid=next_rid, lp=lp, use_ntvfs=(use_ntvfs), - use_rfc2307=(use_rfc2307)) + useeadb=eadb, next_rid=next_rid, lp=lp, use_ntvfs=use_ntvfs, + use_rfc2307=use_rfc2307) except ProvisioningError, e: raise CommandError("Provision failed", e) diff --git a/source4/smbd/process_onefork.c b/source4/smbd/process_onefork.c index 251e507..b5e93d9 100644 --- a/source4/smbd/process_onefork.c +++ b/source4/smbd/process_onefork.c @@ -32,19 +32,6 @@ #include "param/param.h" #include "ldb_wrap.h" -#ifdef HAVE_SETPROCTITLE -#ifdef HAVE_SETPROCTITLE_H -#include -#endif -#else -#define setproctitle none_setproctitle -static int none_setproctitle(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2); -static int none_setproctitle(const char *fmt, ...) -{ - return 0; -} -#endif - NTSTATUS process_model_onefork_init(void); /* -- 1.7.9.5 From a696d43160b483a9942c099e3260976dbbb17b5f Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Mon, 24 Sep 2012 09:42:15 +0200 Subject: [PATCH 2/3] Remove compatibility code for setproctitle() now moved to libreplace. --- source4/smbd/process_prefork.c | 13 ------------- source4/smbd/process_standard.c | 13 ------------- 2 files changed, 26 deletions(-) diff --git a/source4/smbd/process_prefork.c b/source4/smbd/process_prefork.c index e4a519a..24ae4cf 100644 --- a/source4/smbd/process_prefork.c +++ b/source4/smbd/process_prefork.c @@ -32,19 +32,6 @@ #include "param/param.h" #include "ldb_wrap.h" -#ifdef HAVE_SETPROCTITLE -#ifdef HAVE_SETPROCTITLE_H -#include -#endif -#else -#define setproctitle none_setproctitle -static int none_setproctitle(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2); -static int none_setproctitle(const char *fmt, ...) -{ - return 0; -} -#endif - NTSTATUS process_model_prefork_init(void); /* diff --git a/source4/smbd/process_standard.c b/source4/smbd/process_standard.c index dd5f958..c5377b3 100644 --- a/source4/smbd/process_standard.c +++ b/source4/smbd/process_standard.c @@ -29,19 +29,6 @@ #include "param/param.h" #include "ldb_wrap.h" -#ifdef HAVE_SETPROCTITLE -#ifdef HAVE_SETPROCTITLE_H -#include -#endif -#else -#define setproctitle none_setproctitle -static int none_setproctitle(const char *fmt, ...) PRINTF_ATTRIBUTE(1, 2); -static int none_setproctitle(const char *fmt, ...) -{ - return 0; -} -#endif - NTSTATUS process_model_standard_init(void); /* we hold a pipe open in the parent, and the any child -- 1.7.9.5 From ae66dce0ddd0a0c3752aa887607798cbbe6adf62 Mon Sep 17 00:00:00 2001 From: Jelmer Vernooij Date: Tue, 25 Sep 2012 01:22:56 +0200 Subject: [PATCH 3/3] replace: Avoid returning value in void setproctitle() replacement. Autobuild-User(master): Jelmer Vernooij Autobuild-Date(master): Tue Sep 25 06:38:40 CEST 2012 on sn-devel-104 (cherry picked from commit 6749cfb418cd8e21df626c7144f1f4db3b6770e7) --- lib/replace/replace.c | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/replace/replace.c b/lib/replace/replace.c index bbfb7cf..53d4df8 100644 --- a/lib/replace/replace.c +++ b/lib/replace/replace.c @@ -908,6 +908,5 @@ int rep_usleep(useconds_t sec) #ifndef HAVE_SETPROCTITLE void rep_setproctitle(const char *fmt, ...) { - return 0; } #endif -- 1.7.9.5