The Samba-Bugzilla – Attachment 14512 Details for
Bug 13465
testparm crashes with PANIC: messaging not initialized on SLES 12 SP3
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch for 4.8 backported from master
bug13465-v48.patch (text/plain), 65.46 KB, created by
Ralph Böhme
on 2018-10-04 10:10:51 UTC
(
hide
)
Description:
Patch for 4.8 backported from master
Filename:
MIME Type:
Creator:
Ralph Böhme
Created:
2018-10-04 10:10:51 UTC
Size:
65.46 KB
patch
obsolete
>From cc531c71a1c02586578c8ae20fd33271484ff7dc Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Mon, 9 Jul 2018 17:11:57 +0200 >Subject: [PATCH 01/22] s3:lib/server_contexts: make server_event_ctx and > server_msg_ctx static > >server_event_ctx and server_msg_ctx static shouldn't be accessible from >outside this compilation unit. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Christof Schmitt <cs@samba.org> >(cherry picked from commit d920a725ee19215190bbccaefd5b426bedc98860) >--- > source3/lib/server_contexts.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > >diff --git a/source3/lib/server_contexts.c b/source3/lib/server_contexts.c >index 50072e680b6..b21cf0a4c81 100644 >--- a/source3/lib/server_contexts.c >+++ b/source3/lib/server_contexts.c >@@ -21,7 +21,7 @@ > #include "includes.h" > #include "messages.h" > >-struct tevent_context *server_event_ctx = NULL; >+static struct tevent_context *server_event_ctx = NULL; > > struct tevent_context *server_event_context(void) > { >@@ -44,7 +44,7 @@ void server_event_context_free(void) > TALLOC_FREE(server_event_ctx); > } > >-struct messaging_context *server_msg_ctx = NULL; >+static struct messaging_context *server_msg_ctx = NULL; > > struct messaging_context *server_messaging_context(void) > { >-- >2.13.6 > > >From a8a1606b1cf379ae8b7f6801a0e9468b9457c0cd Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 13 Aug 2018 15:07:20 -0700 >Subject: [PATCH 02/22] s3/lib:popt_common: Move setup_logging to common > callback > >The flag is set in the common callback, so be consistent > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit dff1028e8ba4c70e726283c12531853681034014) >--- > source3/lib/popt_common.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > >diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c >index cc93a756c3b..454884fbb5c 100644 >--- a/source3/lib/popt_common.c >+++ b/source3/lib/popt_common.c >@@ -93,6 +93,10 @@ static void popt_common_callback(poptContext con, > } > } > >+ if (override_logfile) { >+ setup_logging(lp_logfile(talloc_tos()), DEBUG_FILE ); >+ } >+ > /* Further 'every Samba program must do this' hooks here. */ > return; > } >@@ -288,10 +292,6 @@ static void popt_common_credentials_callback(poptContext con, > if (reason == POPT_CALLBACK_REASON_POST) { > bool ok; > >- if (override_logfile) { >- setup_logging(lp_logfile(talloc_tos()), DEBUG_FILE ); >- } >- > ok = lp_load_client(get_dyn_CONFIGFILE()); > if (!ok) { > const char *pname = poptGetInvocationName(con); >-- >2.13.6 > > >From a703d95de8ac791a4d617a49a42832ef45551563 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 13 Aug 2018 15:39:08 -0700 >Subject: [PATCH 03/22] s3:lib: Move popt_common_credentials to separate file > >This is only used by command line utilities and has additional >dependencies. Move to a separate file to contain the dependencies to the >command line tools. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit b7464fd89bc22b71c82bbaa424bcbfcf947db651) >--- > source3/client/client.c | 2 +- > source3/include/popt_common.h | 10 -- > source3/include/popt_common_cmdline.h | 47 +++++++ > source3/lib/popt_common.c | 208 ----------------------------- > source3/lib/popt_common_cmdline.c | 241 ++++++++++++++++++++++++++++++++++ > source3/rpcclient/cmd_spoolss.c | 2 +- > source3/rpcclient/rpcclient.c | 2 +- > source3/rpcclient/wscript_build | 2 +- > source3/utils/net.c | 2 +- > source3/utils/regedit.c | 2 +- > source3/utils/smbcacls.c | 2 +- > source3/utils/smbcquotas.c | 2 +- > source3/utils/smbget.c | 2 +- > source3/utils/smbtree.c | 2 +- > source3/utils/wscript_build | 14 +- > source3/wscript_build | 9 +- > 16 files changed, 313 insertions(+), 236 deletions(-) > create mode 100644 source3/include/popt_common_cmdline.h > create mode 100644 source3/lib/popt_common_cmdline.c > >diff --git a/source3/client/client.c b/source3/client/client.c >index c836e5a0477..319899f2897 100644 >--- a/source3/client/client.c >+++ b/source3/client/client.c >@@ -23,7 +23,7 @@ > > #include "includes.h" > #include "system/filesys.h" >-#include "popt_common.h" >+#include "popt_common_cmdline.h" > #include "rpc_client/cli_pipe.h" > #include "client/client_proto.h" > #include "client/clitar_proto.h" >diff --git a/source3/include/popt_common.h b/source3/include/popt_common.h >index a8c778473e9..e001a5369b7 100644 >--- a/source3/include/popt_common.h >+++ b/source3/include/popt_common.h >@@ -21,7 +21,6 @@ > #define _POPT_COMMON_H > > #include <popt.h> >-#include "auth_info.h" > > /* Common popt structures */ > extern struct poptOption popt_common_samba[]; >@@ -41,19 +40,10 @@ extern const struct poptOption popt_common_dynconfig[]; > #define POPT_COMMON_CONNECTION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_connection, 0, "Connection options:", NULL }, > #define POPT_COMMON_VERSION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_version, 0, "Common samba options:", NULL }, > #define POPT_COMMON_CONFIGFILE { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_configfile, 0, "Common samba config:", NULL }, >-#define POPT_COMMON_CREDENTIALS { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_credentials, 0, "Authentication options:", NULL }, > #define POPT_COMMON_DYNCONFIG { NULL, 0, POPT_ARG_INCLUDE_TABLE, \ > discard_const_p(poptOption, popt_common_dynconfig), 0, \ > "Build-time configuration overrides:", NULL }, > #define POPT_COMMON_DEBUGLEVEL { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_debuglevel, 0, "Common samba debugging:", NULL }, > #define POPT_COMMON_OPTION { NULL, 0, POPT_ARG_INCLUDE_TABLE, popt_common_option, 0, "Common samba commandline config:", NULL }, > >-struct user_auth_info *popt_get_cmdline_auth_info(void); >-void popt_free_cmdline_auth_info(void); >- >-void popt_common_credentials_set_ignore_missing_conf(void); >-void popt_common_credentials_set_delay_post(void); >-void popt_common_credentials_post(void); >-void popt_burn_cmdline_password(int argc, char *argv[]); >- > #endif /* _POPT_COMMON_H */ >diff --git a/source3/include/popt_common_cmdline.h b/source3/include/popt_common_cmdline.h >new file mode 100644 >index 00000000000..21130cff071 >--- /dev/null >+++ b/source3/include/popt_common_cmdline.h >@@ -0,0 +1,47 @@ >+/* >+ Unix SMB/CIFS implementation. >+ Common popt arguments >+ Copyright (C) Jelmer Vernooij 2003 >+ Copyright (C) Christof Schmitt 2018 >+ >+ This program is free software; you can redistribute it and/or modify >+ it under the terms of the GNU General Public License as published by >+ the Free Software Foundation; either version 3 of the License, or >+ (at your option) any later version. >+ >+ This program is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ GNU General Public License for more details. >+ >+ You should have received a copy of the GNU General Public License >+ along with this program. If not, see <http://www.gnu.org/licenses/>. >+*/ >+ >+ >+#ifndef _POPT_COMMON_CREDENTIALS_H >+#define _POPT_COMMON_CREDENTIALS_H >+ >+#include "popt_common.h" >+ >+extern struct poptOption popt_common_credentials[]; >+#define POPT_COMMON_CREDENTIALS \ >+ { \ >+ NULL, \ >+ 0, \ >+ POPT_ARG_INCLUDE_TABLE, \ >+ popt_common_credentials, \ >+ 0, \ >+ "Authentication options:", \ >+ NULL \ >+ }, >+ >+struct user_auth_info *popt_get_cmdline_auth_info(void); >+void popt_free_cmdline_auth_info(void); >+ >+void popt_common_credentials_set_ignore_missing_conf(void); >+void popt_common_credentials_set_delay_post(void); >+void popt_common_credentials_post(void); >+void popt_burn_cmdline_password(int argc, char *argv[]); >+ >+#endif >diff --git a/source3/lib/popt_common.c b/source3/lib/popt_common.c >index 454884fbb5c..11db080c82d 100644 >--- a/source3/lib/popt_common.c >+++ b/source3/lib/popt_common.c >@@ -213,211 +213,3 @@ struct poptOption popt_common_option[] = { > { "option", 0, POPT_ARG_STRING, NULL, OPT_OPTION, "Set smb.conf option from command line", "name=value" }, > POPT_TABLEEND > }; >- >-/* Handle command line options: >- * -U,--user >- * -A,--authentication-file >- * -k,--use-kerberos >- * -N,--no-pass >- * -S,--signing >- * -P --machine-pass >- * -e --encrypt >- * -C --use-ccache >- */ >- >-static struct user_auth_info *cmdline_auth_info; >- >-struct user_auth_info *popt_get_cmdline_auth_info(void) >-{ >- return cmdline_auth_info; >-} >-void popt_free_cmdline_auth_info(void) >-{ >- TALLOC_FREE(cmdline_auth_info); >-} >- >-static bool popt_common_credentials_ignore_missing_conf; >-static bool popt_common_credentials_delay_post; >- >-void popt_common_credentials_set_ignore_missing_conf(void) >-{ >- popt_common_credentials_delay_post = true; >-} >- >-void popt_common_credentials_set_delay_post(void) >-{ >- popt_common_credentials_delay_post = true; >-} >- >-void popt_common_credentials_post(void) >-{ >- if (get_cmdline_auth_info_use_machine_account(cmdline_auth_info) && >- !set_cmdline_auth_info_machine_account_creds(cmdline_auth_info)) >- { >- fprintf(stderr, >- "Failed to use machine account credentials\n"); >- exit(1); >- } >- >- set_cmdline_auth_info_getpass(cmdline_auth_info); >- >- /* >- * When we set the username during the handling of the options passed to >- * the binary we haven't loaded the config yet. This means that we >- * didnn't take the 'winbind separator' into account. >- * >- * The username might contain the domain name and thus it hasn't been >- * correctly parsed yet. If we have a username we need to set it again >- * to run the string parser for the username correctly. >- */ >- reset_cmdline_auth_info_username(cmdline_auth_info); >-} >- >-static void popt_common_credentials_callback(poptContext con, >- enum poptCallbackReason reason, >- const struct poptOption *opt, >- const char *arg, const void *data) >-{ >- if (reason == POPT_CALLBACK_REASON_PRE) { >- struct user_auth_info *auth_info = >- user_auth_info_init(NULL); >- if (auth_info == NULL) { >- fprintf(stderr, "user_auth_info_init() failed\n"); >- exit(1); >- } >- cmdline_auth_info = auth_info; >- return; >- } >- >- if (reason == POPT_CALLBACK_REASON_POST) { >- bool ok; >- >- ok = lp_load_client(get_dyn_CONFIGFILE()); >- if (!ok) { >- const char *pname = poptGetInvocationName(con); >- >- fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", >- pname, get_dyn_CONFIGFILE()); >- if (!popt_common_credentials_ignore_missing_conf) { >- exit(1); >- } >- } >- >- load_interfaces(); >- >- set_cmdline_auth_info_guess(cmdline_auth_info); >- >- if (popt_common_credentials_delay_post) { >- return; >- } >- >- popt_common_credentials_post(); >- return; >- } >- >- switch(opt->val) { >- case 'U': >- set_cmdline_auth_info_username(cmdline_auth_info, arg); >- break; >- >- case 'A': >- set_cmdline_auth_info_from_file(cmdline_auth_info, arg); >- break; >- >- case 'k': >-#ifndef HAVE_KRB5 >- d_printf("No kerberos support compiled in\n"); >- exit(1); >-#else >- set_cmdline_auth_info_use_krb5_ticket(cmdline_auth_info); >-#endif >- break; >- >- case 'S': >- if (!set_cmdline_auth_info_signing_state(cmdline_auth_info, >- arg)) { >- fprintf(stderr, "Unknown signing option %s\n", arg ); >- exit(1); >- } >- break; >- case 'P': >- set_cmdline_auth_info_use_machine_account(cmdline_auth_info); >- break; >- case 'N': >- set_cmdline_auth_info_password(cmdline_auth_info, ""); >- break; >- case 'e': >- set_cmdline_auth_info_smb_encrypt(cmdline_auth_info); >- break; >- case 'C': >- set_cmdline_auth_info_use_ccache(cmdline_auth_info, true); >- break; >- case 'H': >- set_cmdline_auth_info_use_pw_nt_hash(cmdline_auth_info, true); >- break; >- } >-} >- >-/** >- * @brief Burn the commandline password. >- * >- * This function removes the password from the command line so we >- * don't leak the password e.g. in 'ps aux'. >- * >- * It should be called after processing the options and you should pass down >- * argv from main(). >- * >- * @param[in] argc The number of arguments. >- * >- * @param[in] argv[] The argument array we will find the array. >- */ >-void popt_burn_cmdline_password(int argc, char *argv[]) >-{ >- bool found = false; >- char *p = NULL; >- int i, ulen = 0; >- >- for (i = 0; i < argc; i++) { >- p = argv[i]; >- if (strncmp(p, "-U", 2) == 0) { >- ulen = 2; >- found = true; >- } else if (strncmp(p, "--user", 6) == 0) { >- ulen = 6; >- found = true; >- } >- >- if (found) { >- if (p == NULL) { >- return; >- } >- >- if (strlen(p) == ulen) { >- continue; >- } >- >- p = strchr_m(p, '%'); >- if (p != NULL) { >- memset(p, '\0', strlen(p)); >- } >- found = false; >- } >- } >-} >- >-struct poptOption popt_common_credentials[] = { >- { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, >- (void *)popt_common_credentials_callback, 0, NULL }, >- { "user", 'U', POPT_ARG_STRING, NULL, 'U', "Set the network username", "USERNAME" }, >- { "no-pass", 'N', POPT_ARG_NONE, NULL, 'N', "Don't ask for a password" }, >- { "kerberos", 'k', POPT_ARG_NONE, NULL, 'k', "Use kerberos (active directory) authentication" }, >- { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', "Get the credentials from a file", "FILE" }, >- { "signing", 'S', POPT_ARG_STRING, NULL, 'S', "Set the client signing state", "on|off|required" }, >- {"machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', "Use stored machine account password" }, >- {"encrypt", 'e', POPT_ARG_NONE, NULL, 'e', "Encrypt SMB transport" }, >- {"use-ccache", 'C', POPT_ARG_NONE, NULL, 'C', >- "Use the winbind ccache for authentication" }, >- {"pw-nt-hash", '\0', POPT_ARG_NONE, NULL, 'H', >- "The supplied password is the NT hash" }, >- POPT_TABLEEND >-}; >diff --git a/source3/lib/popt_common_cmdline.c b/source3/lib/popt_common_cmdline.c >new file mode 100644 >index 00000000000..57f77e0868a >--- /dev/null >+++ b/source3/lib/popt_common_cmdline.c >@@ -0,0 +1,241 @@ >+/* >+ Unix SMB/CIFS implementation. >+ Common popt routines only used by cmdline utils >+ >+ Copyright (C) Tim Potter 2001,2002 >+ Copyright (C) Jelmer Vernooij 2002,2003 >+ Copyright (C) James Peach 2006 >+ Copyright (C) Christof Schmitt 2018 >+ >+ This program is free software; you can redistribute it and/or modify >+ it under the terms of the GNU General Public License as published by >+ the Free Software Foundation; either version 3 of the License, or >+ (at your option) any later version. >+ >+ This program is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ GNU General Public License for more details. >+ >+ You should have received a copy of the GNU General Public License >+ along with this program. If not, see <http://www.gnu.org/licenses/>. >+*/ >+ >+/* Handle command line options: >+ * -U,--user >+ * -A,--authentication-file >+ * -k,--use-kerberos >+ * -N,--no-pass >+ * -S,--signing >+ * -P --machine-pass >+ * -e --encrypt >+ * -C --use-ccache >+ */ >+ >+#include "popt_common_cmdline.h" >+#include "includes.h" >+#include "auth_info.h" >+ >+static struct user_auth_info *cmdline_auth_info; >+ >+struct user_auth_info *popt_get_cmdline_auth_info(void) >+{ >+ return cmdline_auth_info; >+} >+void popt_free_cmdline_auth_info(void) >+{ >+ TALLOC_FREE(cmdline_auth_info); >+} >+ >+static bool popt_common_credentials_ignore_missing_conf; >+static bool popt_common_credentials_delay_post; >+ >+void popt_common_credentials_set_ignore_missing_conf(void) >+{ >+ popt_common_credentials_delay_post = true; >+} >+ >+void popt_common_credentials_set_delay_post(void) >+{ >+ popt_common_credentials_delay_post = true; >+} >+ >+void popt_common_credentials_post(void) >+{ >+ if (get_cmdline_auth_info_use_machine_account(cmdline_auth_info) && >+ !set_cmdline_auth_info_machine_account_creds(cmdline_auth_info)) >+ { >+ fprintf(stderr, >+ "Failed to use machine account credentials\n"); >+ exit(1); >+ } >+ >+ set_cmdline_auth_info_getpass(cmdline_auth_info); >+ >+ /* >+ * When we set the username during the handling of the options passed to >+ * the binary we haven't loaded the config yet. This means that we >+ * didn't take the 'winbind separator' into account. >+ * >+ * The username might contain the domain name and thus it hasn't been >+ * correctly parsed yet. If we have a username we need to set it again >+ * to run the string parser for the username correctly. >+ */ >+ reset_cmdline_auth_info_username(cmdline_auth_info); >+} >+ >+static void popt_common_credentials_callback(poptContext con, >+ enum poptCallbackReason reason, >+ const struct poptOption *opt, >+ const char *arg, const void *data) >+{ >+ if (reason == POPT_CALLBACK_REASON_PRE) { >+ struct user_auth_info *auth_info = >+ user_auth_info_init(NULL); >+ if (auth_info == NULL) { >+ fprintf(stderr, "user_auth_info_init() failed\n"); >+ exit(1); >+ } >+ cmdline_auth_info = auth_info; >+ return; >+ } >+ >+ if (reason == POPT_CALLBACK_REASON_POST) { >+ bool ok; >+ >+ ok = lp_load_client(get_dyn_CONFIGFILE()); >+ if (!ok) { >+ const char *pname = poptGetInvocationName(con); >+ >+ fprintf(stderr, "%s: Can't load %s - run testparm to debug it\n", >+ pname, get_dyn_CONFIGFILE()); >+ if (!popt_common_credentials_ignore_missing_conf) { >+ exit(1); >+ } >+ } >+ >+ load_interfaces(); >+ >+ set_cmdline_auth_info_guess(cmdline_auth_info); >+ >+ if (popt_common_credentials_delay_post) { >+ return; >+ } >+ >+ popt_common_credentials_post(); >+ return; >+ } >+ >+ switch(opt->val) { >+ case 'U': >+ set_cmdline_auth_info_username(cmdline_auth_info, arg); >+ break; >+ >+ case 'A': >+ set_cmdline_auth_info_from_file(cmdline_auth_info, arg); >+ break; >+ >+ case 'k': >+#ifndef HAVE_KRB5 >+ d_printf("No kerberos support compiled in\n"); >+ exit(1); >+#else >+ set_cmdline_auth_info_use_krb5_ticket(cmdline_auth_info); >+#endif >+ break; >+ >+ case 'S': >+ if (!set_cmdline_auth_info_signing_state(cmdline_auth_info, >+ arg)) { >+ fprintf(stderr, "Unknown signing option %s\n", arg ); >+ exit(1); >+ } >+ break; >+ case 'P': >+ set_cmdline_auth_info_use_machine_account(cmdline_auth_info); >+ break; >+ case 'N': >+ set_cmdline_auth_info_password(cmdline_auth_info, ""); >+ break; >+ case 'e': >+ set_cmdline_auth_info_smb_encrypt(cmdline_auth_info); >+ break; >+ case 'C': >+ set_cmdline_auth_info_use_ccache(cmdline_auth_info, true); >+ break; >+ case 'H': >+ set_cmdline_auth_info_use_pw_nt_hash(cmdline_auth_info, true); >+ break; >+ } >+} >+ >+/** >+ * @brief Burn the commandline password. >+ * >+ * This function removes the password from the command line so we >+ * don't leak the password e.g. in 'ps aux'. >+ * >+ * It should be called after processing the options and you should pass down >+ * argv from main(). >+ * >+ * @param[in] argc The number of arguments. >+ * >+ * @param[in] argv[] The argument array we will find the array. >+ */ >+void popt_burn_cmdline_password(int argc, char *argv[]) >+{ >+ bool found = false; >+ char *p = NULL; >+ int i, ulen = 0; >+ >+ for (i = 0; i < argc; i++) { >+ p = argv[i]; >+ if (strncmp(p, "-U", 2) == 0) { >+ ulen = 2; >+ found = true; >+ } else if (strncmp(p, "--user", 6) == 0) { >+ ulen = 6; >+ found = true; >+ } >+ >+ if (found) { >+ if (p == NULL) { >+ return; >+ } >+ >+ if (strlen(p) == ulen) { >+ continue; >+ } >+ >+ p = strchr_m(p, '%'); >+ if (p != NULL) { >+ memset(p, '\0', strlen(p)); >+ } >+ found = false; >+ } >+ } >+} >+ >+struct poptOption popt_common_credentials[] = { >+ { NULL, 0, POPT_ARG_CALLBACK|POPT_CBFLAG_PRE|POPT_CBFLAG_POST, >+ (void *)popt_common_credentials_callback, 0, NULL }, >+ { "user", 'U', POPT_ARG_STRING, NULL, 'U', >+ "Set the network username", "USERNAME" }, >+ { "no-pass", 'N', POPT_ARG_NONE, NULL, 'N', >+ "Don't ask for a password" }, >+ { "kerberos", 'k', POPT_ARG_NONE, NULL, 'k', >+ "Use kerberos (active directory) authentication" }, >+ { "authentication-file", 'A', POPT_ARG_STRING, NULL, 'A', >+ "Get the credentials from a file", "FILE" }, >+ { "signing", 'S', POPT_ARG_STRING, NULL, 'S', >+ "Set the client signing state", "on|off|required" }, >+ {"machine-pass", 'P', POPT_ARG_NONE, NULL, 'P', >+ "Use stored machine account password" }, >+ {"encrypt", 'e', POPT_ARG_NONE, NULL, 'e', >+ "Encrypt SMB transport" }, >+ {"use-ccache", 'C', POPT_ARG_NONE, NULL, 'C', >+ "Use the winbind ccache for authentication" }, >+ {"pw-nt-hash", '\0', POPT_ARG_NONE, NULL, 'H', >+ "The supplied password is the NT hash" }, >+ POPT_TABLEEND >+}; >diff --git a/source3/rpcclient/cmd_spoolss.c b/source3/rpcclient/cmd_spoolss.c >index 1d24476e9a5..8d330afdeb0 100644 >--- a/source3/rpcclient/cmd_spoolss.c >+++ b/source3/rpcclient/cmd_spoolss.c >@@ -33,7 +33,7 @@ > #include "../libcli/security/security_descriptor.h" > #include "../libcli/registry/util_reg.h" > #include "libsmb/libsmb.h" >-#include "popt_common.h" >+#include "popt_common_cmdline.h" > > #define RPCCLIENT_PRINTERNAME(_printername, _cli, _arg) \ > { \ >diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c >index c1039ed84c5..3635a3e31ff 100644 >--- a/source3/rpcclient/rpcclient.c >+++ b/source3/rpcclient/rpcclient.c >@@ -21,7 +21,7 @@ > > #include "includes.h" > #include "../libcli/auth/netlogon_creds_cli.h" >-#include "popt_common.h" >+#include "popt_common_cmdline.h" > #include "rpcclient.h" > #include "../libcli/auth/libcli_auth.h" > #include "../librpc/gen_ndr/ndr_lsa_c.h" >diff --git a/source3/rpcclient/wscript_build b/source3/rpcclient/wscript_build >index c24a5670db9..11a64f3248a 100644 >--- a/source3/rpcclient/wscript_build >+++ b/source3/rpcclient/wscript_build >@@ -25,7 +25,7 @@ bld.SAMBA3_BINARY('rpcclient', > ''', > deps=''' > talloc >- popt_samba3 >+ popt_samba3_cmdline > pdb > libsmb > smbconf >diff --git a/source3/utils/net.c b/source3/utils/net.c >index bde261670b5..9ee32cd6110 100644 >--- a/source3/utils/net.c >+++ b/source3/utils/net.c >@@ -41,7 +41,7 @@ > /*****************************************************/ > > #include "includes.h" >-#include "popt_common.h" >+#include "popt_common_cmdline.h" > #include "utils/net.h" > #include "secrets.h" > #include "lib/netapi/netapi.h" >diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c >index 14e75c25bfa..a6a6d404a67 100644 >--- a/source3/utils/regedit.c >+++ b/source3/utils/regedit.c >@@ -18,7 +18,7 @@ > */ > > #include "includes.h" >-#include "popt_common.h" >+#include "popt_common_cmdline.h" > #include "lib/util/data_blob.h" > #include "lib/registry/registry.h" > #include "regedit.h" >diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c >index 0a5eeb31d0b..33eb78c41ec 100644 >--- a/source3/utils/smbcacls.c >+++ b/source3/utils/smbcacls.c >@@ -22,7 +22,7 @@ > */ > > #include "includes.h" >-#include "popt_common.h" >+#include "popt_common_cmdline.h" > #include "rpc_client/cli_pipe.h" > #include "../librpc/gen_ndr/ndr_lsa.h" > #include "rpc_client/cli_lsarpc.h" >diff --git a/source3/utils/smbcquotas.c b/source3/utils/smbcquotas.c >index 798b8b6f177..a4b1b8111a5 100644 >--- a/source3/utils/smbcquotas.c >+++ b/source3/utils/smbcquotas.c >@@ -22,7 +22,7 @@ > */ > > #include "includes.h" >-#include "popt_common.h" >+#include "popt_common_cmdline.h" > #include "rpc_client/cli_pipe.h" > #include "../librpc/gen_ndr/ndr_lsa.h" > #include "rpc_client/cli_lsarpc.h" >diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c >index e1be42917fb..37462fa131f 100644 >--- a/source3/utils/smbget.c >+++ b/source3/utils/smbget.c >@@ -18,7 +18,7 @@ > > #include "includes.h" > #include "system/filesys.h" >-#include "popt_common.h" >+#include "popt_common_cmdline.h" > #include "libsmbclient.h" > > static int columns = 0; >diff --git a/source3/utils/smbtree.c b/source3/utils/smbtree.c >index fb0c130d350..9f830dbf8cd 100644 >--- a/source3/utils/smbtree.c >+++ b/source3/utils/smbtree.c >@@ -20,7 +20,7 @@ > */ > > #include "includes.h" >-#include "popt_common.h" >+#include "popt_common_cmdline.h" > #include "rpc_client/cli_pipe.h" > #include "../librpc/gen_ndr/ndr_srvsvc_c.h" > #include "libsmb/libsmb.h" >diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build >index 8b4d890d485..993086a66b2 100644 >--- a/source3/utils/wscript_build >+++ b/source3/utils/wscript_build >@@ -27,7 +27,7 @@ bld.SAMBA3_BINARY('smbtree', > smbconf > libsmb > msrpc3 >- popt_samba3 >+ popt_samba3_cmdline > RPC_NDR_SRVSVC''') > > bld.SAMBA3_BINARY('smbpasswd', >@@ -52,7 +52,7 @@ bld.SAMBA3_BINARY('smbget', > source='smbget.c', > deps=''' > talloc >- popt_samba3 >+ popt_samba3_cmdline > smbclient''') > > bld.SAMBA3_BINARY('nmblookup', >@@ -67,7 +67,7 @@ bld.SAMBA3_BINARY('smbcacls', > source='smbcacls.c ../lib/util_sd.c', > deps=''' > talloc >- popt_samba3 >+ popt_samba3_cmdline > msrpc3 > libcli_lsa3 > krb5samba''') >@@ -76,7 +76,7 @@ bld.SAMBA3_BINARY('smbcquotas', > source='smbcquotas.c', > deps=''' > talloc >- popt_samba3 >+ popt_samba3_cmdline > libsmb > msrpc3 > libcli_lsa3''') >@@ -149,7 +149,9 @@ bld.SAMBA3_BINARY('samba-regedit', > regedit_wrap.c regedit_treeview.c > regedit_valuelist.c regedit_dialog.c > regedit_hexedit.c regedit_list.c""", >- deps='ncurses menu panel form registry smbconf popt_samba3', >+ deps=''' >+ ncurses menu panel form registry smbconf popt_samba3_cmdline >+ ''', > enabled=bld.env.build_regedit) > > bld.SAMBA3_BINARY('testparm', >@@ -216,7 +218,7 @@ bld.SAMBA3_BINARY('net', > netapi > addns > samba_intl >- popt_samba3 >+ popt_samba3_cmdline > pdb > libsmb > smbconf >diff --git a/source3/wscript_build b/source3/wscript_build >index 61838e34496..83ef56d8ba8 100644 >--- a/source3/wscript_build >+++ b/source3/wscript_build >@@ -257,7 +257,12 @@ bld.SAMBA3_SUBSYSTEM('REG_FULL', > > bld.SAMBA3_LIBRARY('popt_samba3', > source='lib/popt_common.c', >- deps='popt samba-util util_cmdline', >+ deps='popt samba-util smbconf', >+ private_library=True) >+ >+bld.SAMBA3_LIBRARY('popt_samba3_cmdline', >+ source='lib/popt_common_cmdline.c', >+ deps='popt_samba3 util_cmdline', > private_library=True) > > bld.SAMBA3_LIBRARY('util_cmdline', >@@ -1083,7 +1088,7 @@ bld.SAMBA3_BINARY('client/smbclient', > ''', > deps=''' > talloc >- popt_samba3 >+ popt_samba3_cmdline > smbconf > ndr-standard > SMBREADLINE >-- >2.13.6 > > >From 9a3dc5f172be651686179c5b446280b3b193d13d Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 20 Aug 2018 14:44:28 -0700 >Subject: [PATCH 04/22] s3:lib: Introduce cmdline context wrapper > >Command line tools need acccess to the same messaging context provided >by server_messaging_context, as common code for db_open uses that >context. We want to have additional checking for command line tools >without having that code part of the servers. Introduce a wrapper >library to use for command line tools with the additional checks, that >then acquires the server_messaging_context. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit 8c3b62e6231e62feafacf2a7ee4c9d41cd27a4a1) >--- > source3/lib/cmdline_contexts.c | 70 ++++++++++++++++++++++++++++++++++++++++++ > source3/lib/cmdline_contexts.h | 27 ++++++++++++++++ > source3/wscript_build | 5 +++ > 3 files changed, 102 insertions(+) > create mode 100644 source3/lib/cmdline_contexts.c > create mode 100644 source3/lib/cmdline_contexts.h > >diff --git a/source3/lib/cmdline_contexts.c b/source3/lib/cmdline_contexts.c >new file mode 100644 >index 00000000000..5713f7f7956 >--- /dev/null >+++ b/source3/lib/cmdline_contexts.c >@@ -0,0 +1,70 @@ >+/* >+ Unix SMB/CIFS implementation. >+ cmdline context wrapper. >+ >+ Copyright (C) Christof Schmitt <cs@samba.org> 2018 >+ >+ This program is free software; you can redistribute it and/or modify >+ it under the terms of the GNU General Public License as published by >+ the Free Software Foundation; either version 3 of the License, or >+ (at your option) any later version. >+ >+ This program is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ GNU General Public License for more details. >+ >+ You should have received a copy of the GNU General Public License >+ along with this program. If not, see <http://www.gnu.org/licenses/>. >+*/ >+ >+#include "cmdline_contexts.h" >+#include "includes.h" >+#include "messages.h" >+ >+struct messaging_context *cmdline_messaging_context(const char *config_file) >+{ >+ struct messaging_context *msg_ctx = NULL; >+ >+ /* >+ * Ensure that a config is loaded, in case the underlying >+ * messaging_init needs to create directories or sockets. >+ */ >+ if (!lp_loaded()) { >+ if (!lp_load_initial_only(config_file)) { >+ return NULL; >+ } >+ } >+ >+ /* >+ * Clustered Samba can only work as root due to required >+ * access to the registry and ctdb, which in turn requires >+ * messaging access as root. >+ */ >+ if (lp_clustering() && geteuid() != 0) { >+ fprintf(stderr, "Cluster mode requires running as root.\n"); >+ exit(1); >+ } >+ >+ msg_ctx = server_messaging_context(); >+ if (msg_ctx == NULL) { >+ if (geteuid() == 0) { >+ fprintf(stderr, >+ "Unable to initialize messaging context!\n"); >+ exit(1); >+ } else { >+ /* >+ * Non-cluster, non-root: Log error, but leave >+ * it up to the caller how to proceed. >+ */ >+ DBG_NOTICE("Unable to initialize messaging context.\n"); >+ } >+ } >+ >+ return msg_ctx; >+} >+ >+void cmdline_messaging_context_free(void) >+{ >+ server_messaging_context_free(); >+} >diff --git a/source3/lib/cmdline_contexts.h b/source3/lib/cmdline_contexts.h >new file mode 100644 >index 00000000000..21f81f0f1cd >--- /dev/null >+++ b/source3/lib/cmdline_contexts.h >@@ -0,0 +1,27 @@ >+/* >+ Unix SMB/CIFS implementation. >+ cmdline context wrapper. >+ >+ Copyright (C) Christof Schmitt <cs@samba.org> 2018 >+ >+ This program is free software; you can redistribute it and/or modify >+ it under the terms of the GNU General Public License as published by >+ the Free Software Foundation; either version 3 of the License, or >+ (at your option) any later version. >+ >+ This program is distributed in the hope that it will be useful, >+ but WITHOUT ANY WARRANTY; without even the implied warranty of >+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+ GNU General Public License for more details. >+ >+ You should have received a copy of the GNU General Public License >+ along with this program. If not, see <http://www.gnu.org/licenses/>. >+*/ >+ >+#ifndef _LIB_CMDLINE_CONTEXTS_H >+#define _LIB_CMDLINE_CONTEXTS_H >+ >+struct messaging_context *cmdline_messaging_context(const char *config_file); >+void cmdline_messaging_context_free(void); >+ >+#endif >diff --git a/source3/wscript_build b/source3/wscript_build >index 83ef56d8ba8..1808b5e0cb3 100644 >--- a/source3/wscript_build >+++ b/source3/wscript_build >@@ -270,6 +270,11 @@ bld.SAMBA3_LIBRARY('util_cmdline', > deps='secrets3', > private_library=True) > >+bld.SAMBA3_LIBRARY('cmdline_contexts', >+ source='lib/cmdline_contexts.c', >+ deps='samba3core', >+ private_library=True) >+ > bld.SAMBA3_SUBSYSTEM('KRBCLIENT', > source='libads/kerberos.c libads/ads_status.c', > public_deps='krb5samba asn1util k5crypto gssapi LIBTSOCKET CLDAP LIBNMB') >-- >2.13.6 > > >From bc4588c8ac7ddbc8f3aed3ca69d2837f5352327f Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 10 Jul 2018 08:11:31 +0200 >Subject: [PATCH 05/22] s3:loadparm: reinit_globals in > lp_load_with_registry_shares() > >This was set to false in 0e0d77519c27038b30fec92d542198e97be767d9 based >on the assumption that callers would have no need to call >lp_load_initial_only() with a later call to lp_load_something(). > >This is not quite correct, since for accessing registry config on a >cluster with include=registry, we need messaging up and running which >*itself* requires loadparm to be initialized to get the statedir, >lockdir asf. directories. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Christof Schmitt <cs@samba.org> >(cherry picked from commit 3aca3f24d4bdacc11278388934b0b411d518d7b0) >--- > source3/param/loadparm.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > >diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c >index 096c23f4fb3..ff40a07f4f0 100644 >--- a/source3/param/loadparm.c >+++ b/source3/param/loadparm.c >@@ -4116,7 +4116,7 @@ bool lp_load_with_registry_shares(const char *pszFname) > false, /* global_only */ > true, /* save_defaults */ > false, /* add_ipc */ >- false, /* reinit_globals */ >+ true, /* reinit_globals */ > true, /* allow_include_registry */ > true); /* load_all_shares*/ > } >-- >2.13.6 > > >From fa26d58092625abaa2e5dd04c1b49a98a9e85ab3 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 10 Jul 2018 10:38:10 +0200 >Subject: [PATCH 06/22] selftest: pass configfile to pdbedit > >This is needed otherwise pdbedit fails to initialize messaging in >autobuild. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Christof Schmitt <cs@samba.org> >(cherry picked from commit 10e1a6ebb3d95b8a1584a9b90c2584536aa9c96d) >--- > testprogs/blackbox/test_pdbtest.sh | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > >diff --git a/testprogs/blackbox/test_pdbtest.sh b/testprogs/blackbox/test_pdbtest.sh >index 2ffded9af4e..02615094451 100755 >--- a/testprogs/blackbox/test_pdbtest.sh >+++ b/testprogs/blackbox/test_pdbtest.sh >@@ -44,12 +44,12 @@ send ${NEWUSERPASS}\n > send ${NEWUSERPASS}\n > EOF > >-testit "create user with pdbedit" $texpect ./tmpsmbpasswdscript $VALGRIND $pdbedit -a $USER --account-desc="pdbedit-test-user" $@ || failed=`expr $failed + 1` >+testit "create user with pdbedit" $texpect ./tmpsmbpasswdscript $VALGRIND $pdbedit -s $SMB_CONF -a $USER --account-desc="pdbedit-test-user" $@ || failed=`expr $failed + 1` > USERPASS=$NEWUSERPASS > > test_smbclient "Test login with user (ntlm)" 'ls' "$unc" -k no -U$USER%$NEWUSERPASS $@ || failed=`expr $failed + 1` > >-testit "modify user" $VALGRIND $pdbedit --modify $USER --drive="D:" $@ || failed=`expr $failed + 1` >+testit "modify user" $VALGRIND $pdbedit -s $SMB_CONF --modify $USER --drive="D:" $@ || failed=`expr $failed + 1` > > test_smbclient "Test login with user (ntlm)" 'ls' "$unc" -k no -U$USER%$NEWUSERPASS $@|| failed=`expr $failed + 1` > >@@ -87,11 +87,11 @@ test_smbclient "Test login with no expiry (ntlm)" 'ls' "$unc" -k no -U$USER%$NEW > NEWUSERPASS=testPaSS@03% > NEWUSERHASH=062519096c45739c1938800f80906731 > >-testit "Set user password with password hash" $VALGRIND $pdbedit -u $USER --set-nt-hash $NEWUSERHASH $@ || failed=`expr $failed + 1` >+testit "Set user password with password hash" $VALGRIND $pdbedit -s $SMB_CONF -u $USER --set-nt-hash $NEWUSERHASH $@ || failed=`expr $failed + 1` > > test_smbclient "Test login with new password (from hash)" 'ls' "$unc" -k no -U$USER%$NEWUSERPASS || failed=`expr $failed + 1` > >-testit "del user" $VALGRIND $pdbedit -x $USER $@ || failed=`expr $failed + 1` >+testit "del user" $VALGRIND $pdbedit -s $SMB_CONF -x $USER $@ || failed=`expr $failed + 1` > > rm ./tmpsmbpasswdscript > >-- >2.13.6 > > >From bce164e8bf828c3e08ce4ba26d69f5a1f7e7fb64 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 10 Jul 2018 15:26:40 +0200 >Subject: [PATCH 07/22] s3:popt_common: use cmdline_messaging_context() in > popt_common_credentials_callback() > >This adds a call to cmdline_messaging_context() to the popt >popt_common_credentials_callback() hook and ensures that any client tool >that uses POPT_COMMON_CREDENTIALS gets an implicit messaging context, >ensuring it doesn't crash in the subsequent lp_load_client() with >include=registry in a cluster. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Christof Schmitt <cs@samba.org> >(cherry picked from commit 2c63ce94ef3a55ab0aa1aae4f6fee88e29ac2efe) >--- > source3/lib/popt_common_cmdline.c | 8 ++++++++ > source3/wscript_build | 2 +- > 2 files changed, 9 insertions(+), 1 deletion(-) > >diff --git a/source3/lib/popt_common_cmdline.c b/source3/lib/popt_common_cmdline.c >index 57f77e0868a..d1ba90dd43e 100644 >--- a/source3/lib/popt_common_cmdline.c >+++ b/source3/lib/popt_common_cmdline.c >@@ -35,6 +35,7 @@ > #include "popt_common_cmdline.h" > #include "includes.h" > #include "auth_info.h" >+#include "cmdline_contexts.h" > > static struct user_auth_info *cmdline_auth_info; > >@@ -101,8 +102,15 @@ static void popt_common_credentials_callback(poptContext con, > } > > if (reason == POPT_CALLBACK_REASON_POST) { >+ struct messaging_context *msg_ctx = NULL; > bool ok; > >+ msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE()); >+ if (msg_ctx == NULL) { >+ fprintf(stderr, "Unable to initialize " >+ "messaging context\n"); >+ } >+ > ok = lp_load_client(get_dyn_CONFIGFILE()); > if (!ok) { > const char *pname = poptGetInvocationName(con); >diff --git a/source3/wscript_build b/source3/wscript_build >index 1808b5e0cb3..fb61f3236df 100644 >--- a/source3/wscript_build >+++ b/source3/wscript_build >@@ -262,7 +262,7 @@ bld.SAMBA3_LIBRARY('popt_samba3', > > bld.SAMBA3_LIBRARY('popt_samba3_cmdline', > source='lib/popt_common_cmdline.c', >- deps='popt_samba3 util_cmdline', >+ deps='popt_samba3 util_cmdline cmdline_contexts', > private_library=True) > > bld.SAMBA3_LIBRARY('util_cmdline', >-- >2.13.6 > > >From f52d84e2f304823aa6cd3be7a63a80645651d8b4 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Tue, 21 Aug 2018 14:58:01 -0700 >Subject: [PATCH 08/22] test:doc: Skip 'clustering=yes' > >As testparm will error out when running clustering=yes as non-root, skip >this step to avoid a test failure. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(backported from commit 3ecb9ed7b079fc1bf74c311cf5f1684086b36883) >--- > python/samba/tests/docs.py | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > >diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py >index 1462600b3b1..f8b62dcf855 100644 >--- a/python/samba/tests/docs.py >+++ b/python/samba/tests/docs.py >@@ -163,7 +163,8 @@ import xml.etree.ElementTree as ET > 'registry shares', > 'smb ports', > 'rpc server dynamic port range', >- 'name resolve order']) >+ 'name resolve order', >+ 'clustering']) > self._test_empty(['bin/testparm']) > > def test_default_s4(self): >-- >2.13.6 > > >From d5013a7d44a22d3c955de33f6cb310c505a084c7 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 20 Aug 2018 15:38:33 -0700 >Subject: [PATCH 09/22] 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 <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit 29fd2c2e5ad3c2d44f3629c6b7b4139772fe350c) >--- > source3/utils/smbpasswd.c | 17 +++-------------- > source3/utils/wscript_build | 4 +++- > 2 files changed, 6 insertions(+), 15 deletions(-) > >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 993086a66b2..06e6edaf26a 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', >-- >2.13.6 > > >From 0d81835e8d089e562cdb4f6739422a3acda52f05 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 20 Aug 2018 15:46:27 -0700 >Subject: [PATCH 10/22] s3:smbstatus: Use cmdline_messaging_context > >Use cmdline_messaging_context to initialize a messaging context instead >of open coding the same steps. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(backported from commit d7fa3815a83a50fd9e3d78cac0d5ef3eb79235e5) >--- > source3/utils/status.c | 17 +++-------------- > source3/wscript_build | 1 + > 2 files changed, 4 insertions(+), 14 deletions(-) > >diff --git a/source3/utils/status.c b/source3/utils/status.c >index dfb1d921a42..4756b971697 100644 >--- a/source3/utils/status.c >+++ b/source3/utils/status.c >@@ -48,6 +48,7 @@ > #include "serverid.h" > #include "status_profile.h" > #include "smbd/notifyd/notifyd.h" >+#include "cmdline_contexts.h" > > #define SMB_MAXPIDS 2048 > static uid_t Ucrit_uid = 0; /* added by OH */ >@@ -605,21 +606,9 @@ int main(int argc, const char *argv[]) > d_printf("using configfile = %s\n", get_dyn_CONFIGFILE()); > } > >- if (!lp_load_initial_only(get_dyn_CONFIGFILE())) { >- fprintf(stderr, "Can't load %s - run testparm to debug it\n", >- get_dyn_CONFIGFILE()); >- ret = -1; >- goto done; >- } >- >- >- /* >- * This implicitly initializes the global ctdbd connection, >- * usable by the db_open() calls further down. >- */ >- msg_ctx = messaging_init(NULL, samba_tevent_context_init(NULL)); >+ msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE()); > if (msg_ctx == NULL) { >- fprintf(stderr, "messaging_init failed\n"); >+ fprintf(stderr, "Could not initialize messaging, not root?\n"); > ret = -1; > goto done; > } >diff --git a/source3/wscript_build b/source3/wscript_build >index fb61f3236df..5a8380906ae 100644 >--- a/source3/wscript_build >+++ b/source3/wscript_build >@@ -1146,6 +1146,7 @@ bld.SAMBA3_BINARY('smbstatus', > talloc > smbconf > popt_samba3 >+ cmdline_contexts > smbd_base > LOCKING > PROFILE >-- >2.13.6 > > >From 1dfed8b1b47ec1eecb37fa3ca43a4cae996b8f0c Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 20 Aug 2018 15:54:11 -0700 >Subject: [PATCH 11/22] rpcclient: Use cmdline_messaging_context > >Use cmdline_messaging_context with its error checking instead of open >coding the same steps. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit dd3ae2ffdc66be4707471bfccf27ef446b5599cb) >--- > source3/rpcclient/rpcclient.c | 28 ++-------------------------- > 1 file changed, 2 insertions(+), 26 deletions(-) > >diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c >index 3635a3e31ff..9dfac2b60ec 100644 >--- a/source3/rpcclient/rpcclient.c >+++ b/source3/rpcclient/rpcclient.c >@@ -35,6 +35,7 @@ > #include "auth/gensec/gensec.h" > #include "../libcli/smb/smbXcli_base.h" > #include "messages.h" >+#include "cmdline_contexts.h" > > enum pipe_auth_type_spnego { > PIPE_AUTH_TYPE_SPNEGO_NONE = 0, >@@ -950,7 +951,6 @@ static NTSTATUS process_cmd(struct user_auth_info *auth_info, > const char *binding_string = NULL; > const char *host; > int signing_state = SMB_SIGNING_IPC_DEFAULT; >- struct tevent_context *ev_ctx = NULL; > > /* make sure the vars that get altered (4th field) are in > a fixed location or certain compilers complain */ >@@ -1016,30 +1016,7 @@ static NTSTATUS process_cmd(struct user_auth_info *auth_info, > poptFreeContext(pc); > popt_burn_cmdline_password(argc, argv); > >- ev_ctx = samba_tevent_context_init(frame); >- if (ev_ctx == NULL) { >- fprintf(stderr, "Could not init event context\n"); >- result = 1; >- goto done; >- } >- >- nt_status = messaging_init_client(ev_ctx, >- ev_ctx, >- &rpcclient_msg_ctx); >- if (geteuid() != 0 && >- NT_STATUS_EQUAL(nt_status, NT_STATUS_ACCESS_DENIED)) { >- /* >- * Normal to fail to initialize messaging context >- * if we're not root as we don't have ability to >- * read lock directory. >- */ >- DBG_NOTICE("Unable to initialize messaging context. " >- "Must be root to do that.\n"); >- } else if (!NT_STATUS_IS_OK(nt_status)) { >- fprintf(stderr, "Could not init messaging context\n"); >- result = 1; >- goto done; >- } >+ rpcclient_msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE()); > > if (!init_names()) { > result = 1; >@@ -1258,7 +1235,6 @@ static NTSTATUS process_cmd(struct user_auth_info *auth_info, > popt_free_cmdline_auth_info(); > netlogon_creds_cli_close_global_db(); > TALLOC_FREE(rpcclient_msg_ctx); >- TALLOC_FREE(ev_ctx); > TALLOC_FREE(frame); > return result; > } >-- >2.13.6 > > >From 7e52365a5b3be1d4076766f03c8eb173bb4eef4b Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 20 Aug 2018 16:01:00 -0700 >Subject: [PATCH 12/22] s3:net: Use cmdline_messaging_context > >Use cmdline_messaging_context with its error checking instead of open >coding the same steps. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(backported from commit f2b659e4f518ccb06f221dd028f99883ca1a1847) >--- > source3/utils/net.c | 25 ++----------------------- > 1 file changed, 2 insertions(+), 23 deletions(-) > >diff --git a/source3/utils/net.c b/source3/utils/net.c >index 9ee32cd6110..759d8cd442b 100644 >--- a/source3/utils/net.c >+++ b/source3/utils/net.c >@@ -48,6 +48,7 @@ > #include "../libcli/security/security.h" > #include "passdb.h" > #include "messages.h" >+#include "cmdline_contexts.h" > > #ifdef WITH_FAKE_KASERVER > #include "utils/net_afs.h" >@@ -916,7 +917,6 @@ static struct functable net_func[] = { > poptContext pc; > TALLOC_CTX *frame = talloc_stackframe(); > struct net_context *c = talloc_zero(frame, struct net_context); >- NTSTATUS status; > > struct poptOption long_options[] = { > {"help", 'h', POPT_ARG_NONE, 0, 'h'}, >@@ -1030,28 +1030,7 @@ static struct functable net_func[] = { > } > } > >- if (!lp_load_initial_only(get_dyn_CONFIGFILE())) { >- d_fprintf(stderr, "Can't load %s - run testparm to debug it\n", >- get_dyn_CONFIGFILE()); >- exit(1); >- } >- >- status = messaging_init_client(c, >- samba_tevent_context_init(c), >- &c->msg_ctx); >- if (geteuid() != 0 && >- NT_STATUS_EQUAL(status, NT_STATUS_ACCESS_DENIED)) { >- /* >- * Normal to fail to initialize messaging context >- * if we're not root as we don't have ability to >- * read lock directory. >- */ >- DBG_NOTICE("Unable to initialize messaging context. " >- "Must be root to do that.\n"); >- } else if (!NT_STATUS_IS_OK(status)) { >- d_fprintf(stderr, "Failed to init messaging context\n"); >- exit(1); >- } >+ c->msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE()); > > if (!lp_load_global(get_dyn_CONFIGFILE())) { > d_fprintf(stderr, "Can't load %s - run testparm to debug it\n", >-- >2.13.6 > > >From 4bd03fe95d631c865d7faca3bbdbf39853e071f9 Mon Sep 17 00:00:00 2001 >From: Ralph Boehme <slow@samba.org> >Date: Tue, 10 Jul 2018 16:29:46 +0200 >Subject: [PATCH 13/22] s3:messaging: remove unused messaging_init_client() > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Ralph Boehme <slow@samba.org> >Reviewed-by: Christof Schmitt <cs@samba.org> >(cherry picked from commit f56496b11469f0e9af9ba81cefb796ca1febabb1) >--- > source3/include/messages.h | 3 --- > source3/lib/messages.c | 9 --------- > 2 files changed, 12 deletions(-) > >diff --git a/source3/include/messages.h b/source3/include/messages.h >index 29c394af317..f7b40664b0b 100644 >--- a/source3/include/messages.h >+++ b/source3/include/messages.h >@@ -46,9 +46,6 @@ struct messaging_rec; > > struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, > struct tevent_context *ev); >-NTSTATUS messaging_init_client(TALLOC_CTX *mem_ctx, >- struct tevent_context *ev, >- struct messaging_context **pmsg_ctx); > > struct server_id messaging_server_id(const struct messaging_context *msg_ctx); > struct tevent_context *messaging_tevent_context( >diff --git a/source3/lib/messages.c b/source3/lib/messages.c >index 5a31f3414d7..d946aa770b7 100644 >--- a/source3/lib/messages.c >+++ b/source3/lib/messages.c >@@ -595,15 +595,6 @@ struct messaging_context *messaging_init(TALLOC_CTX *mem_ctx, > return ctx; > } > >-NTSTATUS messaging_init_client(TALLOC_CTX *mem_ctx, >- struct tevent_context *ev, >- struct messaging_context **pmsg_ctx) >-{ >- return messaging_init_internal(mem_ctx, >- ev, >- pmsg_ctx); >-} >- > struct server_id messaging_server_id(const struct messaging_context *msg_ctx) > { > return msg_ctx->id; >-- >2.13.6 > > >From f637fe513a9d44ee38812c79491257c5fbfa0a1f Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 20 Aug 2018 16:08:21 -0700 >Subject: [PATCH 14/22] s3:pdbedit: Use cmdline_messaging_context > >Initialize the messaging context through cmdline_messaging_context to >allow access to config in clustered Samba. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit 4661537c201acebee991d219d151cb481f56265c) >--- > source3/utils/pdbedit.c | 3 +++ > source3/utils/wscript_build | 1 + > 2 files changed, 4 insertions(+) > >diff --git a/source3/utils/pdbedit.c b/source3/utils/pdbedit.c >index a353bae7c4e..09f0320ed63 100644 >--- a/source3/utils/pdbedit.c >+++ b/source3/utils/pdbedit.c >@@ -25,6 +25,7 @@ > #include "../librpc/gen_ndr/samr.h" > #include "../libcli/security/security.h" > #include "passdb.h" >+#include "cmdline_contexts.h" > > #define BIT_BACKEND 0x00000004 > #define BIT_VERBOSE 0x00000008 >@@ -1117,6 +1118,8 @@ int main(int argc, const char **argv) > if (user_name == NULL) > user_name = poptGetArg(pc); > >+ cmdline_messaging_context(get_dyn_CONFIGFILE()); >+ > if (!lp_load_global(get_dyn_CONFIGFILE())) { > fprintf(stderr, "Can't load %s - run testparm to debug it\n", get_dyn_CONFIGFILE()); > exit(1); >diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build >index 06e6edaf26a..c039231eecc 100644 >--- a/source3/utils/wscript_build >+++ b/source3/utils/wscript_build >@@ -47,6 +47,7 @@ bld.SAMBA3_BINARY('pdbedit', > talloc > smbconf > popt_samba3 >+ cmdline_contexts > pdb > PASSWD_UTIL''') > >-- >2.13.6 > > >From 1d386633324bbf6fb61b7bc65cd465b7abadecc9 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 20 Aug 2018 16:11:11 -0700 >Subject: [PATCH 15/22] s3:testparm: Use cmdline_messaging_context > >Call cmdline_messaging_context to initialize a messaging config before >accessing clustered Samba config. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit ea7a4ff7ae5ef2b22fb7ef5640d6b946c064cfc3) >--- > source3/utils/testparm.c | 3 +++ > source3/utils/wscript_build | 4 +++- > 2 files changed, 6 insertions(+), 1 deletion(-) > >diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c >index a53eea5b8cc..4145f75b3da 100644 >--- a/source3/utils/testparm.c >+++ b/source3/utils/testparm.c >@@ -35,6 +35,7 @@ > #include "system/filesys.h" > #include "popt_common.h" > #include "lib/param/loadparm.h" >+#include "cmdline_contexts.h" > > #include <regex.h> > >@@ -698,6 +699,8 @@ static void do_per_share_checks(int s) > goto done; > } > >+ cmdline_messaging_context(config_file); >+ > fprintf(stderr,"Load smb config files from %s\n",config_file); > > if (!lp_load_with_registry_shares(config_file)) { >diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build >index c039231eecc..9748ed7f857 100644 >--- a/source3/utils/wscript_build >+++ b/source3/utils/wscript_build >@@ -162,7 +162,9 @@ bld.SAMBA3_BINARY('testparm', > deps=''' > talloc > smbconf >- popt_samba3''') >+ popt_samba3 >+ cmdline_contexts >+ ''') > > bld.SAMBA3_BINARY('net', > source='''net.c >-- >2.13.6 > > >From fac2d07d9c6b965407743a3bcbc56e30934e3b68 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 20 Aug 2018 16:15:02 -0700 >Subject: [PATCH 16/22] s3:sharesec: Use cmdline_messaging_context > >Call cmdline_messasging_context to initialize messaging context before >accessing clustered Samba config. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit cab8f27bbc927e48c52bac6350325e8ec38092b2) >--- > source3/utils/sharesec.c | 2 ++ > source3/utils/wscript_build | 4 +++- > 2 files changed, 5 insertions(+), 1 deletion(-) > >diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c >index d9f81587f0e..375ae582ae5 100644 >--- a/source3/utils/sharesec.c >+++ b/source3/utils/sharesec.c >@@ -28,6 +28,7 @@ struct cli_state; > #include "../libcli/security/security.h" > #include "passdb/machine_sid.h" > #include "util_sd.h" >+#include "cmdline_contexts.h" > > static TALLOC_CTX *ctx; > >@@ -420,6 +421,7 @@ int main(int argc, const char *argv[]) > > setlinebuf(stdout); > >+ cmdline_messaging_context(get_dyn_CONFIGFILE()); > lp_load_with_registry_shares(get_dyn_CONFIGFILE()); > > /* check for initializing secrets.tdb first */ >diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build >index 9748ed7f857..b0ea6964023 100644 >--- a/source3/utils/wscript_build >+++ b/source3/utils/wscript_build >@@ -97,7 +97,9 @@ bld.SAMBA3_BINARY('sharesec', > talloc > msrpc3 > libcli_lsa3 >- popt_samba3''') >+ popt_samba3 >+ cmdline_contexts >+ ''') > > bld.SAMBA3_BINARY('log2pcap', > source='log2pcaphex.c', >-- >2.13.6 > > >From 480f9bc51fcdd3aef6f3880d1621674629507f35 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 20 Aug 2018 16:18:20 -0700 >Subject: [PATCH 17/22] s3: ntlm_auth: Use cmdline_messaging_context > >Call cmdline_messaging_context to initialize the messaging context >before accessing clustered Samba config. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit 9ed617474f588ceb42c8929ee8a51071a408c219) >--- > source3/utils/ntlm_auth.c | 3 +++ > source3/utils/wscript_build | 1 + > 2 files changed, 4 insertions(+) > >diff --git a/source3/utils/ntlm_auth.c b/source3/utils/ntlm_auth.c >index 8f77680416f..78e189a932f 100644 >--- a/source3/utils/ntlm_auth.c >+++ b/source3/utils/ntlm_auth.c >@@ -47,6 +47,7 @@ > #include "nsswitch/libwbclient/wbclient.h" > #include "lib/param/loadparm.h" > #include "lib/util/base64.h" >+#include "cmdline_contexts.h" > > #if HAVE_KRB5 > #include "auth/kerberos/pac_utils.h" >@@ -2364,6 +2365,8 @@ enum { > > poptFreeContext(pc); > >+ cmdline_messaging_context(get_dyn_CONFIGFILE()); >+ > if (!lp_load_global(get_dyn_CONFIGFILE())) { > d_fprintf(stderr, "ntlm_auth: error opening config file %s. Error was %s\n", > get_dyn_CONFIGFILE(), strerror(errno)); >diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build >index b0ea6964023..acd22f77fbf 100644 >--- a/source3/utils/wscript_build >+++ b/source3/utils/wscript_build >@@ -127,6 +127,7 @@ bld.SAMBA3_BINARY('ntlm_auth', > tiniparser > libsmb > popt_samba3 >+ cmdline_contexts > gse gensec''') > > bld.SAMBA3_BINARY('dbwrap_tool', >-- >2.13.6 > > >From 77bc8d270256b6ca0312e39d7edfd87517c674f0 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Mon, 20 Aug 2018 16:21:51 -0700 >Subject: [PATCH 18/22] s3:eventlogadm: Use cmdline_messaging_context > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(backported from commit 095123df945270bc51635a19125a7abdfcd4ab80) >--- > source3/utils/eventlogadm.c | 4 ++++ > source3/utils/wscript_build | 3 ++- > 2 files changed, 6 insertions(+), 1 deletion(-) > >diff --git a/source3/utils/eventlogadm.c b/source3/utils/eventlogadm.c >index 5ef091a9ae3..db874dfae8a 100644 >--- a/source3/utils/eventlogadm.c >+++ b/source3/utils/eventlogadm.c >@@ -30,6 +30,7 @@ > #include "registry/reg_util_token.h" > #include "registry/reg_backend_db.h" > #include "../libcli/registry/util_reg.h" >+#include "cmdline_contexts.h" > > extern int optind; > extern char *optarg; >@@ -472,6 +473,9 @@ int main( int argc, char *argv[] ) > exit( 1 ); > } > >+ cmdline_messaging_context(configfile == NULL ? >+ get_dyn_CONFIGFILE() : configfile); >+ > if ( configfile == NULL ) { > lp_load_global(get_dyn_CONFIGFILE()); > } else if (!lp_load_global(configfile)) { >diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build >index acd22f77fbf..6ff34ef482c 100644 >--- a/source3/utils/wscript_build >+++ b/source3/utils/wscript_build >@@ -89,7 +89,8 @@ bld.SAMBA3_BINARY('eventlogadm', > deps=''' > talloc > smbconf >- LIBEVENTLOG''') >+ LIBEVENTLOG >+ cmdline_contexts''') > > bld.SAMBA3_BINARY('sharesec', > source='sharesec.c ../lib/util_sd.c', >-- >2.13.6 > > >From 476b82b2e02e8ca38d88aa96e62db38c7ff7e6d0 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Tue, 21 Aug 2018 12:34:34 -0700 >Subject: [PATCH 19/22] s3:dbwrap_tool: Use cmdline_messaging_context > >Initialize the messaging context through cmdline_messaging_context to >allow access to config in clustered Samba. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit 7eeff96b826711b5a8d44ab24603dafcc0343d84) >--- > source3/utils/dbwrap_tool.c | 3 +++ > source3/utils/wscript_build | 4 +++- > 2 files changed, 6 insertions(+), 1 deletion(-) > >diff --git a/source3/utils/dbwrap_tool.c b/source3/utils/dbwrap_tool.c >index 94aacd8ba26..b182e9cbfab 100644 >--- a/source3/utils/dbwrap_tool.c >+++ b/source3/utils/dbwrap_tool.c >@@ -28,6 +28,7 @@ > #include "dbwrap/dbwrap_watch.h" > #include "messages.h" > #include "util_tdb.h" >+#include "cmdline_contexts.h" > > enum dbwrap_op { OP_FETCH, OP_STORE, OP_DELETE, OP_ERASE, OP_LISTKEYS, > OP_EXISTS }; >@@ -428,6 +429,8 @@ int main(int argc, const char **argv) > while (extra_argv[extra_argc]) extra_argc++; > } > >+ cmdline_messaging_context(get_dyn_CONFIGFILE()); >+ > lp_load_global(get_dyn_CONFIGFILE()); > > if ((extra_argc < 2) || (extra_argc > 5)) { >diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build >index 6ff34ef482c..42aaf683695 100644 >--- a/source3/utils/wscript_build >+++ b/source3/utils/wscript_build >@@ -135,7 +135,9 @@ bld.SAMBA3_BINARY('dbwrap_tool', > source='dbwrap_tool.c', > deps=''' > talloc >- popt_samba3''') >+ popt_samba3 >+ cmdline_contexts >+ ''') > > bld.SAMBA3_BINARY('dbwrap_torture', > source='dbwrap_torture.c', >-- >2.13.6 > > >From e8c4ab518c44d71b6f9678a628f480b56b52eae1 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Tue, 21 Aug 2018 12:35:11 -0700 >Subject: [PATCH 20/22] s3:smbcontrol: Use cmdline_messaging_context > >Initialize the messaging context through cmdline_messaging_context to >allow access to config in clustered Samba. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit de040eafbd7d729316d757c14c44df163a4b36ad) >--- > source3/utils/smbcontrol.c | 19 +++++++++++-------- > source3/utils/wscript_build | 1 + > 2 files changed, 12 insertions(+), 8 deletions(-) > >diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c >index b024f3afbd9..5f7c2e8de0d 100644 >--- a/source3/utils/smbcontrol.c >+++ b/source3/utils/smbcontrol.c >@@ -35,6 +35,7 @@ > #include "util_tdb.h" > #include "../lib/util/pidfile.h" > #include "serverid.h" >+#include "cmdline_contexts.h" > > #if HAVE_LIBUNWIND_H > #include <libunwind.h> >@@ -1643,21 +1644,23 @@ int main(int argc, const char **argv) > if (argc <= 1) > usage(pc); > >+ msg_ctx = cmdline_messaging_context(get_dyn_CONFIGFILE()); >+ if (msg_ctx == NULL) { >+ fprintf(stderr, >+ "Could not init messaging context, not root?\n"); >+ TALLOC_FREE(frame); >+ exit(1); >+ } >+ >+ evt_ctx = server_event_context(); >+ > lp_load_global(get_dyn_CONFIGFILE()); > > /* Need to invert sense of return code -- samba > * routines mostly return True==1 for success, but > * shell needs 0. */ > >- if (!(evt_ctx = samba_tevent_context_init(NULL)) || >- !(msg_ctx = messaging_init(NULL, evt_ctx))) { >- fprintf(stderr, "could not init messaging context\n"); >- TALLOC_FREE(frame); >- exit(1); >- } >- > ret = !do_command(evt_ctx, msg_ctx, argc, argv); >- TALLOC_FREE(msg_ctx); > TALLOC_FREE(frame); > return ret; > } >diff --git a/source3/utils/wscript_build b/source3/utils/wscript_build >index 42aaf683695..4b1893f79b7 100644 >--- a/source3/utils/wscript_build >+++ b/source3/utils/wscript_build >@@ -18,6 +18,7 @@ bld.SAMBA3_BINARY('smbcontrol', > talloc > smbconf > popt_samba3 >+ cmdline_contexts > PRINTBASE''') > > bld.SAMBA3_BINARY('smbtree', >-- >2.13.6 > > >From e80f7fc91080e9ea267167079e4ccf2ec5a95d91 Mon Sep 17 00:00:00 2001 >From: Christof Schmitt <cs@samba.org> >Date: Tue, 21 Aug 2018 16:11:02 -0700 >Subject: [PATCH 21/22] s3:smbget: Use cmdline_messaging_context > >Initialize the messaging context through cmdline_messaging_context to >allow access to config in clustered Samba. > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Christof Schmitt <cs@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit 20ed13923ed3c55e1b293e5440028d29384e9d3a) >--- > source3/utils/smbget.c | 3 +++ > 1 file changed, 3 insertions(+) > >diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c >index 37462fa131f..4653c6894e0 100644 >--- a/source3/utils/smbget.c >+++ b/source3/utils/smbget.c >@@ -20,6 +20,7 @@ > #include "system/filesys.h" > #include "popt_common_cmdline.h" > #include "libsmbclient.h" >+#include "cmdline_contexts.h" > > static int columns = 0; > >@@ -879,6 +880,8 @@ int main(int argc, char **argv) > > popt_burn_cmdline_password(argc, argv); > >+ cmdline_messaging_context(get_dyn_CONFIGFILE()); >+ > if (smbc_init(get_auth_data, opt.debuglevel) < 0) { > fprintf(stderr, "Unable to initialize libsmbclient\n"); > return 1; >-- >2.13.6 > > >From a4449c8e3cb4daa493842180760c07b6655c4694 Mon Sep 17 00:00:00 2001 >From: Volker Lendecke <vl@samba.org> >Date: Fri, 7 Sep 2018 07:27:46 +0200 >Subject: [PATCH 22/22] examples: Fix the smb2mount build > >BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465 > >Signed-off-by: Volker Lendecke <vl@samba.org> >Reviewed-by: Ralph Boehme <slow@samba.org> >(cherry picked from commit 94852e3544bf2cace3ddba8b9c89d986d77fdab5) >--- > examples/fuse/smb2mount.c | 2 +- > examples/fuse/wscript_build | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > >diff --git a/examples/fuse/smb2mount.c b/examples/fuse/smb2mount.c >index 816b0b597ad..ec4be809f6d 100644 >--- a/examples/fuse/smb2mount.c >+++ b/examples/fuse/smb2mount.c >@@ -20,7 +20,7 @@ > > #include "source3/include/includes.h" > #include "popt.h" >-#include "popt_common.h" >+#include "popt_common_cmdline.h" > #include "client.h" > #include "libsmb/proto.h" > #include "clifuse.h" >diff --git a/examples/fuse/wscript_build b/examples/fuse/wscript_build >index 9ec5fc0a0f2..31341e4357d 100644 >--- a/examples/fuse/wscript_build >+++ b/examples/fuse/wscript_build >@@ -3,5 +3,5 @@ > if bld.env.HAVE_FUSE: > bld.SAMBA_BINARY('smb2mount', > source='smb2mount.c clifuse.c', >- deps='smbconf popt_samba3 libsmb fuse', >+ deps='smbconf popt_samba3_cmdline libsmb fuse', > install=False) >-- >2.13.6 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Flags:
cs
:
review+
Actions:
View
Attachments on
bug 13465
:
14224
|
14264
|
14281
|
14511
| 14512 |
14513