From 6947e4141016bb140dfae62cd71be9d9ba5d7060 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sat, 4 May 2019 12:12:04 +0200 Subject: [PATCH 1/2] s3:dbwrap: initialize messaging before getting the ctdb connection This is a better fix for bug #13465. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13925 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit ca95d7f41b683b4d7ac59ed6ee709d44abfe2019) --- source3/lib/dbwrap/dbwrap_open.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c index c8dfd9103a8..20084bca471 100644 --- a/source3/lib/dbwrap/dbwrap_open.c +++ b/source3/lib/dbwrap/dbwrap_open.c @@ -141,13 +141,19 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx, struct messaging_context *msg_ctx; struct ctdbd_connection *conn; + /* + * Initialize messaging before getting the ctdb + * connection, as the ctdb connection requires messaging + * to be initialized. + */ + msg_ctx = global_messaging_context(); + conn = messaging_ctdb_connection(); if (conn == NULL) { DBG_WARNING("No ctdb connection\n"); errno = EIO; return NULL; } - msg_ctx = global_messaging_context(); result = db_open_ctdb(mem_ctx, msg_ctx, base, hash_size, -- 2.21.0 From ca5652c7ee22955fb1690534fe33759ccb008ee5 Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Sat, 4 May 2019 12:12:48 +0200 Subject: [PATCH 2/2] s3: remove now unneeded call to cmdline_messaging_context() This was only needed as dbwrap_open() had a bug where it asked for the ctdb connection before initializing messaging. The previous commit fixed that so we can now safely remove the calls to cmdline_messaging_context() from all tools that don't use messaging. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13925 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Thu Oct 24 09:33:47 UTC 2019 on sn-devel-184 (cherry picked from commit 9471508391fd3bcf199b1e94f8d9ee2b956e8f8e) --- source3/lib/popt_common_cmdline.c | 7 ------- source3/utils/dbwrap_tool.c | 2 -- source3/utils/eventlogadm.c | 3 --- source3/utils/ntlm_auth.c | 2 -- source3/utils/pdbedit.c | 2 -- source3/utils/sharesec.c | 1 - source3/utils/smbget.c | 2 -- source3/utils/smbpasswd.c | 2 -- source3/utils/testparm.c | 2 -- 9 files changed, 23 deletions(-) diff --git a/source3/lib/popt_common_cmdline.c b/source3/lib/popt_common_cmdline.c index 79e34847f48..39a787510a3 100644 --- a/source3/lib/popt_common_cmdline.c +++ b/source3/lib/popt_common_cmdline.c @@ -102,15 +102,8 @@ 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/utils/dbwrap_tool.c b/source3/utils/dbwrap_tool.c index 2808a5d68bf..153a4459ee0 100644 --- a/source3/utils/dbwrap_tool.c +++ b/source3/utils/dbwrap_tool.c @@ -422,8 +422,6 @@ 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/eventlogadm.c b/source3/utils/eventlogadm.c index db874dfae8a..2770fffa48c 100644 --- a/source3/utils/eventlogadm.c +++ b/source3/utils/eventlogadm.c @@ -473,9 +473,6 @@ 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/ntlm_auth.c b/source3/utils/ntlm_auth.c index 2be641c891c..87f6554ae4f 100644 --- a/source3/utils/ntlm_auth.c +++ b/source3/utils/ntlm_auth.c @@ -2504,8 +2504,6 @@ 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/pdbedit.c b/source3/utils/pdbedit.c index 74f8c3b0b2f..14edbaeceea 100644 --- a/source3/utils/pdbedit.c +++ b/source3/utils/pdbedit.c @@ -1128,8 +1128,6 @@ 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/sharesec.c b/source3/utils/sharesec.c index 2ea81b9adfa..10c347eaac3 100644 --- a/source3/utils/sharesec.c +++ b/source3/utils/sharesec.c @@ -501,7 +501,6 @@ 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/smbget.c b/source3/utils/smbget.c index 58690be56e3..a948a336445 100644 --- a/source3/utils/smbget.c +++ b/source3/utils/smbget.c @@ -1003,8 +1003,6 @@ 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; diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index 8e2b9d7f80f..a6509abe5cb 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -197,8 +197,6 @@ 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); diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index efa58a6a417..9ba625da4bf 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -742,8 +742,6 @@ 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)) { -- 2.21.0