[PATCH] Fix bug 13465
Christof Schmitt
cs at samba.org
Thu Aug 30 22:31:42 UTC 2018
On Sun, Aug 26, 2018 at 05:16:53PM +0200, Ralph Böhme wrote:
> On Tue, Aug 21, 2018 at 04:23:42PM -0700, Christof Schmitt via samba-technical wrote:
> >Here is an update patch series.
>
> Thanks a *lot* for taking the stab. :)
Thank you for the review!
> >This hopefully detangles a bit of the dependencies.
> >POPT_CREDENTIALS is moved, so that only command line tools link it
> >and its dependencies. A new cmdline_messaging_context wrapper is
> >added for the checks required by the command line tools; it then
> >provides the server_messaging_context.
>
> Generally looks good, mostly reviewed-by-me, few nitpicks in the
> attached patchset, also rebased on top current master (with resolved
> conflict in the "test:doc: Skip 'clustering=yes'" commit).
>
> The third commit "s3:lib: Move popt_common_credentials to separate
> file" doesn't build due to a linking error, cf the commit message.
> Can you check?
Yes. The problem was that the update in wscript_build was only in a
later patch. I moved that to fix the link error.
> >As the server_messaging_context is also used outside of the server
> >processes, the last four patches rename the "server" contects to
> >"common" contexts; i would suggest to not backport these patches
> >and i have left out the bugzilla number.
>
> Maybe give the kid a name that reflects what it is and call it
> "global" instead of "common"?
Yes, i made the change, together with the other requested changes
(commit message update and fixup of pointer initialization). See
attached updated patches.
Christof
-------------- next part --------------
From 970486bf4f7a7faf6336c08ef72a621497ab1bca Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Mon, 9 Jul 2018 17:11:57 +0200
Subject: [PATCH 01/25] 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 at samba.org>
Reviewed-by: Christof Schmitt <cs at samba.org>
---
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.17.0
From 6e4c277cc2f783264013925ecf512a69f52674d7 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 13 Aug 2018 15:07:20 -0700
Subject: [PATCH 02/25] 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 at samba.org>
---
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.17.0
From f339f4bc797aa6a9126b9066f0dcfa02745fdbe2 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 13 Aug 2018 15:39:08 -0700
Subject: [PATCH 03/25] 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 at samba.org>
---
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 25ba01d6216..2f193459d5d 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 b4e25e6e479..f7e196226cf 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 69564f65232..3c095d0bc4a 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 27bd6f8f2c2..20115ae1624 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 3b539ef1045..fb0f165a18d 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 93e6abaac0d..67bb87e7a74 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''')
@@ -150,7 +150,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',
@@ -217,7 +219,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 f463a8c4261..82f9d62297b 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -268,7 +268,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',
@@ -1093,7 +1098,7 @@ bld.SAMBA3_BINARY('client/smbclient',
''',
deps='''
talloc
- popt_samba3
+ popt_samba3_cmdline
smbconf
ndr-standard
SMBREADLINE
--
2.17.0
From 3569236aefffd6e504f01068b075d1760bba1a7f Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 20 Aug 2018 14:44:28 -0700
Subject: [PATCH 04/25] 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 at samba.org>
---
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 at 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 at 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 82f9d62297b..320b84d7180 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -281,6 +281,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.17.0
From 0c3c25bdb8718701f6ffb44375217e48d6d09ec8 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 10 Jul 2018 08:11:31 +0200
Subject: [PATCH 05/25] 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 at samba.org>
Reviewed-by: Christof Schmitt <cs at samba.org>
---
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 291ba57e0bb..322934c55f0 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -4120,7 +4120,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.17.0
From 00b5542184f34cea58969391f3c9d473813ce837 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 10 Jul 2018 10:38:10 +0200
Subject: [PATCH 06/25] 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 at samba.org>
Reviewed-by: Christof Schmitt <cs at samba.org>
---
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 @@ expect retype new password:
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 at 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.17.0
From 988b14e6c6b03818e9be5ee0b52ae7aac725f4ff Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 10 Jul 2018 15:26:40 +0200
Subject: [PATCH 07/25] 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 at samba.org>
Reviewed-by: Christof Schmitt <cs at samba.org>
---
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 320b84d7180..2e70e9f7122 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -273,7 +273,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.17.0
From 959b0036beef50137eba6e0de1d750180a324327 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 21 Aug 2018 14:58:01 -0700
Subject: [PATCH 08/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
python/samba/tests/docs.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/python/samba/tests/docs.py b/python/samba/tests/docs.py
index 6ffdeab9040..5a59ed68588 100644
--- a/python/samba/tests/docs.py
+++ b/python/samba/tests/docs.py
@@ -159,12 +159,13 @@ class SmbDotConfTests(TestCase):
# registry shares appears to need sudo
self._set_arbitrary(['bin/testparm'],
- exceptions=['client lanman auth',
- 'client plaintext auth',
- 'registry shares',
- 'smb ports',
- 'rpc server dynamic port range',
- 'name resolve order'])
+ exceptions = ['client lanman auth',
+ 'client plaintext auth',
+ 'registry shares',
+ 'smb ports',
+ 'rpc server dynamic port range',
+ 'name resolve order',
+ 'clustering'])
self._test_empty(['bin/testparm'])
def test_default_s4(self):
--
2.17.0
From 81b6ef91e0e7dcb9b31928fb3432ff1325376371 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 20 Aug 2018 15:38:33 -0700
Subject: [PATCH 09/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
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 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',
--
2.17.0
From 1e6feffd9d4b995a501a73a6f4f80949d0c2a003 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 20 Aug 2018 15:46:27 -0700
Subject: [PATCH 10/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
source3/utils/status.c | 25 +++----------------------
source3/wscript_build | 1 +
2 files changed, 4 insertions(+), 22 deletions(-)
diff --git a/source3/utils/status.c b/source3/utils/status.c
index f0d1a851be4..0fe2c820eb2 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 */
@@ -527,7 +528,6 @@ int main(int argc, const char *argv[])
};
TALLOC_CTX *frame = talloc_stackframe();
int ret = 0;
- struct tevent_context *ev;
struct messaging_context *msg_ctx = NULL;
char *db_path;
bool ok;
@@ -606,28 +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.
- */
- ev = samba_tevent_context_init(NULL);
- if (ev == NULL) {
- fprintf(stderr, "samba_tevent_context_init failed\n");
- ret = -1;
- goto done;
- }
-
- msg_ctx = messaging_init(NULL, ev);
+ 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 2e70e9f7122..7051c0c329e 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -1156,6 +1156,7 @@ bld.SAMBA3_BINARY('smbstatus',
talloc
smbconf
popt_samba3
+ cmdline_contexts
smbd_base
LOCKING
PROFILE
--
2.17.0
From dd2d2b54e63bbcbd10d30586ff6baf69cc11895c Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 20 Aug 2018 15:54:11 -0700
Subject: [PATCH 11/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
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 f7e196226cf..9f95f1a7a8c 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 @@ out_free:
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 @@ out_free:
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 @@ done:
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.17.0
From 024c11cd1494dfea1ad2389406229e205f2d2d82 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 20 Aug 2018 16:01:00 -0700
Subject: [PATCH 12/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
source3/utils/net.c | 29 ++---------------------------
1 file changed, 2 insertions(+), 27 deletions(-)
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 3c095d0bc4a..b3bd4b67118 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"
@@ -915,9 +916,7 @@ static struct functable net_func[] = {
const char **argv_const = discard_const_p(const char *, argv);
poptContext pc;
TALLOC_CTX *frame = talloc_stackframe();
- struct tevent_context *ev;
struct net_context *c = talloc_zero(frame, struct net_context);
- NTSTATUS status;
struct poptOption long_options[] = {
{"help", 'h', POPT_ARG_NONE, 0, 'h'},
@@ -1032,31 +1031,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);
- }
-
- ev = samba_tevent_context_init(c);
- if (ev == NULL) {
- d_fprintf(stderr, "samba_tevent_context_init failed\n");
- exit(1);
- }
- status = messaging_init_client(c, ev, &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.17.0
From 874edc6f9a668b043894239390e3ea4a89ea7849 Mon Sep 17 00:00:00 2001
From: Ralph Boehme <slow at samba.org>
Date: Tue, 10 Jul 2018 16:29:46 +0200
Subject: [PATCH 13/25] s3:messaging: remove unused messaging_init_client()
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465
Signed-off-by: Ralph Boehme <slow at samba.org>
Reviewed-by: Christof Schmitt <cs at samba.org>
---
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 cf6c1ce9c5a..aa899142333 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -635,15 +635,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.17.0
From d5ffed2bafc1eb24de2950aa7e0f2d336557bb03 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 20 Aug 2018 16:08:21 -0700
Subject: [PATCH 14/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
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 5c947e2fbde..a2394880c65 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
@@ -1121,6 +1122,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 06a986cada4..570c4506bee 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.17.0
From 397b72eda464da6da2939526e306d3d56d3fc85b Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 20 Aug 2018 16:11:11 -0700
Subject: [PATCH 15/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
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 8113eea0020..88dfc42d492 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 570c4506bee..ffa0762d828 100644
--- a/source3/utils/wscript_build
+++ b/source3/utils/wscript_build
@@ -163,7 +163,9 @@ bld.SAMBA3_BINARY('testparm',
deps='''
talloc
smbconf
- popt_samba3''')
+ popt_samba3
+ cmdline_contexts
+ ''')
bld.SAMBA3_BINARY('net',
source='''net.c
--
2.17.0
From 382f53cb1b9b9a1eb6409798ba8d8ea1a7511f46 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 20 Aug 2018 16:15:02 -0700
Subject: [PATCH 16/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
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 ffa0762d828..7e586dc268d 100644
--- a/source3/utils/wscript_build
+++ b/source3/utils/wscript_build
@@ -98,7 +98,9 @@ bld.SAMBA3_BINARY('sharesec',
talloc
msrpc3
libcli_lsa3
- popt_samba3''')
+ popt_samba3
+ cmdline_contexts
+ ''')
bld.SAMBA3_BINARY('log2pcap',
source='log2pcaphex.c',
--
2.17.0
From 8b6113b7b3ad1d2d61f8d7f6cfde24f732fde1a1 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 20 Aug 2018 16:18:20 -0700
Subject: [PATCH 17/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
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 7d27712980b..b8014ec1034 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"
@@ -2380,6 +2381,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 7e586dc268d..92404a61c2d 100644
--- a/source3/utils/wscript_build
+++ b/source3/utils/wscript_build
@@ -128,6 +128,7 @@ bld.SAMBA3_BINARY('ntlm_auth',
tiniparser
libsmb
popt_samba3
+ cmdline_contexts
gse gensec''')
bld.SAMBA3_BINARY('dbwrap_tool',
--
2.17.0
From 7aba875979cfc010393f540b32ffa6dfed0438c6 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Mon, 20 Aug 2018 16:21:51 -0700
Subject: [PATCH 18/25] s3:eventlogadm: Use cmdline_messaging_context
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13465
Signed-off-by: Christof Schmitt <cs at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
source3/utils/eventlogadm.c | 4 ++++
source3/utils/wscript_build | 1 +
2 files changed, 5 insertions(+)
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 92404a61c2d..eabebcf3d52 100644
--- a/source3/utils/wscript_build
+++ b/source3/utils/wscript_build
@@ -89,6 +89,7 @@ bld.SAMBA3_BINARY('eventlogadm',
deps='''
talloc
smbconf
+ cmdline_contexts
LIBEVENTLOG''',
install_path='${SBINDIR}')
--
2.17.0
From 66e523b9dd08b6dd28322e0dca4a47d6aba42ed6 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 21 Aug 2018 12:34:34 -0700
Subject: [PATCH 19/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
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 eabebcf3d52..11bd2015c3a 100644
--- a/source3/utils/wscript_build
+++ b/source3/utils/wscript_build
@@ -136,7 +136,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.17.0
From 7c7a4f9d63ca623ef28b740fa0bbaa99b148983b Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 21 Aug 2018 12:35:11 -0700
Subject: [PATCH 20/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
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 6e612e9dd8f..d768849b766 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>
@@ -1609,21 +1610,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 11bd2015c3a..6793c6d5c8a 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.17.0
From cf389db71eb4f85c28ce2f1b1b37be4e172f59c8 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 21 Aug 2018 16:11:02 -0700
Subject: [PATCH 21/25] 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 at samba.org>
Reviewed-by: Ralph Boehme <slow at samba.org>
---
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.17.0
From 35dd259ffd45c444f155b53f76b5354f710ed85b Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 21 Aug 2018 11:06:16 -0700
Subject: [PATCH 22/25] s3: Rename server_event_context() to
global_event_context()
This reflects that the event context is also used outside of the server
processes.
The command used for the rename:
find . -name '*.[hc]' -print0 | xargs -0 sed -i 's/server_event_context/global_event_context/'
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/include/proto.h | 4 +-
source3/lib/server_contexts.c | 6 +-
source3/modules/vfs_aio_fork.c | 4 +-
source3/modules/vfs_preopen.c | 2 +-
source3/nmbd/nmbd.c | 4 +-
source3/printing/printing.c | 28 +++++-----
source3/printing/queue_process.c | 4 +-
source3/rpc_server/fss/srv_fss_agent.c | 4 +-
source3/rpc_server/mdssvc/mdssvc.c | 6 +-
source3/rpc_server/samr/srv_samr_nt.c | 2 +-
source3/rpc_server/spoolss/srv_spoolss_nt.c | 18 +++---
source3/smbd/server.c | 2 +-
source3/smbd/server_exit.c | 2 +-
source3/torture/test_dbwrap_do_locked.c | 4 +-
source3/torture/test_g_lock.c | 2 +-
source3/utils/smbcontrol.c | 2 +-
source3/winbindd/idmap_ldap.c | 2 +-
source3/winbindd/idmap_rfc2307.c | 2 +-
source3/winbindd/winbindd.c | 56 +++++++++----------
source3/winbindd/winbindd_cm.c | 4 +-
source3/winbindd/winbindd_cred_cache.c | 14 ++---
source3/winbindd/winbindd_domain_info.c | 2 +-
source3/winbindd/winbindd_dual.c | 22 ++++----
source3/winbindd/winbindd_gpupdate.c | 4 +-
source3/winbindd/winbindd_irpc.c | 18 +++---
source3/winbindd/winbindd_pam_auth.c | 2 +-
source3/winbindd/winbindd_pam_auth_crap.c | 2 +-
source3/winbindd/winbindd_pam_chauthtok.c | 2 +-
.../winbindd_pam_chng_pswd_auth_crap.c | 2 +-
source3/winbindd/winbindd_pam_logoff.c | 2 +-
source3/winbindd/winbindd_util.c | 2 +-
31 files changed, 115 insertions(+), 115 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index fea4ba51be5..5b460e5d666 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -888,8 +888,8 @@ uint32_t get_int_param( const char* param );
char* get_string_param( const char* param );
/* The following definitions come from lib/server_contexts.c */
-struct tevent_context *server_event_context(void);
-void server_event_context_free(void);
+struct tevent_context *global_event_context(void);
+void global_event_context_free(void);
struct messaging_context *server_messaging_context(void);
void server_messaging_context_free(void);
diff --git a/source3/lib/server_contexts.c b/source3/lib/server_contexts.c
index b21cf0a4c81..40f1ed046ef 100644
--- a/source3/lib/server_contexts.c
+++ b/source3/lib/server_contexts.c
@@ -23,7 +23,7 @@
static struct tevent_context *server_event_ctx = NULL;
-struct tevent_context *server_event_context(void)
+struct tevent_context *global_event_context(void)
{
if (!server_event_ctx) {
/*
@@ -39,7 +39,7 @@ struct tevent_context *server_event_context(void)
return server_event_ctx;
}
-void server_event_context_free(void)
+void global_event_context_free(void)
{
TALLOC_FREE(server_event_ctx);
}
@@ -55,7 +55,7 @@ struct messaging_context *server_messaging_context(void)
* children exiting.
*/
server_msg_ctx = messaging_init(NULL,
- server_event_context());
+ global_event_context());
}
return server_msg_ctx;
}
diff --git a/source3/modules/vfs_aio_fork.c b/source3/modules/vfs_aio_fork.c
index 5ad2dcee4ba..a1fed5c0655 100644
--- a/source3/modules/vfs_aio_fork.c
+++ b/source3/modules/vfs_aio_fork.c
@@ -256,7 +256,7 @@ static void aio_child_cleanup(struct tevent_context *event_ctx,
/*
* Re-schedule the next cleanup round
*/
- list->cleanup_event = tevent_add_timer(server_event_context(), list,
+ list->cleanup_event = tevent_add_timer(global_event_context(), list,
timeval_add(&now, 30, 0),
aio_child_cleanup, list);
@@ -287,7 +287,7 @@ static struct aio_child_list *init_aio_children(struct vfs_handle_struct *handle
if (children->cleanup_event == NULL) {
children->cleanup_event =
- tevent_add_timer(server_event_context(), children,
+ tevent_add_timer(global_event_context(), children,
timeval_current_ofs(30, 0),
aio_child_cleanup, children);
if (children->cleanup_event == NULL) {
diff --git a/source3/modules/vfs_preopen.c b/source3/modules/vfs_preopen.c
index b6a63d35b1e..84b13556195 100644
--- a/source3/modules/vfs_preopen.c
+++ b/source3/modules/vfs_preopen.c
@@ -239,7 +239,7 @@ static NTSTATUS preopen_init_helper(struct preopen_helper *h)
}
close(fdpair[1]);
h->fd = fdpair[0];
- h->fde = tevent_add_fd(server_event_context(), h->state, h->fd,
+ h->fde = tevent_add_fd(global_event_context(), h->state, h->fd,
TEVENT_FD_READ, preopen_helper_readable, h);
if (h->fde == NULL) {
close(h->fd);
diff --git a/source3/nmbd/nmbd.c b/source3/nmbd/nmbd.c
index 7884ff8dd06..cb4a46d9261 100644
--- a/source3/nmbd/nmbd.c
+++ b/source3/nmbd/nmbd.c
@@ -46,7 +46,7 @@ time_t StartupTime = 0;
struct tevent_context *nmbd_event_context(void)
{
- return server_event_context();
+ return global_event_context();
}
/**************************************************************************** **
@@ -928,7 +928,7 @@ static bool open_sockets(bool isdaemon, int port)
exit(1);
}
- msg = messaging_init(NULL, server_event_context());
+ msg = messaging_init(NULL, global_event_context());
if (msg == NULL) {
return 1;
}
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index efdd6870999..105166ddf7d 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1682,7 +1682,7 @@ void print_queue_receive(struct messaging_context *msg,
return;
}
- print_queue_update_with_lock(server_event_context(), msg, sharename,
+ print_queue_update_with_lock(global_event_context(), msg, sharename,
get_printer_fns_from_type((enum printing_types)printing_type),
lpqcommand, lprmcommand );
@@ -1764,7 +1764,7 @@ static void print_queue_update(struct messaging_context *msg_ctx,
if ( force || background_lpq_updater_pid == -1 ) {
DEBUG(4,("print_queue_update: updating queue [%s] myself\n", sharename));
current_printif = get_printer_fns( snum );
- print_queue_update_with_lock(server_event_context(), msg_ctx,
+ print_queue_update_with_lock(global_event_context(), msg_ctx,
sharename, current_printif,
lpqcommand, lprmcommand);
@@ -2307,7 +2307,7 @@ WERROR print_job_delete(const struct auth_session_info *server_info,
}
}
- if (!print_job_delete1(server_event_context(), msg_ctx, snum, jobid)) {
+ if (!print_job_delete1(global_event_context(), msg_ctx, snum, jobid)) {
werr = WERR_ACCESS_DENIED;
goto err_out;
}
@@ -2387,7 +2387,7 @@ WERROR print_job_pause(const struct auth_session_info *server_info,
/* Send a printer notify message */
- notify_job_status(server_event_context(), msg_ctx, sharename, jobid,
+ notify_job_status(global_event_context(), msg_ctx, sharename, jobid,
JOB_STATUS_PAUSED);
/* how do we tell if this succeeded? */
@@ -2453,7 +2453,7 @@ WERROR print_job_resume(const struct auth_session_info *server_info,
/* Send a printer notify message */
- notify_job_status(server_event_context(), msg_ctx, sharename, jobid,
+ notify_job_status(global_event_context(), msg_ctx, sharename, jobid,
JOB_STATUS_QUEUED);
werr = WERR_OK;
@@ -2881,7 +2881,7 @@ WERROR print_job_start(const struct auth_session_info *server_info,
goto fail;
}
- pjob_store(server_event_context(), msg_ctx, sharename, jobid, &pjob);
+ pjob_store(global_event_context(), msg_ctx, sharename, jobid, &pjob);
/* Update the 'jobs added' entry used by print_queue_status. */
add_to_jobs_added(pdb, jobid);
@@ -2896,7 +2896,7 @@ WERROR print_job_start(const struct auth_session_info *server_info,
fail:
if (jobid != -1) {
- pjob_delete(server_event_context(), msg_ctx, sharename, jobid);
+ pjob_delete(global_event_context(), msg_ctx, sharename, jobid);
}
release_print_db(pdb);
@@ -2930,7 +2930,7 @@ void print_job_endpage(struct messaging_context *msg_ctx,
}
pjob->page_count++;
- pjob_store(server_event_context(), msg_ctx, sharename, jobid, pjob);
+ pjob_store(global_event_context(), msg_ctx, sharename, jobid, pjob);
err_out:
talloc_free(tmp_ctx);
}
@@ -3014,7 +3014,7 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum,
DEBUG(5,("print_job_end: canceling spool of %s (%s)\n",
pjob->filename, pjob->size ? "deleted" : "zero length" ));
unlink(pjob->filename);
- pjob_delete(server_event_context(), msg_ctx, sharename, jobid);
+ pjob_delete(global_event_context(), msg_ctx, sharename, jobid);
return NT_STATUS_OK;
}
@@ -3052,7 +3052,7 @@ NTSTATUS print_job_end(struct messaging_context *msg_ctx, int snum,
pjob->spooled = True;
pjob->status = LPQ_QUEUED;
- pjob_store(server_event_context(), msg_ctx, sharename, jobid, pjob);
+ pjob_store(global_event_context(), msg_ctx, sharename, jobid, pjob);
/* make sure the database is up to date */
if (print_cache_expired(lp_const_servicename(snum), True))
@@ -3066,7 +3066,7 @@ fail:
/* Still need to add proper error return propagation! 010122:JRR */
pjob->fd = -1;
unlink(pjob->filename);
- pjob_delete(server_event_context(), msg_ctx, sharename, jobid);
+ pjob_delete(global_event_context(), msg_ctx, sharename, jobid);
err_out:
talloc_free(tmp_ctx);
return status;
@@ -3344,7 +3344,7 @@ WERROR print_queue_pause(const struct auth_session_info *server_info,
/* Send a printer notify message */
- notify_printer_status(server_event_context(), msg_ctx, snum,
+ notify_printer_status(global_event_context(), msg_ctx, snum,
PRINTER_STATUS_PAUSED);
return WERR_OK;
@@ -3381,7 +3381,7 @@ WERROR print_queue_resume(const struct auth_session_info *server_info,
/* Send a printer notify message */
- notify_printer_status(server_event_context(), msg_ctx, snum,
+ notify_printer_status(global_event_context(), msg_ctx, snum,
PRINTER_STATUS_OK);
return WERR_OK;
@@ -3431,7 +3431,7 @@ WERROR print_queue_purge(const struct auth_session_info *server_info,
jobid);
if (owner || can_job_admin) {
- print_job_delete1(server_event_context(), msg_ctx,
+ print_job_delete1(global_event_context(), msg_ctx,
snum, jobid);
}
}
diff --git a/source3/printing/queue_process.c b/source3/printing/queue_process.c
index c4648ce2b6a..1d60f259a86 100644
--- a/source3/printing/queue_process.c
+++ b/source3/printing/queue_process.c
@@ -211,8 +211,8 @@ static void bq_setup_sig_term_handler(void)
{
struct tevent_signal *se;
- se = tevent_add_signal(server_event_context(),
- server_event_context(),
+ se = tevent_add_signal(global_event_context(),
+ global_event_context(),
SIGTERM, 0,
bq_sig_term_handler,
NULL);
diff --git a/source3/rpc_server/fss/srv_fss_agent.c b/source3/rpc_server/fss/srv_fss_agent.c
index ab7f9055939..03c2668171b 100644
--- a/source3/rpc_server/fss/srv_fss_agent.c
+++ b/source3/rpc_server/fss/srv_fss_agent.c
@@ -527,7 +527,7 @@ static void fss_seq_tout_set(TALLOC_CTX *mem_ctx,
memcpy(sc_set_id, &sc_set->id, sizeof(*sc_set_id));
}
- tmr = tevent_add_timer(server_event_context(),
+ tmr = tevent_add_timer(global_event_context(),
mem_ctx,
timeval_current_ofs(tout, 0),
fss_seq_tout_handler, sc_set_id);
@@ -948,7 +948,7 @@ uint32_t _fss_CommitShadowCopySet(struct pipes_struct *p,
for (sc = sc_set->scs; sc; sc = sc->next) {
char *base_path;
char *snap_path;
- status = commit_sc_with_conn(frame, server_event_context(),
+ status = commit_sc_with_conn(frame, global_event_context(),
p->msg_ctx, p->session_info, sc,
&base_path, &snap_path);
if (!NT_STATUS_IS_OK(status)) {
diff --git a/source3/rpc_server/mdssvc/mdssvc.c b/source3/rpc_server/mdssvc/mdssvc.c
index 5a63d379738..7c996941cfa 100644
--- a/source3/rpc_server/mdssvc/mdssvc.c
+++ b/source3/rpc_server/mdssvc/mdssvc.c
@@ -772,7 +772,7 @@ static void tracker_cursor_cb(GObject *object,
SLQ_DEBUG(10, slq, "closed");
g_main_loop_quit(slq->mds_ctx->gmainloop);
- req = slq_destroy_send(slq, server_event_context(), &slq);
+ req = slq_destroy_send(slq, global_event_context(), &slq);
if (req == NULL) {
slq->state = SLQ_STATE_ERROR;
return;
@@ -1166,7 +1166,7 @@ static bool slrpc_open_query(struct mds_ctx *mds_ctx,
slq->last_used = timeval_current();
slq->start_time = slq->last_used;
slq->expire_time = timeval_add(&slq->last_used, MAX_SL_RUNTIME, 0);
- slq->te = tevent_add_timer(server_event_context(), slq,
+ slq->te = tevent_add_timer(global_event_context(), slq,
slq->expire_time, slq_close_timer, slq);
if (slq->te == NULL) {
DEBUG(1, ("tevent_add_timer failed\n"));
@@ -1361,7 +1361,7 @@ static bool slrpc_fetch_query_results(struct mds_ctx *mds_ctx,
TALLOC_FREE(slq->te);
slq->last_used = timeval_current();
slq->expire_time = timeval_add(&slq->last_used, MAX_SL_RUNTIME, 0);
- slq->te = tevent_add_timer(server_event_context(), slq,
+ slq->te = tevent_add_timer(global_event_context(), slq,
slq->expire_time, slq_close_timer, slq);
if (slq->te == NULL) {
DEBUG(1, ("tevent_add_timer failed\n"));
diff --git a/source3/rpc_server/samr/srv_samr_nt.c b/source3/rpc_server/samr/srv_samr_nt.c
index adc9e41e49e..00497efc96e 100644
--- a/source3/rpc_server/samr/srv_samr_nt.c
+++ b/source3/rpc_server/samr/srv_samr_nt.c
@@ -308,7 +308,7 @@ static void set_disp_info_cache_timeout(DISP_INFO *disp_info, time_t secs_fromno
(unsigned int)secs_fromnow ));
disp_info->cache_timeout_event = tevent_add_timer(
- server_event_context(), NULL,
+ global_event_context(), NULL,
timeval_current_ofs(secs_fromnow, 0),
disp_info_cache_idle_timeout_handler, (void *)disp_info);
}
diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c
index 2bdce560c38..ac76e7e6e1b 100644
--- a/source3/rpc_server/spoolss/srv_spoolss_nt.c
+++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c
@@ -6043,7 +6043,7 @@ WERROR _spoolss_WritePrinter(struct pipes_struct *p,
return WERR_INVALID_HANDLE;
/* print_job_write takes care of checking for PJOB_SMBD_SPOOLING */
- buffer_written = print_job_write(server_event_context(),p->msg_ctx,
+ buffer_written = print_job_write(global_event_context(),p->msg_ctx,
snum, Printer->jobid,
(const char *)r->in.data.data,
(size_t)r->in._data_size);
@@ -6544,7 +6544,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n",
printer->drivername));
- notify_printer_driver(server_event_context(), msg_ctx,
+ notify_printer_driver(global_event_context(), msg_ctx,
snum, printer->drivername ?
printer->drivername : "");
}
@@ -6572,7 +6572,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
}
if (!force_update) {
- notify_printer_comment(server_event_context(), msg_ctx,
+ notify_printer_comment(global_event_context(), msg_ctx,
snum, printer->comment ?
printer->comment : "");
}
@@ -6600,7 +6600,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
}
if (!force_update) {
- notify_printer_sharename(server_event_context(),
+ notify_printer_sharename(global_event_context(),
msg_ctx,
snum, printer->sharename ?
printer->sharename : "");
@@ -6641,7 +6641,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
}
if (!force_update) {
- notify_printer_printername(server_event_context(),
+ notify_printer_printername(global_event_context(),
msg_ctx, snum, p ? p : "");
}
@@ -6671,7 +6671,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
}
if (!force_update) {
- notify_printer_port(server_event_context(),
+ notify_printer_port(global_event_context(),
msg_ctx, snum, printer->portname ?
printer->portname : "");
}
@@ -6699,7 +6699,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
}
if (!force_update) {
- notify_printer_location(server_event_context(),
+ notify_printer_location(global_event_context(),
msg_ctx, snum,
printer->location ?
printer->location : "");
@@ -6728,7 +6728,7 @@ static WERROR update_dsspooler(TALLOC_CTX *mem_ctx,
}
if (!force_update) {
- notify_printer_sepfile(server_event_context(),
+ notify_printer_sepfile(global_event_context(),
msg_ctx, snum,
printer->sepfile ?
printer->sepfile : "");
@@ -7718,7 +7718,7 @@ static WERROR spoolss_setjob_1(TALLOC_CTX *mem_ctx,
return WERR_OK;
}
- if (!print_job_set_name(server_event_context(), msg_ctx,
+ if (!print_job_set_name(global_event_context(), msg_ctx,
printer_name, job_id, r->document_name)) {
return WERR_INVALID_HANDLE;
}
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index b73ac2bb731..a9201f8424c 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -1776,7 +1776,7 @@ extern void build_options(bool screen);
* initialized before the messaging context, cause the messaging
* context holds an event context.
*/
- ev_ctx = server_event_context();
+ ev_ctx = global_event_context();
if (ev_ctx == NULL) {
exit(1);
}
diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c
index cc8ea18aeda..4bf3ea82d4d 100644
--- a/source3/smbd/server_exit.c
+++ b/source3/smbd/server_exit.c
@@ -218,7 +218,7 @@ static void exit_server_common(enum server_exit_reason how,
TALLOC_FREE(global_smbXsrv_client);
smbprofile_dump();
server_messaging_context_free();
- server_event_context_free();
+ global_event_context_free();
TALLOC_FREE(smbd_memcache_ctx);
locking_end();
diff --git a/source3/torture/test_dbwrap_do_locked.c b/source3/torture/test_dbwrap_do_locked.c
index 2e5305d4d75..9245e5d357d 100644
--- a/source3/torture/test_dbwrap_do_locked.c
+++ b/source3/torture/test_dbwrap_do_locked.c
@@ -78,9 +78,9 @@ bool run_dbwrap_do_locked1(int dummy)
int ret = false;
NTSTATUS status;
- ev = server_event_context();
+ ev = global_event_context();
if (ev == NULL) {
- fprintf(stderr, "server_event_context() failed\n");
+ fprintf(stderr, "global_event_context() failed\n");
return false;
}
msg = server_messaging_context();
diff --git a/source3/torture/test_g_lock.c b/source3/torture/test_g_lock.c
index 624f7cdd46e..29046d67886 100644
--- a/source3/torture/test_g_lock.c
+++ b/source3/torture/test_g_lock.c
@@ -31,7 +31,7 @@ static bool get_g_lock_ctx(TALLOC_CTX *mem_ctx,
struct messaging_context **msg,
struct g_lock_ctx **ctx)
{
- *ev = server_event_context();
+ *ev = global_event_context();
if (*ev == NULL) {
fprintf(stderr, "tevent_context_init failed\n");
return false;
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index d768849b766..e23e1284012 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -1618,7 +1618,7 @@ int main(int argc, const char **argv)
exit(1);
}
- evt_ctx = server_event_context();
+ evt_ctx = global_event_context();
lp_load_global(get_dyn_CONFIGFILE());
diff --git a/source3/winbindd/idmap_ldap.c b/source3/winbindd/idmap_ldap.c
index 6765dfc217a..9b2b7c15806 100644
--- a/source3/winbindd/idmap_ldap.c
+++ b/source3/winbindd/idmap_ldap.c
@@ -455,7 +455,7 @@ static NTSTATUS idmap_ldap_db_init(struct idmap_domain *dom)
/* get_credentials deals with setting up creds */
- ret = smbldap_init(ctx, server_event_context(), ctx->url,
+ ret = smbldap_init(ctx, global_event_context(), ctx->url,
false, NULL, NULL, &ctx->smbldap_state);
if (!NT_STATUS_IS_OK(ret)) {
DEBUG(1, ("ERROR: smbldap_init (%s) failed!\n", ctx->url));
diff --git a/source3/winbindd/idmap_rfc2307.c b/source3/winbindd/idmap_rfc2307.c
index 264ccb034fb..f30baf9e104 100644
--- a/source3/winbindd/idmap_rfc2307.c
+++ b/source3/winbindd/idmap_rfc2307.c
@@ -193,7 +193,7 @@ static NTSTATUS idmap_rfc2307_init_ldap(struct idmap_rfc2307_context *ctx,
}
/* assume anonymous if we don't have a specified user */
- ret = smbldap_init(mem_ctx, server_event_context(), url,
+ ret = smbldap_init(mem_ctx, global_event_context(), url,
(user_dn == NULL), user_dn, secret,
&ctx->smbldap_state);
SAFE_FREE(secret);
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index b63db381540..4781506c6f2 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -87,7 +87,7 @@ struct imessaging_context *winbind_imessaging_context(void)
* Note we MUST use the NULL context here, not the autofree context,
* to avoid side effects in forked children exiting.
*/
- msg = imessaging_init(NULL, lp_ctx, myself, server_event_context());
+ msg = imessaging_init(NULL, lp_ctx, myself, global_event_context());
talloc_unlink(NULL, lp_ctx);
if (msg == NULL) {
@@ -270,14 +270,14 @@ bool winbindd_setup_sig_term_handler(bool parent)
struct tevent_signal *se;
bool *is_parent;
- is_parent = talloc(server_event_context(), bool);
+ is_parent = talloc(global_event_context(), bool);
if (!is_parent) {
return false;
}
*is_parent = parent;
- se = tevent_add_signal(server_event_context(),
+ se = tevent_add_signal(global_event_context(),
is_parent,
SIGTERM, 0,
winbindd_sig_term_handler,
@@ -288,7 +288,7 @@ bool winbindd_setup_sig_term_handler(bool parent)
return false;
}
- se = tevent_add_signal(server_event_context(),
+ se = tevent_add_signal(global_event_context(),
is_parent,
SIGINT, 0,
winbindd_sig_term_handler,
@@ -299,7 +299,7 @@ bool winbindd_setup_sig_term_handler(bool parent)
return false;
}
- se = tevent_add_signal(server_event_context(),
+ se = tevent_add_signal(global_event_context(),
is_parent,
SIGQUIT, 0,
winbindd_sig_term_handler,
@@ -320,7 +320,7 @@ bool winbindd_setup_stdin_handler(bool parent, bool foreground)
if (foreground) {
struct stat st;
- is_parent = talloc(server_event_context(), bool);
+ is_parent = talloc(global_event_context(), bool);
if (!is_parent) {
return false;
}
@@ -336,7 +336,7 @@ bool winbindd_setup_stdin_handler(bool parent, bool foreground)
return false;
}
if (S_ISFIFO(st.st_mode) || S_ISSOCK(st.st_mode)) {
- tevent_add_fd(server_event_context(),
+ tevent_add_fd(global_event_context(),
is_parent,
0,
TEVENT_FD_READ,
@@ -368,15 +368,15 @@ bool winbindd_setup_sig_hup_handler(const char *lfile)
char *file = NULL;
if (lfile) {
- file = talloc_strdup(server_event_context(),
+ file = talloc_strdup(global_event_context(),
lfile);
if (!file) {
return false;
}
}
- se = tevent_add_signal(server_event_context(),
- server_event_context(),
+ se = tevent_add_signal(global_event_context(),
+ global_event_context(),
SIGHUP, 0,
winbindd_sig_hup_handler,
file);
@@ -405,8 +405,8 @@ static bool winbindd_setup_sig_chld_handler(void)
{
struct tevent_signal *se;
- se = tevent_add_signal(server_event_context(),
- server_event_context(),
+ se = tevent_add_signal(global_event_context(),
+ global_event_context(),
SIGCHLD, 0,
winbindd_sig_chld_handler,
NULL);
@@ -431,8 +431,8 @@ static bool winbindd_setup_sig_usr2_handler(void)
{
struct tevent_signal *se;
- se = tevent_add_signal(server_event_context(),
- server_event_context(),
+ se = tevent_add_signal(global_event_context(),
+ global_event_context(),
SIGUSR2, 0,
winbindd_sig_usr2_handler,
NULL);
@@ -929,7 +929,7 @@ static void new_connection(int listen_sock, bool privileged)
state->privileged = privileged;
- req = wb_req_read_send(state, server_event_context(), state->sock,
+ req = wb_req_read_send(state, global_event_context(), state->sock,
WINBINDD_MAX_EXTRA_DATA);
if (req == NULL) {
TALLOC_FREE(state);
@@ -969,7 +969,7 @@ static void winbind_client_request_read(struct tevent_req *req)
return;
}
- req = wait_for_read_send(state, server_event_context(), state->sock,
+ req = wait_for_read_send(state, global_event_context(), state->sock,
true);
if (req == NULL) {
DEBUG(0, ("winbind_client_request_read[%d:%s]:"
@@ -981,7 +981,7 @@ static void winbind_client_request_read(struct tevent_req *req)
tevent_req_set_callback(req, winbind_client_activity, state);
state->io_req = req;
- req = process_request_send(state, server_event_context(), state);
+ req = process_request_send(state, global_event_context(), state);
if (req == NULL) {
DBG_ERR("process_request_send failed\n");
remove_client(state);
@@ -1069,7 +1069,7 @@ static void winbind_client_processed(struct tevent_req *req)
req = wb_req_read_send(
cli_state,
- server_event_context(),
+ global_event_context(),
cli_state->sock,
WINBINDD_MAX_EXTRA_DATA);
if (req == NULL) {
@@ -1296,7 +1296,7 @@ static bool winbindd_setup_listeners(void)
int rc;
char *socket_path;
- pub_state = talloc(server_event_context(),
+ pub_state = talloc(global_event_context(),
struct winbindd_listen_state);
if (!pub_state) {
goto failed;
@@ -1313,7 +1313,7 @@ static bool winbindd_setup_listeners(void)
goto failed;
}
- fde = tevent_add_fd(server_event_context(), pub_state, pub_state->fd,
+ fde = tevent_add_fd(global_event_context(), pub_state, pub_state->fd,
TEVENT_FD_READ, winbindd_listen_fde_handler,
pub_state);
if (fde == NULL) {
@@ -1322,7 +1322,7 @@ static bool winbindd_setup_listeners(void)
}
tevent_fd_set_auto_close(fde);
- priv_state = talloc(server_event_context(),
+ priv_state = talloc(global_event_context(),
struct winbindd_listen_state);
if (!priv_state) {
goto failed;
@@ -1345,7 +1345,7 @@ static bool winbindd_setup_listeners(void)
goto failed;
}
- fde = tevent_add_fd(server_event_context(), priv_state,
+ fde = tevent_add_fd(global_event_context(), priv_state,
priv_state->fd, TEVENT_FD_READ,
winbindd_listen_fde_handler, priv_state);
if (fde == NULL) {
@@ -1354,7 +1354,7 @@ static bool winbindd_setup_listeners(void)
}
tevent_fd_set_auto_close(fde);
- winbindd_scrub_clients_handler(server_event_context(), NULL,
+ winbindd_scrub_clients_handler(global_event_context(), NULL,
timeval_current(), NULL);
return true;
failed:
@@ -1473,7 +1473,7 @@ static void winbindd_register_handlers(struct messaging_context *msg_ctx,
}
if (scan_trusts) {
- if (tevent_add_timer(server_event_context(), NULL, timeval_zero(),
+ if (tevent_add_timer(global_event_context(), NULL, timeval_zero(),
rescan_trusted_domains, NULL) == NULL) {
DEBUG(0, ("Could not trigger rescan_trusted_domains()\n"));
exit(1);
@@ -1840,12 +1840,12 @@ int main(int argc, const char **argv)
*/
status = reinit_after_fork(server_messaging_context(),
- server_event_context(),
+ global_event_context(),
false, NULL);
if (!NT_STATUS_IS_OK(status)) {
exit_daemon("Winbindd reinit_after_fork() failed", map_errno_from_nt_status(status));
}
- initialize_password_db(true, server_event_context());
+ initialize_password_db(true, global_event_context());
/*
* Do not initialize the parent-child-pipe before becoming
@@ -1871,7 +1871,7 @@ int main(int argc, const char **argv)
rpc_lsarpc_init(NULL);
rpc_samr_init(NULL);
- winbindd_init_addrchange(NULL, server_event_context(),
+ winbindd_init_addrchange(NULL, global_event_context(),
server_messaging_context());
/* setup listen sockets */
@@ -1894,7 +1894,7 @@ int main(int argc, const char **argv)
while (1) {
frame = talloc_stackframe();
- if (tevent_loop_once(server_event_context()) == -1) {
+ if (tevent_loop_once(global_event_context()) == -1) {
DEBUG(1, ("tevent_loop_once() failed: %s\n",
strerror(errno)));
return 1;
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 95612034d2f..88ef36600d5 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -434,7 +434,7 @@ void set_domain_offline(struct winbindd_domain *domain)
calc_new_online_timeout_check(domain);
- domain->check_online_event = tevent_add_timer(server_event_context(),
+ domain->check_online_event = tevent_add_timer(global_event_context(),
NULL,
timeval_current_ofs(domain->check_online_timeout,0),
check_domain_online_handler,
@@ -610,7 +610,7 @@ void set_domain_online_request(struct winbindd_domain *domain)
TALLOC_FREE(domain->check_online_event);
- domain->check_online_event = tevent_add_timer(server_event_context(),
+ domain->check_online_event = tevent_add_timer(global_event_context(),
NULL,
tev,
check_domain_online_handler,
diff --git a/source3/winbindd/winbindd_cred_cache.c b/source3/winbindd/winbindd_cred_cache.c
index 5e019dfce0c..c7332297982 100644
--- a/source3/winbindd/winbindd_cred_cache.c
+++ b/source3/winbindd/winbindd_cred_cache.c
@@ -284,7 +284,7 @@ done:
if (entry->refresh_time == 0) {
entry->refresh_time = new_start;
}
- entry->event = tevent_add_timer(server_event_context(), entry,
+ entry->event = tevent_add_timer(global_event_context(), entry,
timeval_set(new_start, 0),
krb5_ticket_refresh_handler,
entry);
@@ -383,7 +383,7 @@ static void krb5_ticket_gain_handler(struct tevent_context *event_ctx,
if (entry->refresh_time == 0) {
entry->refresh_time = t.tv_sec;
}
- entry->event = tevent_add_timer(server_event_context(),
+ entry->event = tevent_add_timer(global_event_context(),
entry,
t,
krb5_ticket_refresh_handler,
@@ -402,7 +402,7 @@ static void add_krb5_ticket_gain_handler_event(struct WINBINDD_CCACHE_ENTRY *ent
struct timeval t)
{
entry->refresh_time = 0;
- entry->event = tevent_add_timer(server_event_context(),
+ entry->event = tevent_add_timer(global_event_context(),
entry,
t,
krb5_ticket_gain_handler,
@@ -422,13 +422,13 @@ void ccache_regain_all_now(void)
* the event has the krb5_ticket_gain_handler
*/
if (cur->refresh_time == 0) {
- new_event = tevent_add_timer(server_event_context(),
+ new_event = tevent_add_timer(global_event_context(),
cur,
t,
krb5_ticket_gain_handler,
cur);
} else {
- new_event = tevent_add_timer(server_event_context(),
+ new_event = tevent_add_timer(global_event_context(),
cur,
t,
krb5_ticket_refresh_handler,
@@ -545,7 +545,7 @@ NTSTATUS add_ccache_to_list(const char *princ_name,
if (!entry->refresh_time) {
entry->refresh_time = t.tv_sec;
}
- entry->event = tevent_add_timer(server_event_context(),
+ entry->event = tevent_add_timer(global_event_context(),
entry,
t,
krb5_ticket_refresh_handler,
@@ -643,7 +643,7 @@ NTSTATUS add_ccache_to_list(const char *princ_name,
if (entry->refresh_time == 0) {
entry->refresh_time = t.tv_sec;
}
- entry->event = tevent_add_timer(server_event_context(),
+ entry->event = tevent_add_timer(global_event_context(),
entry,
t,
krb5_ticket_refresh_handler,
diff --git a/source3/winbindd/winbindd_domain_info.c b/source3/winbindd/winbindd_domain_info.c
index 126691a893e..7a5d9eb3870 100644
--- a/source3/winbindd/winbindd_domain_info.c
+++ b/source3/winbindd/winbindd_domain_info.c
@@ -66,7 +66,7 @@ struct tevent_req *winbindd_domain_info_send(
* Send a ping down. This implicitly initializes the domain.
*/
- subreq = wb_domain_request_send(state, server_event_context(),
+ subreq = wb_domain_request_send(state, global_event_context(),
state->domain, &state->ping_request);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index cff2c974dee..e641b52fe13 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -242,7 +242,7 @@ static void wb_child_request_waited(struct tevent_req *subreq)
tevent_fd_set_flags(state->child->monitor_fde, 0);
- subreq = wb_simple_trans_send(state, server_event_context(), NULL,
+ subreq = wb_simple_trans_send(state, global_event_context(), NULL,
state->child->sock, state->request);
if (tevent_req_nomem(subreq, req)) {
return;
@@ -1188,7 +1188,7 @@ static void account_lockout_policy_handler(struct tevent_context *ctx,
nt_errstr(result)));
}
- child->lockout_policy_event = tevent_add_timer(server_event_context(), NULL,
+ child->lockout_policy_event = tevent_add_timer(global_event_context(), NULL,
timeval_current_ofs(3600, 0),
account_lockout_policy_handler,
child);
@@ -1353,7 +1353,7 @@ static void machine_password_change_handler(struct tevent_context *ctx,
}
done:
- child->machine_password_change_event = tevent_add_timer(server_event_context(), NULL,
+ child->machine_password_change_event = tevent_add_timer(global_event_context(), NULL,
next_change,
machine_password_change_handler,
child);
@@ -1498,13 +1498,13 @@ NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself,
status = reinit_after_fork(
server_messaging_context(),
- server_event_context(),
+ global_event_context(),
true, NULL);
if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("reinit_after_fork() failed\n"));
return status;
}
- initialize_password_db(true, server_event_context());
+ initialize_password_db(true, global_event_context());
close_conns_after_fork();
@@ -1672,8 +1672,8 @@ static bool fork_domain_child(struct winbindd_child *child)
return false;
}
- child->monitor_fde = tevent_add_fd(server_event_context(),
- server_event_context(),
+ child->monitor_fde = tevent_add_fd(global_event_context(),
+ global_event_context(),
fdpair[1],
TEVENT_FD_READ,
child_socket_readable,
@@ -1782,7 +1782,7 @@ static bool fork_domain_child(struct winbindd_child *child)
}
child->lockout_policy_event = tevent_add_timer(
- server_event_context(), NULL, timeval_zero(),
+ global_event_context(), NULL, timeval_zero(),
account_lockout_policy_handler,
child);
}
@@ -1796,13 +1796,13 @@ static bool fork_domain_child(struct winbindd_child *child)
if (calculate_next_machine_pwd_change(child->domain->name,
&next_change)) {
child->machine_password_change_event = tevent_add_timer(
- server_event_context(), NULL, next_change,
+ global_event_context(), NULL, next_change,
machine_password_change_handler,
child);
}
}
- fde = tevent_add_fd(server_event_context(), NULL, state.cli.sock,
+ fde = tevent_add_fd(global_event_context(), NULL, state.cli.sock,
TEVENT_FD_READ, child_handler, &state);
if (fde == NULL) {
DEBUG(1, ("tevent_add_fd failed\n"));
@@ -1814,7 +1814,7 @@ static bool fork_domain_child(struct winbindd_child *child)
int ret;
TALLOC_CTX *frame = talloc_stackframe();
- ret = tevent_loop_once(server_event_context());
+ ret = tevent_loop_once(global_event_context());
if (ret != 0) {
DEBUG(1, ("tevent_loop_once failed: %s\n",
strerror(errno)));
diff --git a/source3/winbindd/winbindd_gpupdate.c b/source3/winbindd/winbindd_gpupdate.c
index 75772ea4feb..293ca375564 100644
--- a/source3/winbindd/winbindd_gpupdate.c
+++ b/source3/winbindd/winbindd_gpupdate.c
@@ -83,7 +83,7 @@ void gpupdate_init(void)
{
struct tevent_timer *time_event;
struct timeval schedule;
- TALLOC_CTX * ctx = talloc_new(server_event_context());
+ TALLOC_CTX * ctx = talloc_new(global_event_context());
struct gpupdate_state *data = talloc(ctx, struct gpupdate_state);
struct loadparm_context *lp_ctx =
loadparm_init_s3(NULL, loadparm_s3_helpers());
@@ -107,7 +107,7 @@ void gpupdate_init(void)
if (data->lp_ctx == NULL) {
smb_panic("Could not load smb.conf\n");
}
- time_event = tevent_add_timer(server_event_context(), data->ctx,
+ time_event = tevent_add_timer(global_event_context(), data->ctx,
schedule, gpupdate_callback, data);
if (time_event == NULL) {
DEBUG(0, ("Failed scheduling the gpupdate event\n"));
diff --git a/source3/winbindd/winbindd_irpc.c b/source3/winbindd/winbindd_irpc.c
index 1e34fdfc2d0..2ac4f9bc422 100644
--- a/source3/winbindd/winbindd_irpc.c
+++ b/source3/winbindd/winbindd_irpc.c
@@ -129,7 +129,7 @@ static NTSTATUS wb_irpc_DsrUpdateReadOnlyServerDnsRecords(struct irpc_message *m
DEBUG(5, ("wb_irpc_DsrUpdateReadOnlyServerDnsRecords called\n"));
return wb_irpc_forward_rpc_call(msg, msg,
- server_event_context(),
+ global_event_context(),
req, NDR_WINBIND_DSRUPDATEREADONLYSERVERDNSRECORDS,
"winbind_DsrUpdateReadOnlyServerDnsRecords",
domain, IRPC_CALL_TIMEOUT);
@@ -212,7 +212,7 @@ static NTSTATUS wb_irpc_SamLogon(struct irpc_message *msg,
DEBUG(5, ("wb_irpc_SamLogon called\n"));
return wb_irpc_forward_rpc_call(msg, msg,
- server_event_context(),
+ global_event_context(),
req, NDR_WINBIND_SAMLOGON,
"winbind_SamLogon",
domain, IRPC_CALL_TIMEOUT);
@@ -272,7 +272,7 @@ static NTSTATUS wb_irpc_LogonControl(struct irpc_message *msg,
TALLOC_FREE(frame);
return wb_irpc_forward_rpc_call(msg, msg,
- server_event_context(),
+ global_event_context(),
req, NDR_WINBIND_LOGONCONTROL,
"winbind_LogonControl",
domain, 45 /* timeout */);
@@ -312,7 +312,7 @@ static NTSTATUS wb_irpc_GetForestTrustInformation(struct irpc_message *msg,
DEBUG(5, ("wb_irpc_GetForestTrustInformation called\n"));
return wb_irpc_forward_rpc_call(msg, msg,
- server_event_context(),
+ global_event_context(),
req, NDR_WINBIND_GETFORESTTRUSTINFORMATION,
"winbind_GetForestTrustInformation",
domain, 45 /* timeout */);
@@ -330,7 +330,7 @@ static NTSTATUS wb_irpc_SendToSam(struct irpc_message *msg,
DEBUG(5, ("wb_irpc_SendToSam called\n"));
return wb_irpc_forward_rpc_call(msg, msg,
- server_event_context(),
+ global_event_context(),
req, NDR_WINBIND_SENDTOSAM,
"winbind_SendToSam",
domain, IRPC_CALL_TIMEOUT);
@@ -396,7 +396,7 @@ static NTSTATUS wb_irpc_lsa_LookupSids3_call(struct irpc_message *msg,
}
subreq = wb_lookupsids_send(msg,
- server_event_context(),
+ global_event_context(),
sids, req->in.sids->num_sids);
if (subreq == NULL) {
return NT_STATUS_NO_MEMORY;
@@ -573,7 +573,7 @@ static NTSTATUS wb_irpc_lsa_LookupNames4_call(struct irpc_message *msg,
}
subreq = wb_lookupname_send(msg,
- server_event_context(),
+ global_event_context(),
nstate->namespace,
nstate->domain,
nstate->name,
@@ -647,7 +647,7 @@ static void wb_irpc_lsa_LookupNames4_done(struct tevent_req *subreq)
* to get a good lsa_RefDomainList
*/
subreq = wb_lookupsids_send(state,
- server_event_context(),
+ global_event_context(),
state->domain_sids,
state->num_domain_sids);
if (subreq == NULL) {
@@ -754,7 +754,7 @@ static NTSTATUS wb_irpc_GetDCName(struct irpc_message *msg,
state->req = req;
subreq = wb_dsgetdcname_send(msg,
- server_event_context(),
+ global_event_context(),
req->in.domain_name,
req->in.domain_guid,
req->in.site_name,
diff --git a/source3/winbindd/winbindd_pam_auth.c b/source3/winbindd/winbindd_pam_auth.c
index 95550ba9066..f91879e1c17 100644
--- a/source3/winbindd/winbindd_pam_auth.c
+++ b/source3/winbindd/winbindd_pam_auth.c
@@ -87,7 +87,7 @@ struct tevent_req *winbindd_pam_auth_send(TALLOC_CTX *mem_ctx,
return tevent_req_post(req, ev);
}
- subreq = wb_domain_request_send(state, server_event_context(), domain,
+ subreq = wb_domain_request_send(state, global_event_context(), domain,
request);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
diff --git a/source3/winbindd/winbindd_pam_auth_crap.c b/source3/winbindd/winbindd_pam_auth_crap.c
index 046517d1245..b7912db43df 100644
--- a/source3/winbindd/winbindd_pam_auth_crap.c
+++ b/source3/winbindd/winbindd_pam_auth_crap.c
@@ -132,7 +132,7 @@ struct tevent_req *winbindd_pam_auth_crap_send(
fstrcpy(request->data.auth_crap.workstation, lp_netbios_name());
}
- subreq = wb_domain_request_send(state, server_event_context(), domain,
+ subreq = wb_domain_request_send(state, global_event_context(), domain,
request);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
diff --git a/source3/winbindd/winbindd_pam_chauthtok.c b/source3/winbindd/winbindd_pam_chauthtok.c
index a6b8b66b9be..c802649497d 100644
--- a/source3/winbindd/winbindd_pam_chauthtok.c
+++ b/source3/winbindd/winbindd_pam_chauthtok.c
@@ -83,7 +83,7 @@ struct tevent_req *winbindd_pam_chauthtok_send(
return tevent_req_post(req, ev);
}
- subreq = wb_domain_request_send(state, server_event_context(),
+ subreq = wb_domain_request_send(state, global_event_context(),
contact_domain, request);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
diff --git a/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c b/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c
index e9ee0ab63ce..38d84be0af7 100644
--- a/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c
+++ b/source3/winbindd/winbindd_pam_chng_pswd_auth_crap.c
@@ -73,7 +73,7 @@ struct tevent_req *winbindd_pam_chng_pswd_auth_crap_send(
return tevent_req_post(req, ev);
}
- subreq = wb_domain_request_send(state, server_event_context(),
+ subreq = wb_domain_request_send(state, global_event_context(),
domain, request);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
diff --git a/source3/winbindd/winbindd_pam_logoff.c b/source3/winbindd/winbindd_pam_logoff.c
index 8f2b4882521..30f69e10045 100644
--- a/source3/winbindd/winbindd_pam_logoff.c
+++ b/source3/winbindd/winbindd_pam_logoff.c
@@ -98,7 +98,7 @@ struct tevent_req *winbindd_pam_logoff_send(TALLOC_CTX *mem_ctx,
break;
}
- subreq = wb_domain_request_send(state, server_event_context(), domain,
+ subreq = wb_domain_request_send(state, global_event_context(), domain,
request);
if (tevent_req_nomem(subreq, req)) {
return tevent_req_post(req, ev);
diff --git a/source3/winbindd/winbindd_util.c b/source3/winbindd/winbindd_util.c
index f913d395575..9bc25d98c4e 100644
--- a/source3/winbindd/winbindd_util.c
+++ b/source3/winbindd/winbindd_util.c
@@ -409,7 +409,7 @@ static void add_trusted_domains( struct winbindd_domain *domain )
state->request.length = sizeof(state->request);
state->request.cmd = WINBINDD_LIST_TRUSTDOM;
- req = wb_domain_request_send(state, server_event_context(),
+ req = wb_domain_request_send(state, global_event_context(),
domain, &state->request);
if (req == NULL) {
DEBUG(1, ("wb_domain_request_send failed\n"));
--
2.17.0
From 011365df822b9d07b090497d45a151389bc3ea18 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 21 Aug 2018 11:09:16 -0700
Subject: [PATCH 23/25] s3: Rename server_messaging_context() to
global_messaging_context()
This reflects that the messaging context is also used outside of the
server processes.
The command used for the rename:
find . -name '*.[hc]' -print0 | xargs -0 sed -i 's/server_messaging_context/global_messaging_context/'
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/auth/auth_samba4.c | 2 +-
source3/include/proto.h | 4 +--
source3/lib/cmdline_contexts.c | 4 +--
source3/lib/dbwrap/dbwrap_open.c | 2 +-
source3/lib/server_contexts.c | 4 +--
source3/locking/share_mode_lock.c | 2 +-
source3/passdb/pdb_interface.c | 2 +-
source3/printing/nt_printing.c | 6 ++---
source3/printing/spoolssd.c | 2 +-
source3/rpc_server/lsasd.c | 2 +-
source3/rpc_server/mdssd.c | 2 +-
source3/rpc_server/srvsvc/srv_srvsvc_nt.c | 4 +--
source3/smbd/msdfs.c | 8 +++---
source3/smbd/posix_acls.c | 2 +-
source3/smbd/server.c | 2 +-
source3/smbd/server_exit.c | 4 +--
source3/smbd/smbXsrv_session.c | 2 +-
source3/torture/test_dbwrap_ctdb.c | 2 +-
source3/torture/test_dbwrap_do_locked.c | 4 +--
source3/torture/test_g_lock.c | 2 +-
source3/torture/vfstest.c | 2 +-
source3/winbindd/winbindd.c | 18 ++++++-------
source3/winbindd/winbindd_cm.c | 32 +++++++++++------------
source3/winbindd/winbindd_dual.c | 32 +++++++++++------------
source3/winbindd/winbindd_dual_srv.c | 6 ++---
25 files changed, 76 insertions(+), 76 deletions(-)
diff --git a/source3/auth/auth_samba4.c b/source3/auth/auth_samba4.c
index 46c8f9ffd62..a71c75631d7 100644
--- a/source3/auth/auth_samba4.c
+++ b/source3/auth/auth_samba4.c
@@ -59,7 +59,7 @@ static struct server_id *new_server_id_task(TALLOC_CTX *mem_ctx)
}
}
- msg_ctx = server_messaging_context();
+ msg_ctx = global_messaging_context();
if (msg_ctx == NULL) {
return NULL;
}
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 5b460e5d666..685d481c100 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -890,8 +890,8 @@ char* get_string_param( const char* param );
/* The following definitions come from lib/server_contexts.c */
struct tevent_context *global_event_context(void);
void global_event_context_free(void);
-struct messaging_context *server_messaging_context(void);
-void server_messaging_context_free(void);
+struct messaging_context *global_messaging_context(void);
+void global_messaging_context_free(void);
/* The following definitions come from lib/sessionid_tdb.c */
struct sessionid;
diff --git a/source3/lib/cmdline_contexts.c b/source3/lib/cmdline_contexts.c
index 5713f7f7956..2bee7f38059 100644
--- a/source3/lib/cmdline_contexts.c
+++ b/source3/lib/cmdline_contexts.c
@@ -46,7 +46,7 @@ struct messaging_context *cmdline_messaging_context(const char *config_file)
exit(1);
}
- msg_ctx = server_messaging_context();
+ msg_ctx = global_messaging_context();
if (msg_ctx == NULL) {
if (geteuid() == 0) {
fprintf(stderr,
@@ -66,5 +66,5 @@ struct messaging_context *cmdline_messaging_context(const char *config_file)
void cmdline_messaging_context_free(void)
{
- server_messaging_context_free();
+ global_messaging_context_free();
}
diff --git a/source3/lib/dbwrap/dbwrap_open.c b/source3/lib/dbwrap/dbwrap_open.c
index e144d9881bb..33bf9696998 100644
--- a/source3/lib/dbwrap/dbwrap_open.c
+++ b/source3/lib/dbwrap/dbwrap_open.c
@@ -146,7 +146,7 @@ struct db_context *db_open(TALLOC_CTX *mem_ctx,
errno = EIO;
return NULL;
}
- msg_ctx = server_messaging_context();
+ msg_ctx = global_messaging_context();
result = db_open_ctdb(mem_ctx, msg_ctx, base,
hash_size,
diff --git a/source3/lib/server_contexts.c b/source3/lib/server_contexts.c
index 40f1ed046ef..2d92ad9f69c 100644
--- a/source3/lib/server_contexts.c
+++ b/source3/lib/server_contexts.c
@@ -46,7 +46,7 @@ void global_event_context_free(void)
static struct messaging_context *server_msg_ctx = NULL;
-struct messaging_context *server_messaging_context(void)
+struct messaging_context *global_messaging_context(void)
{
if (server_msg_ctx == NULL) {
/*
@@ -60,7 +60,7 @@ struct messaging_context *server_messaging_context(void)
return server_msg_ctx;
}
-void server_messaging_context_free(void)
+void global_messaging_context_free(void)
{
TALLOC_FREE(server_msg_ctx);
}
diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c
index 0bf7b9db90a..157e4cf1b2f 100644
--- a/source3/locking/share_mode_lock.c
+++ b/source3/locking/share_mode_lock.c
@@ -86,7 +86,7 @@ static bool locking_init_internal(bool read_only)
return False;
}
- lock_db = db_open_watched(NULL, &backend, server_messaging_context());
+ lock_db = db_open_watched(NULL, &backend, global_messaging_context());
if (lock_db == NULL) {
DBG_ERR("db_open_watched failed\n");
TALLOC_FREE(backend);
diff --git a/source3/passdb/pdb_interface.c b/source3/passdb/pdb_interface.c
index 7fdc33c4fa7..8b23da6b979 100644
--- a/source3/passdb/pdb_interface.c
+++ b/source3/passdb/pdb_interface.c
@@ -648,7 +648,7 @@ NTSTATUS pdb_delete_user(TALLOC_CTX *mem_ctx, struct samu *sam_acct)
* just return */
return status;
}
- messaging_send_all(server_messaging_context(),
+ messaging_send_all(global_messaging_context(),
ID_CACHE_DELETE,
msg_data,
strlen(msg_data) + 1);
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 9c4c488040f..fdd91454acd 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -1050,7 +1050,7 @@ static uint32_t get_correct_cversion(const struct auth_session_info *session_inf
driver_directory);
}
- nt_status = create_conn_struct_tos_cwd(server_messaging_context(),
+ nt_status = create_conn_struct_tos_cwd(global_messaging_context(),
printdollar_snum,
working_dir,
session_info,
@@ -1525,7 +1525,7 @@ WERROR move_driver_to_download_area(const struct auth_session_info *session_info
return WERR_BAD_NET_NAME;
}
- nt_status = create_conn_struct_tos_cwd(server_messaging_context(),
+ nt_status = create_conn_struct_tos_cwd(global_messaging_context(),
printdollar_snum,
lp_path(frame, printdollar_snum),
session_info,
@@ -2067,7 +2067,7 @@ bool delete_driver_files(const struct auth_session_info *session_info,
return false;
}
- nt_status = create_conn_struct_tos_cwd(server_messaging_context(),
+ nt_status = create_conn_struct_tos_cwd(global_messaging_context(),
printdollar_snum,
lp_path(frame, printdollar_snum),
session_info,
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index ca1eda91879..c029f1a11d5 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -258,7 +258,7 @@ static bool spoolss_child_init(struct tevent_context *ev_ctx,
{
NTSTATUS status;
struct rpc_srv_callbacks spoolss_cb;
- struct messaging_context *msg_ctx = server_messaging_context();
+ struct messaging_context *msg_ctx = global_messaging_context();
bool ok;
status = reinit_after_fork(msg_ctx, ev_ctx, true, "spoolssd-child");
diff --git a/source3/rpc_server/lsasd.c b/source3/rpc_server/lsasd.c
index 9dcf4624aea..4b9403036de 100644
--- a/source3/rpc_server/lsasd.c
+++ b/source3/rpc_server/lsasd.c
@@ -243,7 +243,7 @@ static bool lsasd_child_init(struct tevent_context *ev_ctx,
struct pf_worker_data *pf)
{
NTSTATUS status;
- struct messaging_context *msg_ctx = server_messaging_context();
+ struct messaging_context *msg_ctx = global_messaging_context();
bool ok;
status = reinit_after_fork(msg_ctx, ev_ctx,
diff --git a/source3/rpc_server/mdssd.c b/source3/rpc_server/mdssd.c
index d5c05c7e8e9..79f22cae593 100644
--- a/source3/rpc_server/mdssd.c
+++ b/source3/rpc_server/mdssd.c
@@ -200,7 +200,7 @@ static bool mdssd_child_init(struct tevent_context *ev_ctx,
struct pf_worker_data *pf)
{
NTSTATUS status;
- struct messaging_context *msg_ctx = server_messaging_context();
+ struct messaging_context *msg_ctx = global_messaging_context();
bool ok;
status = reinit_after_fork(msg_ctx, ev_ctx,
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index 7138f126be6..ac18a73ef4e 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -2345,7 +2345,7 @@ WERROR _srvsvc_NetGetFileSecurity(struct pipes_struct *p,
goto error_exit;
}
- nt_status = create_conn_struct_tos_cwd(server_messaging_context(),
+ nt_status = create_conn_struct_tos_cwd(global_messaging_context(),
snum,
lp_path(frame, snum),
p->session_info,
@@ -2478,7 +2478,7 @@ WERROR _srvsvc_NetSetFileSecurity(struct pipes_struct *p,
goto error_exit;
}
- nt_status = create_conn_struct_tos_cwd(server_messaging_context(),
+ nt_status = create_conn_struct_tos_cwd(global_messaging_context(),
snum,
lp_path(frame, snum),
p->session_info,
diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c
index ffa7ccb809b..d3f572e22a1 100644
--- a/source3/smbd/msdfs.c
+++ b/source3/smbd/msdfs.c
@@ -1210,7 +1210,7 @@ NTSTATUS get_referred_path(TALLOC_CTX *ctx,
return NT_STATUS_OK;
}
- status = create_conn_struct_tos_cwd(server_messaging_context(),
+ status = create_conn_struct_tos_cwd(global_messaging_context(),
snum,
lp_path(frame, snum),
NULL,
@@ -1424,7 +1424,7 @@ static bool junction_to_local_path_tos(const struct junction_map *jucn,
if(snum < 0) {
return False;
}
- status = create_conn_struct_tos_cwd(server_messaging_context(),
+ status = create_conn_struct_tos_cwd(global_messaging_context(),
snum,
lp_path(talloc_tos(), snum),
NULL,
@@ -1594,7 +1594,7 @@ static int count_dfs_links(TALLOC_CTX *ctx, int snum)
* Fake up a connection struct for the VFS layer.
*/
- status = create_conn_struct_tos_cwd(server_messaging_context(),
+ status = create_conn_struct_tos_cwd(global_messaging_context(),
snum,
connect_path,
NULL,
@@ -1691,7 +1691,7 @@ static int form_junctions(TALLOC_CTX *ctx,
* Fake up a connection struct for the VFS layer.
*/
- status = create_conn_struct_tos_cwd(server_messaging_context(),
+ status = create_conn_struct_tos_cwd(global_messaging_context(),
snum,
connect_path,
NULL,
diff --git a/source3/smbd/posix_acls.c b/source3/smbd/posix_acls.c
index 8cc9cf1f2fc..f1148f2af8c 100644
--- a/source3/smbd/posix_acls.c
+++ b/source3/smbd/posix_acls.c
@@ -4614,7 +4614,7 @@ NTSTATUS get_nt_acl_no_snum(TALLOC_CTX *ctx, const char *fname,
return NT_STATUS_NO_MEMORY;
}
- status = create_conn_struct_tos(server_messaging_context(),
+ status = create_conn_struct_tos(global_messaging_context(),
-1,
"/",
NULL,
diff --git a/source3/smbd/server.c b/source3/smbd/server.c
index a9201f8424c..ab7803258c8 100644
--- a/source3/smbd/server.c
+++ b/source3/smbd/server.c
@@ -1785,7 +1785,7 @@ extern void build_options(bool screen);
* Init the messaging context
* FIXME: This should only call messaging_init()
*/
- msg_ctx = server_messaging_context();
+ msg_ctx = global_messaging_context();
if (msg_ctx == NULL) {
exit(1);
}
diff --git a/source3/smbd/server_exit.c b/source3/smbd/server_exit.c
index 4bf3ea82d4d..c34c912a433 100644
--- a/source3/smbd/server_exit.c
+++ b/source3/smbd/server_exit.c
@@ -92,7 +92,7 @@ static void exit_server_common(enum server_exit_reason how,
struct smbXsrv_connection *xconn = NULL;
struct smbXsrv_connection *xconn_next = NULL;
struct smbd_server_connection *sconn = NULL;
- struct messaging_context *msg_ctx = server_messaging_context();
+ struct messaging_context *msg_ctx = global_messaging_context();
if (client != NULL) {
sconn = client->sconn;
@@ -217,7 +217,7 @@ static void exit_server_common(enum server_exit_reason how,
netlogon_creds_cli_close_global_db();
TALLOC_FREE(global_smbXsrv_client);
smbprofile_dump();
- server_messaging_context_free();
+ global_messaging_context_free();
global_event_context_free();
TALLOC_FREE(smbd_memcache_ctx);
diff --git a/source3/smbd/smbXsrv_session.c b/source3/smbd/smbXsrv_session.c
index af47f4aa8c3..db13d93b88e 100644
--- a/source3/smbd/smbXsrv_session.c
+++ b/source3/smbd/smbXsrv_session.c
@@ -89,7 +89,7 @@ NTSTATUS smbXsrv_session_global_init(struct messaging_context *msg_ctx)
return status;
}
- db_ctx = db_open_watched(NULL, &backend, server_messaging_context());
+ db_ctx = db_open_watched(NULL, &backend, global_messaging_context());
if (db_ctx == NULL) {
TALLOC_FREE(backend);
return NT_STATUS_NO_MEMORY;
diff --git a/source3/torture/test_dbwrap_ctdb.c b/source3/torture/test_dbwrap_ctdb.c
index 1da5c94a556..eddcdf11290 100644
--- a/source3/torture/test_dbwrap_ctdb.c
+++ b/source3/torture/test_dbwrap_ctdb.c
@@ -34,7 +34,7 @@ bool run_local_dbwrap_ctdb(int dummy)
uint32_t val;
struct messaging_context *msg_ctx;
- msg_ctx = server_messaging_context();
+ msg_ctx = global_messaging_context();
db = db_open_ctdb(talloc_tos(), msg_ctx, "torture.tdb",
0, TDB_DEFAULT,
diff --git a/source3/torture/test_dbwrap_do_locked.c b/source3/torture/test_dbwrap_do_locked.c
index 9245e5d357d..a5b9d4400cf 100644
--- a/source3/torture/test_dbwrap_do_locked.c
+++ b/source3/torture/test_dbwrap_do_locked.c
@@ -83,9 +83,9 @@ bool run_dbwrap_do_locked1(int dummy)
fprintf(stderr, "global_event_context() failed\n");
return false;
}
- msg = server_messaging_context();
+ msg = global_messaging_context();
if (msg == NULL) {
- fprintf(stderr, "server_messaging_context() failed\n");
+ fprintf(stderr, "global_messaging_context() failed\n");
return false;
}
diff --git a/source3/torture/test_g_lock.c b/source3/torture/test_g_lock.c
index 29046d67886..352121e4194 100644
--- a/source3/torture/test_g_lock.c
+++ b/source3/torture/test_g_lock.c
@@ -36,7 +36,7 @@ static bool get_g_lock_ctx(TALLOC_CTX *mem_ctx,
fprintf(stderr, "tevent_context_init failed\n");
return false;
}
- *msg = server_messaging_context();
+ *msg = global_messaging_context();
if (*msg == NULL) {
fprintf(stderr, "messaging_init failed\n");
TALLOC_FREE(*ev);
diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c
index e17e6fc5c34..0f80d11daae 100644
--- a/source3/torture/vfstest.c
+++ b/source3/torture/vfstest.c
@@ -536,7 +536,7 @@ int main(int argc, const char *argv[])
return 1;
}
- status = create_conn_struct_tos(server_messaging_context(),
+ status = create_conn_struct_tos(global_messaging_context(),
-1,
getcwd(cwd, sizeof(cwd)),
session_info,
diff --git a/source3/winbindd/winbindd.c b/source3/winbindd/winbindd.c
index 4781506c6f2..641c0ea96ab 100644
--- a/source3/winbindd/winbindd.c
+++ b/source3/winbindd/winbindd.c
@@ -72,9 +72,9 @@ struct imessaging_context *winbind_imessaging_context(void)
return msg;
}
- msg_ctx = server_messaging_context();
+ msg_ctx = global_messaging_context();
if (msg_ctx == NULL) {
- smb_panic("server_messaging_context failed\n");
+ smb_panic("global_messaging_context failed\n");
}
myself = messaging_server_id(msg_ctx);
@@ -1417,9 +1417,9 @@ static void winbindd_register_handlers(struct messaging_context *msg_ctx,
MSG_WINBIND_ONLINESTATUS, winbind_msg_onlinestatus);
/* Handle domain online/offline messages for domains */
- messaging_register(server_messaging_context(), NULL,
+ messaging_register(global_messaging_context(), NULL,
MSG_WINBIND_DOMAIN_OFFLINE, winbind_msg_domain_offline);
- messaging_register(server_messaging_context(), NULL,
+ messaging_register(global_messaging_context(), NULL,
MSG_WINBIND_DOMAIN_ONLINE, winbind_msg_domain_online);
messaging_register(msg_ctx, NULL,
@@ -1745,7 +1745,7 @@ int main(int argc, const char **argv)
/* Initialise messaging system */
- if (server_messaging_context() == NULL) {
+ if (global_messaging_context() == NULL) {
exit(1);
}
@@ -1839,7 +1839,7 @@ int main(int argc, const char **argv)
* winbindd-specific resources we must free yet. JRA.
*/
- status = reinit_after_fork(server_messaging_context(),
+ status = reinit_after_fork(global_messaging_context(),
global_event_context(),
false, NULL);
if (!NT_STATUS_IS_OK(status)) {
@@ -1857,9 +1857,9 @@ int main(int argc, const char **argv)
exit_daemon(nt_errstr(status), map_errno_from_nt_status(status));
}
- winbindd_register_handlers(server_messaging_context(), !Fork);
+ winbindd_register_handlers(global_messaging_context(), !Fork);
- if (!messaging_parent_dgm_cleanup_init(server_messaging_context())) {
+ if (!messaging_parent_dgm_cleanup_init(global_messaging_context())) {
exit(1);
}
@@ -1872,7 +1872,7 @@ int main(int argc, const char **argv)
rpc_samr_init(NULL);
winbindd_init_addrchange(NULL, global_event_context(),
- server_messaging_context());
+ global_messaging_context());
/* setup listen sockets */
diff --git a/source3/winbindd/winbindd_cm.c b/source3/winbindd/winbindd_cm.c
index 88ef36600d5..21cf40bf5cd 100644
--- a/source3/winbindd/winbindd_cm.c
+++ b/source3/winbindd/winbindd_cm.c
@@ -225,10 +225,10 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
if (domain->dc_probe_pid != (pid_t)0) {
/* Parent */
- messaging_register(server_messaging_context(), NULL,
+ messaging_register(global_messaging_context(), NULL,
MSG_WINBIND_TRY_TO_GO_ONLINE,
msg_try_to_go_online);
- messaging_register(server_messaging_context(), NULL,
+ messaging_register(global_messaging_context(), NULL,
MSG_WINBIND_FAILED_TO_GO_ONLINE,
msg_failed_to_go_online);
return True;
@@ -249,7 +249,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
if (!NT_STATUS_IS_OK(status)) {
DEBUG(1, ("winbindd_reinit_after_fork failed: %s\n",
nt_errstr(status)));
- messaging_send_buf(server_messaging_context(),
+ messaging_send_buf(global_messaging_context(),
pid_to_procid(parent_pid),
MSG_WINBIND_FAILED_TO_GO_ONLINE,
(const uint8_t *)domain->name,
@@ -263,7 +263,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
mem_ctx = talloc_init("fork_child_dc_connect");
if (!mem_ctx) {
DEBUG(0,("talloc_init failed.\n"));
- messaging_send_buf(server_messaging_context(),
+ messaging_send_buf(global_messaging_context(),
pid_to_procid(parent_pid),
MSG_WINBIND_FAILED_TO_GO_ONLINE,
(const uint8_t *)domain->name,
@@ -275,7 +275,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
TALLOC_FREE(mem_ctx);
if (!ok || (num_dcs == 0)) {
/* Still offline ? Can't find DC's. */
- messaging_send_buf(server_messaging_context(),
+ messaging_send_buf(global_messaging_context(),
pid_to_procid(parent_pid),
MSG_WINBIND_FAILED_TO_GO_ONLINE,
(const uint8_t *)domain->name,
@@ -286,7 +286,7 @@ static bool fork_child_dc_connect(struct winbindd_domain *domain)
/* We got a DC. Send a message to our parent to get it to
try and do the same. */
- messaging_send_buf(server_messaging_context(),
+ messaging_send_buf(global_messaging_context(),
pid_to_procid(parent_pid),
MSG_WINBIND_TRY_TO_GO_ONLINE,
(const uint8_t *)domain->name,
@@ -450,7 +450,7 @@ void set_domain_offline(struct winbindd_domain *domain)
/* Send a message to the parent that the domain is offline. */
if (parent_pid > 1 && !domain->internal) {
- messaging_send_buf(server_messaging_context(),
+ messaging_send_buf(global_messaging_context(),
pid_to_procid(parent_pid),
MSG_WINBIND_DOMAIN_OFFLINE,
(uint8_t *)domain->name,
@@ -464,7 +464,7 @@ void set_domain_offline(struct winbindd_domain *domain)
struct winbindd_child *idmap = idmap_child();
if ( idmap->pid != 0 ) {
- messaging_send_buf(server_messaging_context(),
+ messaging_send_buf(global_messaging_context(),
pid_to_procid(idmap->pid),
MSG_WINBIND_OFFLINE,
(const uint8_t *)domain->name,
@@ -527,16 +527,16 @@ static void set_domain_online(struct winbindd_domain *domain)
TALLOC_FREE(domain->check_online_event);
/* Ensure we ignore any pending child messages. */
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_WINBIND_TRY_TO_GO_ONLINE, NULL);
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_WINBIND_FAILED_TO_GO_ONLINE, NULL);
domain->online = True;
/* Send a message to the parent that the domain is online. */
if (parent_pid > 1 && !domain->internal) {
- messaging_send_buf(server_messaging_context(),
+ messaging_send_buf(global_messaging_context(),
pid_to_procid(parent_pid),
MSG_WINBIND_DOMAIN_ONLINE,
(uint8_t *)domain->name,
@@ -550,7 +550,7 @@ static void set_domain_online(struct winbindd_domain *domain)
struct winbindd_child *idmap = idmap_child();
if ( idmap->pid != 0 ) {
- messaging_send_buf(server_messaging_context(),
+ messaging_send_buf(global_messaging_context(),
pid_to_procid(idmap->pid),
MSG_WINBIND_ONLINE,
(const uint8_t *)domain->name,
@@ -1475,7 +1475,7 @@ static bool dcip_check_name(TALLOC_CTX *mem_ctx,
"%s$",
lp_netbios_name());
- status = nbt_getdc(server_messaging_context(), 10, pss,
+ status = nbt_getdc(global_messaging_context(), 10, pss,
domain->name, &domain->sid,
my_acct_name, ACB_WSTRUST,
nt_version, mem_ctx, &nt_version,
@@ -1849,7 +1849,7 @@ NTSTATUS wb_open_internal_pipe(TALLOC_CTX *mem_ctx,
session_info,
NULL,
NULL,
- server_messaging_context(),
+ global_messaging_context(),
&cli);
} else {
status = rpc_pipe_open_internal(mem_ctx,
@@ -1857,7 +1857,7 @@ NTSTATUS wb_open_internal_pipe(TALLOC_CTX *mem_ctx,
session_info,
NULL,
NULL,
- server_messaging_context(),
+ global_messaging_context(),
&cli);
}
if (!NT_STATUS_IS_OK(status)) {
@@ -3293,7 +3293,7 @@ static NTSTATUS cm_connect_netlogon_transport(struct winbindd_domain *domain,
enum dcerpc_transport_t transport,
struct rpc_pipe_client **cli)
{
- struct messaging_context *msg_ctx = server_messaging_context();
+ struct messaging_context *msg_ctx = global_messaging_context();
struct winbindd_cm_conn *conn;
NTSTATUS result;
enum netr_SchannelType sec_chan_type;
diff --git a/source3/winbindd/winbindd_dual.c b/source3/winbindd/winbindd_dual.c
index e641b52fe13..6e3277e5529 100644
--- a/source3/winbindd/winbindd_dual.c
+++ b/source3/winbindd/winbindd_dual.c
@@ -1271,7 +1271,7 @@ static void machine_password_change_handler(struct tevent_context *ctx,
struct timeval now,
void *private_data)
{
- struct messaging_context *msg_ctx = server_messaging_context();
+ struct messaging_context *msg_ctx = global_messaging_context();
struct winbindd_child *child =
(struct winbindd_child *)private_data;
struct rpc_pipe_client *netlogon_pipe = NULL;
@@ -1497,7 +1497,7 @@ NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself,
NTSTATUS status;
status = reinit_after_fork(
- server_messaging_context(),
+ global_messaging_context(),
global_event_context(),
true, NULL);
if (!NT_STATUS_IS_OK(status)) {
@@ -1523,24 +1523,24 @@ NTSTATUS winbindd_reinit_after_fork(const struct winbindd_child *myself,
CatchChild();
/* Don't handle the same messages as our parent. */
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_SMB_CONF_UPDATED, NULL);
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_SHUTDOWN, NULL);
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_WINBIND_OFFLINE, NULL);
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_WINBIND_ONLINE, NULL);
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_WINBIND_ONLINESTATUS, NULL);
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_WINBIND_DUMP_DOMAIN_LIST, NULL);
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_DEBUG, NULL);
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_WINBIND_DOMAIN_OFFLINE, NULL);
- messaging_deregister(server_messaging_context(),
+ messaging_deregister(global_messaging_context(),
MSG_WINBIND_DOMAIN_ONLINE, NULL);
/* We have destroyed all events in the winbindd_event_context
@@ -1718,16 +1718,16 @@ static bool fork_domain_child(struct winbindd_child *child)
}
/* Handle online/offline messages. */
- messaging_register(server_messaging_context(), NULL,
+ messaging_register(global_messaging_context(), NULL,
MSG_WINBIND_OFFLINE, child_msg_offline);
- messaging_register(server_messaging_context(), NULL,
+ messaging_register(global_messaging_context(), NULL,
MSG_WINBIND_ONLINE, child_msg_online);
- messaging_register(server_messaging_context(), NULL,
+ messaging_register(global_messaging_context(), NULL,
MSG_DEBUG, debug_message);
- messaging_register(server_messaging_context(), NULL,
+ messaging_register(global_messaging_context(), NULL,
MSG_WINBIND_IP_DROPPED,
winbind_msg_ip_dropped);
- messaging_register(server_messaging_context(), NULL,
+ messaging_register(global_messaging_context(), NULL,
MSG_WINBIND_DISCONNECT_DC,
winbind_msg_disconnect_dc);
diff --git a/source3/winbindd/winbindd_dual_srv.c b/source3/winbindd/winbindd_dual_srv.c
index 8cb05f06db6..e912cba7a41 100644
--- a/source3/winbindd/winbindd_dual_srv.c
+++ b/source3/winbindd/winbindd_dual_srv.c
@@ -552,7 +552,7 @@ NTSTATUS _wbint_DsGetDcName(struct pipes_struct *p, struct wbint_DsGetDcName *r)
bool try_dsrgetdcname = false;
if (domain == NULL) {
- return dsgetdcname(p->mem_ctx, server_messaging_context(),
+ return dsgetdcname(p->mem_ctx, global_messaging_context(),
r->in.domain_name, r->in.domain_guid,
r->in.site_name ? r->in.site_name : "",
r->in.flags,
@@ -746,7 +746,7 @@ again:
NTSTATUS _wbint_ChangeMachineAccount(struct pipes_struct *p,
struct wbint_ChangeMachineAccount *r)
{
- struct messaging_context *msg_ctx = server_messaging_context();
+ struct messaging_context *msg_ctx = global_messaging_context();
struct winbindd_domain *domain;
NTSTATUS status;
struct rpc_pipe_client *netlogon_pipe = NULL;
@@ -1501,7 +1501,7 @@ static WERROR _winbind_LogonControl_CHANGE_PASSWORD(struct pipes_struct *p,
struct winbindd_domain *domain,
struct winbind_LogonControl *r)
{
- struct messaging_context *msg_ctx = server_messaging_context();
+ struct messaging_context *msg_ctx = global_messaging_context();
NTSTATUS status;
struct rpc_pipe_client *netlogon_pipe = NULL;
struct netlogon_creds_cli_context *netlogon_creds_ctx = NULL;
--
2.17.0
From 997d28093686aced4f662fb883d5083f730cdcd5 Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 21 Aug 2018 11:18:08 -0700
Subject: [PATCH 24/25] s3:lib/server_contexts: Rename variables
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/lib/server_contexts.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)
diff --git a/source3/lib/server_contexts.c b/source3/lib/server_contexts.c
index 2d92ad9f69c..03ab8e4fd48 100644
--- a/source3/lib/server_contexts.c
+++ b/source3/lib/server_contexts.c
@@ -1,6 +1,6 @@
/*
Unix SMB/CIFS implementation.
- Common server globals
+ Global contexts
Copyright (C) Simo Sorce <idra at samba.org> 2010
@@ -21,46 +21,46 @@
#include "includes.h"
#include "messages.h"
-static struct tevent_context *server_event_ctx = NULL;
+static struct tevent_context *global_event_ctx = NULL;
struct tevent_context *global_event_context(void)
{
- if (!server_event_ctx) {
+ if (!global_event_ctx) {
/*
* Note we MUST use the NULL context here, not the
* autofree context, to avoid side effects in forked
* children exiting.
*/
- server_event_ctx = samba_tevent_context_init(NULL);
+ global_event_ctx = samba_tevent_context_init(NULL);
}
- if (!server_event_ctx) {
- smb_panic("Could not init server's event context");
+ if (!global_event_ctx) {
+ smb_panic("Could not init global event context");
}
- return server_event_ctx;
+ return global_event_ctx;
}
void global_event_context_free(void)
{
- TALLOC_FREE(server_event_ctx);
+ TALLOC_FREE(global_event_ctx);
}
-static struct messaging_context *server_msg_ctx = NULL;
+static struct messaging_context *global_msg_ctx = NULL;
struct messaging_context *global_messaging_context(void)
{
- if (server_msg_ctx == NULL) {
+ if (global_msg_ctx == NULL) {
/*
* Note we MUST use the NULL context here, not the
* autofree context, to avoid side effects in forked
* children exiting.
*/
- server_msg_ctx = messaging_init(NULL,
+ global_msg_ctx = messaging_init(NULL,
global_event_context());
}
- return server_msg_ctx;
+ return global_msg_ctx;
}
void global_messaging_context_free(void)
{
- TALLOC_FREE(server_msg_ctx);
+ TALLOC_FREE(global_msg_ctx);
}
--
2.17.0
From 2292ad281141bcca80ffec61c3dee2608477ed2d Mon Sep 17 00:00:00 2001
From: Christof Schmitt <cs at samba.org>
Date: Tue, 21 Aug 2018 13:08:42 -0700
Subject: [PATCH 25/25] s3:lib: Rename server_contexts to global_contexts
Signed-off-by: Christof Schmitt <cs at samba.org>
---
source3/lib/{server_contexts.c => global_contexts.c} | 0
source3/wscript_build | 2 +-
2 files changed, 1 insertion(+), 1 deletion(-)
rename source3/lib/{server_contexts.c => global_contexts.c} (100%)
diff --git a/source3/lib/server_contexts.c b/source3/lib/global_contexts.c
similarity index 100%
rename from source3/lib/server_contexts.c
rename to source3/lib/global_contexts.c
diff --git a/source3/wscript_build b/source3/wscript_build
index 7051c0c329e..dad7702f4f9 100644
--- a/source3/wscript_build
+++ b/source3/wscript_build
@@ -401,7 +401,7 @@ bld.SAMBA3_SUBSYSTEM('samba3core',
intl/lang_tdb.c
lib/gencache.c
lib/util_event.c
- lib/server_contexts.c
+ lib/global_contexts.c
lib/server_prefork.c
lib/server_prefork_util.c
lib/ldap_escape.c
--
2.17.0
More information about the samba-technical
mailing list