From: Christof Schmitt Date: Mon, 20 Aug 2018 22:38:33 +0000 (-0700) Subject: s3:smbpasswd: Use cmdline_messaging_context X-Git-Tag: tdb-1.3.17~1705 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29fd2c2e5ad3c2d44f3629c6b7b4139772fe350c;p=thirdparty%2Fsamba.git s3:smbpasswd: Use cmdline_messaging_context smbpasswd does not use POPT_CREDENTIALS. Call cmdline_messaging_context to initialize a messaging_context with proper error checking before calling lp_load_global. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 Signed-off-by: Christof Schmitt Reviewed-by: Ralph Boehme --- diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index 04f34aa9b69..8e2b9d7f80f 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -23,6 +23,7 @@ #include "../lib/util/util_pw.h" #include "libsmb/proto.h" #include "passdb.h" +#include "cmdline_contexts.h" /* * Next two lines needed for SunOS and don't @@ -196,6 +197,8 @@ static int process_options(int argc, char **argv, int local_flags) usage(); } + cmdline_messaging_context(configfile); + if (!lp_load_global(configfile)) { fprintf(stderr, "Can't load %s - run testparm to debug it\n", configfile); @@ -614,7 +617,6 @@ static int process_nonroot(int local_flags) int main(int argc, char **argv) { TALLOC_CTX *frame = talloc_stackframe(); - struct messaging_context *msg_ctx = NULL; int local_flags = 0; int ret; @@ -632,19 +634,6 @@ int main(int argc, char **argv) setup_logging("smbpasswd", DEBUG_STDERR); - msg_ctx = server_messaging_context(); - if (msg_ctx == NULL) { - if (geteuid() != 0) { - DBG_NOTICE("Unable to initialize messaging context. " - "Must be root to do that.\n"); - } else { - fprintf(stderr, - "smbpasswd is not able to initialize the " - "messaging context!\n"); - return 1; - } - } - /* * Set the machine NETBIOS name if not already * set from the config file. diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build index 67bb87e7a74..06a986cada4 100644 --- a/source3/utils/wscript_build +++ b/source3/utils/wscript_build @@ -37,7 +37,9 @@ bld.SAMBA3_BINARY('smbpasswd', smbconf pdb PASSWD_UTIL - PASSCHANGE''') + PASSCHANGE + cmdline_contexts + ''') bld.SAMBA3_BINARY('pdbedit', source='pdbedit.c',