[PATCHES] some loadparm cleanups
Michael Adam
obnox at samba.org
Tue Apr 21 07:51:04 MDT 2015
Hi,
I just stumbled across a side project I started around
SDC last year. This is about cleaning up some aspects
of loadparm a bit.
This first patchset is mainly cleaning up the mess that
our callers of lp_load() have been (imho), consistently
using wrappers with less or no of these infamous boolean
options.
Review / push / comments appreciated.
Thanks - Michael
-------------- next part --------------
From bcad59ac2c3c739b5c9fb4e2fed276326a157086 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 16:41:22 +0200
Subject: [PATCH 01/26] s3:spoolss: use lp_load() wrapper lp_load_global().
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/printing/spoolssd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/printing/spoolssd.c b/source3/printing/spoolssd.c
index b850578..11bd82f 100644
--- a/source3/printing/spoolssd.c
+++ b/source3/printing/spoolssd.c
@@ -107,7 +107,7 @@ static void update_conf(struct tevent_context *ev,
struct messaging_context *msg)
{
change_to_root_user();
- lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
+ lp_load_global(get_dyn_CONFIGFILE());
load_printers(ev, msg);
spoolss_reopen_logs(spoolss_child_id);
--
2.1.0
From eaada4e2aa78cce628a75afc65e70f3c7d62cab0 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 16:43:05 +0200
Subject: [PATCH 02/26] s3:lsasd: use lp_load() wrapper lp_load_global()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/rpc_server/lsasd.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/source3/rpc_server/lsasd.c b/source3/rpc_server/lsasd.c
index 375f409..42d91fd 100644
--- a/source3/rpc_server/lsasd.c
+++ b/source3/rpc_server/lsasd.c
@@ -116,7 +116,7 @@ static void lsasd_smb_conf_updated(struct messaging_context *msg,
ev_ctx = talloc_get_type_abort(private_data, struct tevent_context);
change_to_root_user();
- lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
+ lp_load_global(get_dyn_CONFIGFILE());
lsasd_reopen_logs(lsasd_child_id);
if (lsasd_child_id == 0) {
@@ -166,7 +166,7 @@ static void lsasd_sig_hup_handler(struct tevent_context *ev,
{
change_to_root_user();
- lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
+ lp_load_global(get_dyn_CONFIGFILE());
lsasd_reopen_logs(lsasd_child_id);
pfh_daemon_config(DAEMON_NAME,
--
2.1.0
From ba430a33eaec0eda7b406cbf14fe9444ed081362 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 16:47:40 +0200
Subject: [PATCH 03/26] s3:param: let lp_load_global() call lp_load(), not
lp_load_ex().
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/param/loadparm.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index a6b3b45..6059f03 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3830,13 +3830,11 @@ bool lp_load_initial_only(const char *pszFname)
*/
bool lp_load_global(const char *file_name)
{
- return lp_load_ex(file_name,
- true, /* global_only */
- false, /* save_defaults */
- false, /* add_ipc */
- true, /* initialize_globals */
- true, /* allow_include_registry */
- false); /* load_all_shares*/
+ return lp_load(file_name,
+ true, /* global_only */
+ false, /* save_defaults */
+ false, /* add_ipc */
+ true); /* initialize_globals */
}
/**
--
2.1.0
From 5ef4cfadcae35dd874f8e3bb7fa760d913ed91c0 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 16:50:48 +0200
Subject: [PATCH 04/26] s3:param: add wrapper lp_load_with_shares().
Most common pattern with shares, including IPC,
but not forcing immediate loading of all registry shares.
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/include/proto.h | 1 +
source3/param/loadparm.c | 14 ++++++++++++++
2 files changed, 15 insertions(+)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index c66283b..89e6429 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1063,6 +1063,7 @@ bool lp_load(const char *pszFname,
bool initialize_globals);
bool lp_load_initial_only(const char *pszFname);
bool lp_load_global(const char *file_name);
+bool lp_load_with_shares(const char *file_name);
bool lp_load_client(const char *file_name);
bool lp_load_global_no_reinit(const char *file_name);
bool lp_load_client_no_reinit(const char *file_name);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 6059f03..2b0bfee 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3838,6 +3838,20 @@ bool lp_load_global(const char *file_name)
}
/**
+ * The typical lp_load wrapper with shares, loads global and
+ * shares, including IPC, but does not force immediate
+ * loading of all shares from registry.
+ */
+bool lp_load_with_shares(const char *file_name)
+{
+ return lp_load(file_name,
+ false, /* global_only */
+ false, /* save_defaults */
+ true, /* add_ipc */
+ true); /* initialize_globals */
+}
+
+/**
* lp_load wrapper, especially for clients
*/
bool lp_load_client(const char *file_name)
--
2.1.0
From b3de18b38888ce2fabaafe07cb9c2ba439e5d077 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 16:52:06 +0200
Subject: [PATCH 05/26] s3:param: let lp_load_global_no_reinit() call lp_load()
instead of lp_load_ex()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/param/loadparm.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 2b0bfee..4117872 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3868,13 +3868,11 @@ bool lp_load_client(const char *file_name)
*/
bool lp_load_global_no_reinit(const char *file_name)
{
- return lp_load_ex(file_name,
- true, /* global_only */
- false, /* save_defaults */
- false, /* add_ipc */
- false, /* initialize_globals */
- true, /* allow_include_registry */
- false); /* load_all_shares*/
+ return lp_load(file_name,
+ true, /* global_only */
+ false, /* save_defaults */
+ false, /* add_ipc */
+ false); /* initialize_globals */
}
/**
--
2.1.0
From 3be5befdf125ee8a9d1143720f3f65b332858bc2 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 16:53:59 +0200
Subject: [PATCH 06/26] s3:smbd: use lp_load_with_shares() in
reload_services().
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/smbd/server_reload.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c
index e1b62d1..c93c077 100644
--- a/source3/smbd/server_reload.c
+++ b/source3/smbd/server_reload.c
@@ -143,11 +143,7 @@ bool reload_services(struct smbd_server_connection *sconn,
lp_killunused(sconn, snumused);
- ret = lp_load(get_dyn_CONFIGFILE(),
- false, /* global only */
- false, /* save defaults */
- true, /* add_ipc */
- true); /* initialize globals */
+ ret = lp_load_with_shares(get_dyn_CONFIGFILE());
/* perhaps the config filename is now set */
if (!test) {
--
2.1.0
From 0aa4cd3089c8fd6537f8e350e4ced56f793e1632 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 16:57:06 +0200
Subject: [PATCH 07/26] nsswitch/wins: use lp_load_global() wrapper of
lp_load().
Signed-off-by: Michael Adam <obnox at samba.org>
---
nsswitch/wins.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/nsswitch/wins.c b/nsswitch/wins.c
index a0790cf..735a9a2 100644
--- a/nsswitch/wins.c
+++ b/nsswitch/wins.c
@@ -52,7 +52,7 @@ static void nss_wins_init(void)
TimeInit();
setup_logging("nss_wins",False);
- lp_load(get_dyn_CONFIGFILE(),True,False,False,True);
+ lp_load_global(get_dyn_CONFIGFILE());
load_interfaces();
}
--
2.1.0
From 1d4da83c6d913c07e5093c176de6af25d91ce729 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 16:59:50 +0200
Subject: [PATCH 08/26] s3:auth: use lp_load_with_shares() in
auth3_generate_session_info_pac()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/auth/auth_generic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/auth/auth_generic.c b/source3/auth/auth_generic.c
index 1da4961..584b52f 100644
--- a/source3/auth/auth_generic.c
+++ b/source3/auth/auth_generic.c
@@ -116,7 +116,7 @@ static NTSTATUS auth3_generate_session_info_pac(struct auth4_context *auth_ctx,
sub_set_smb_name(username);
/* reload services so that the new %U is taken into account */
- lp_load(get_dyn_CONFIGFILE(), false, false, true, true);
+ lp_load_with_shares(get_dyn_CONFIGFILE());
status = make_session_info_krb5(mem_ctx,
ntuser, ntdomain, username, pw,
--
2.1.0
From 625f7f248df0c145df3b1699918e503bd4091bd0 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 17:00:36 +0200
Subject: [PATCH 09/26] s3:auth: use lp_load_with_shares() in
auth3_check_password()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/auth/auth_ntlmssp.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/auth/auth_ntlmssp.c b/source3/auth/auth_ntlmssp.c
index 14bce62..ef83451 100644
--- a/source3/auth/auth_ntlmssp.c
+++ b/source3/auth/auth_ntlmssp.c
@@ -155,7 +155,7 @@ NTSTATUS auth3_check_password(struct auth4_context *auth4_context,
/* sub_set_smb_name checks for weird internally */
sub_set_smb_name(user_info->client.account_name);
- lp_load(get_dyn_CONFIGFILE(), false, false, true, true);
+ lp_load_with_shares(get_dyn_CONFIGFILE());
nt_status = make_user_info_map(talloc_tos(),
&mapped_user_info,
--
2.1.0
From eb5bd281a45c25813065910ec26dfa68fbe3599b Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 17:30:22 +0200
Subject: [PATCH 10/26] s3:param: remove "global_only" parameter from
lp_load_with_registry_shares().
There is no point in choosing global_only when forcing to load
all shares from registry at the same time...
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/include/proto.h | 1 -
source3/param/loadparm.c | 3 +--
source3/param/test_lp_load.c | 1 -
source3/utils/sharesec.c | 3 +--
source3/utils/testparm.c | 2 +-
5 files changed, 3 insertions(+), 7 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 89e6429..8a1fc87 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1068,7 +1068,6 @@ bool lp_load_client(const char *file_name);
bool lp_load_global_no_reinit(const char *file_name);
bool lp_load_client_no_reinit(const char *file_name);
bool lp_load_with_registry_shares(const char *pszFname,
- bool global_only,
bool save_defaults,
bool add_ipc,
bool initialize_globals);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 4117872..aa5f90f 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3886,13 +3886,12 @@ bool lp_load_client_no_reinit(const char *file_name)
}
bool lp_load_with_registry_shares(const char *pszFname,
- bool global_only,
bool save_defaults,
bool add_ipc,
bool initialize_globals)
{
return lp_load_ex(pszFname,
- global_only,
+ false, /* global_only */
save_defaults,
add_ipc,
initialize_globals,
diff --git a/source3/param/test_lp_load.c b/source3/param/test_lp_load.c
index 45427ce..bd5c2b9 100644
--- a/source3/param/test_lp_load.c
+++ b/source3/param/test_lp_load.c
@@ -62,7 +62,6 @@ int main(int argc, const char **argv)
for (i=0; i < count; i++) {
printf("call lp_load() #%d: ", i+1);
if (!lp_load_with_registry_shares(config_file,
- False, /* global only */
True, /* save defaults */
False, /*add_ipc */
True)) /*init globals */
diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c
index ff5400e..4c6e205 100644
--- a/source3/utils/sharesec.c
+++ b/source3/utils/sharesec.c
@@ -599,8 +599,7 @@ int main(int argc, const char *argv[])
setlinebuf(stdout);
- lp_load_with_registry_shares( get_dyn_CONFIGFILE(), False, False, False,
- True );
+ lp_load_with_registry_shares(get_dyn_CONFIGFILE(), False, False, True);
/* check for initializing secrets.tdb first */
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index 9499f86..cec7dd4 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -491,7 +491,7 @@ static void do_per_share_checks(int s)
fprintf(stderr,"Load smb config files from %s\n",config_file);
- if (!lp_load_with_registry_shares(config_file,False,True,False,True)) {
+ if (!lp_load_with_registry_shares(config_file, True, False, True)) {
fprintf(stderr,"Error loading services.\n");
ret = 1;
goto done;
--
2.1.0
From cba912dd0f6a652c6f9ce0f5e6397c6a935cabbb Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 30 Jul 2014 17:47:32 +0200
Subject: [PATCH 11/26] s3:param: remove "add_ipc" parameter from
lp_load_with_registry_shares().
This is not called from the server (which loads registry shares lazily),
so add_ipc is always false...
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/include/proto.h | 1 -
source3/param/loadparm.c | 3 +--
source3/param/test_lp_load.c | 1 -
source3/utils/sharesec.c | 2 +-
source3/utils/testparm.c | 2 +-
5 files changed, 3 insertions(+), 6 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 8a1fc87..ea5fb04 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1069,7 +1069,6 @@ bool lp_load_global_no_reinit(const char *file_name);
bool lp_load_client_no_reinit(const char *file_name);
bool lp_load_with_registry_shares(const char *pszFname,
bool save_defaults,
- bool add_ipc,
bool initialize_globals);
int lp_numservices(void);
void lp_dump(FILE *f, bool show_defaults, int maxtoprint);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index aa5f90f..672155b 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3887,13 +3887,12 @@ bool lp_load_client_no_reinit(const char *file_name)
bool lp_load_with_registry_shares(const char *pszFname,
bool save_defaults,
- bool add_ipc,
bool initialize_globals)
{
return lp_load_ex(pszFname,
false, /* global_only */
save_defaults,
- add_ipc,
+ false, /* add_ipc */
initialize_globals,
true, /* allow_include_registry */
true); /* load_all_shares*/
diff --git a/source3/param/test_lp_load.c b/source3/param/test_lp_load.c
index bd5c2b9..bd373b9 100644
--- a/source3/param/test_lp_load.c
+++ b/source3/param/test_lp_load.c
@@ -63,7 +63,6 @@ int main(int argc, const char **argv)
printf("call lp_load() #%d: ", i+1);
if (!lp_load_with_registry_shares(config_file,
True, /* save defaults */
- False, /*add_ipc */
True)) /*init globals */
{
printf("ERROR.\n");
diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c
index 4c6e205..914cc4f 100644
--- a/source3/utils/sharesec.c
+++ b/source3/utils/sharesec.c
@@ -599,7 +599,7 @@ int main(int argc, const char *argv[])
setlinebuf(stdout);
- lp_load_with_registry_shares(get_dyn_CONFIGFILE(), False, False, True);
+ lp_load_with_registry_shares(get_dyn_CONFIGFILE(), False, True);
/* check for initializing secrets.tdb first */
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index cec7dd4..3cef0d6 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -491,7 +491,7 @@ static void do_per_share_checks(int s)
fprintf(stderr,"Load smb config files from %s\n",config_file);
- if (!lp_load_with_registry_shares(config_file, True, False, True)) {
+ if (!lp_load_with_registry_shares(config_file, True, True)) {
fprintf(stderr,"Error loading services.\n");
ret = 1;
goto done;
--
2.1.0
From 2b402aaa5a14f464f92db51572a88860195ac377 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 31 Jul 2014 00:42:01 +0200
Subject: [PATCH 12/26] s4:torture:libnetapi: use lp_load_global() instead of
lp_load()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source4/torture/libnetapi/libnetapi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source4/torture/libnetapi/libnetapi.c b/source4/torture/libnetapi/libnetapi.c
index 431b531..2a443ec 100644
--- a/source4/torture/libnetapi/libnetapi.c
+++ b/source4/torture/libnetapi/libnetapi.c
@@ -33,7 +33,7 @@ bool torture_libnetapi_init_context(struct torture_context *tctx,
struct libnetapi_ctx *ctx;
TALLOC_CTX *frame = talloc_stackframe();
- if (!lp_load(lpcfg_configfile(tctx->lp_ctx), true, false, false, true)) {
+ if (!lp_load_global(lpcfg_configfile(tctx->lp_ctx))) {
fprintf(stderr, "error loading %s\n", lpcfg_configfile(tctx->lp_ctx));
talloc_free(frame);
return W_ERROR_V(WERR_GENERAL_FAILURE);
--
2.1.0
From 83d38f60d9eb9c333a763bb1f16907e16895cc91 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 9 Sep 2014 23:22:50 +0200
Subject: [PATCH 13/26] s3:torture:msg: use lp_load()-wrapper lp_load_global()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/torture/msg_source.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/torture/msg_source.c b/source3/torture/msg_source.c
index e1974c21..293b099 100644
--- a/source3/torture/msg_source.c
+++ b/source3/torture/msg_source.c
@@ -117,7 +117,7 @@ int main(int argc, const char *argv[])
return -1;
}
- lp_load(get_dyn_CONFIGFILE(), true, false, false, true);
+ lp_load_global(get_dyn_CONFIGFILE());
ev = tevent_context_init(frame);
if (ev == NULL) {
--
2.1.0
From 6bdaf0c30f702f61604a017cc7e221c7b3c26b3a Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 18 Sep 2014 00:28:50 +0200
Subject: [PATCH 14/26] s3:param: add lp_load_no_reinit()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/include/proto.h | 1 +
source3/param/loadparm.c | 15 +++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index ea5fb04..0320f09 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1066,6 +1066,7 @@ bool lp_load_global(const char *file_name);
bool lp_load_with_shares(const char *file_name);
bool lp_load_client(const char *file_name);
bool lp_load_global_no_reinit(const char *file_name);
+bool lp_load_no_reinit(const char *file_name);
bool lp_load_client_no_reinit(const char *file_name);
bool lp_load_with_registry_shares(const char *pszFname,
bool save_defaults,
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 672155b..b9542d8 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3876,6 +3876,21 @@ bool lp_load_global_no_reinit(const char *file_name)
}
/**
+ * lp_load wrapper, loading globals and shares,
+ * intended for subsequent calls, i.e. not reinitializing
+ * the globals to default values.
+ */
+bool lp_load_no_reinit(const char *file_name)
+{
+ return lp_load(file_name,
+ false, /* global_only */
+ false, /* save_defaults */
+ false, /* add_ipc */
+ false); /* reinit_globals */
+}
+
+
+/**
* lp_load wrapper, especially for clients, no reinitialization
*/
bool lp_load_client_no_reinit(const char *file_name)
--
2.1.0
From 2bc1366da5daf11abe1e5355f6b222c713f1259e Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 18 Sep 2014 00:29:28 +0200
Subject: [PATCH 15/26] s3:param: use lp_load_no_reinit() in
lp_load_for_s4_ctx()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/param/loadparm_ctx.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/param/loadparm_ctx.c b/source3/param/loadparm_ctx.c
index fdad041..645b787 100644
--- a/source3/param/loadparm_ctx.c
+++ b/source3/param/loadparm_ctx.c
@@ -50,7 +50,7 @@ static bool lp_load_for_s4_ctx(const char *filename)
bool status;
mem_ctx = talloc_stackframe();
- status = lp_load(filename, false, false, false, false);
+ status = lp_load_no_reinit(filename);
talloc_free(mem_ctx);
return status;
--
2.1.0
From f52f612fa23b84eecc283d256d444a320afde2cf Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 18 Sep 2014 04:16:56 +0200
Subject: [PATCH 16/26] vfstest: use lp_load_with_shares() in cmd_conf
Note this calls lp_load slightly differently.
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/torture/vfstest.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/torture/vfstest.c b/source3/torture/vfstest.c
index 2cca2a4..b6ef2f2 100644
--- a/source3/torture/vfstest.c
+++ b/source3/torture/vfstest.c
@@ -127,7 +127,7 @@ static NTSTATUS cmd_conf(struct vfs_state *vfs, TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
- if (!lp_load(argv[1], False, True, False, True)) {
+ if (!lp_load_with_shares(argv[1])) {
printf("Error loading \"%s\"\n", argv[1]);
return NT_STATUS_OK;
}
--
2.1.0
From 504364ee63c1d3f4d4f6c68417ee0942c8b61420 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Thu, 18 Sep 2014 04:19:10 +0200
Subject: [PATCH 17/26] s3:param: make lp_load() static
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/include/proto.h | 5 -----
source3/param/loadparm.c | 10 +++++-----
2 files changed, 5 insertions(+), 10 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index 0320f09..e66ce5f 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1056,11 +1056,6 @@ int load_usershare_service(const char *servicename);
int load_usershare_shares(struct smbd_server_connection *sconn,
bool (*snumused) (struct smbd_server_connection *, int));
void gfree_loadparm(void);
-bool lp_load(const char *pszFname,
- bool global_only,
- bool save_defaults,
- bool add_ipc,
- bool initialize_globals);
bool lp_load_initial_only(const char *pszFname);
bool lp_load_global(const char *file_name);
bool lp_load_with_shares(const char *file_name);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index b9542d8..75a0d42 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3799,11 +3799,11 @@ static bool lp_load_ex(const char *pszFname,
return (bRetval);
}
-bool lp_load(const char *pszFname,
- bool global_only,
- bool save_defaults,
- bool add_ipc,
- bool initialize_globals)
+static bool lp_load(const char *pszFname,
+ bool global_only,
+ bool save_defaults,
+ bool add_ipc,
+ bool initialize_globals)
{
return lp_load_ex(pszFname,
global_only,
--
2.1.0
From eae5ff66138e5cc8b15156e88698558452ee7073 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 6 Aug 2014 16:20:42 +0200
Subject: [PATCH 18/26] s3:param: in lp_load_initial_only(), make sure to save
defaults.
This is the initial loading of the config in the daemons (and some tools).
So we should save the defaults here. This should especially take into account
some dynamic defaults like log file and maybe some changed values
handed in via the command line.
Signed-off-by: Michael Adam <obnox 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 75a0d42..c73dcfe 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3818,7 +3818,7 @@ bool lp_load_initial_only(const char *pszFname)
{
return lp_load_ex(pszFname,
true, /* global only */
- false, /* save_defaults */
+ true, /* save_defaults */
false, /* add_ipc */
true, /* initialize_globals */
false, /* allow_include_registry */
--
2.1.0
From dbdfcec6567841c42424257a36a7ee7875b7f3a0 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Sat, 20 Sep 2014 04:42:40 +0200
Subject: [PATCH 19/26] s3:param: factor lp_enforce_ad_dc_settings() out of
lp_load_ex()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/param/loadparm.c | 29 ++++++++++++++++-------------
1 file changed, 16 insertions(+), 13 deletions(-)
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index c73dcfe..53078e9 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3627,6 +3627,21 @@ static bool lp_is_in_client(void)
return in_client;
}
+static void lp_enforce_ad_dc_settings(void)
+{
+ lp_do_parameter(-1, "passdb backend", "samba_dsdb");
+ lp_do_parameter(-1, "winbindd:use external pipes", "true");
+ lp_do_parameter(-1, "rpc_server:default", "external");
+ lp_do_parameter(-1, "rpc_server:svcctl", "embedded");
+ lp_do_parameter(-1, "rpc_server:srvsvc", "embedded");
+ lp_do_parameter(-1, "rpc_server:eventlog", "embedded");
+ lp_do_parameter(-1, "rpc_server:ntsvcs", "embedded");
+ lp_do_parameter(-1, "rpc_server:winreg", "embedded");
+ lp_do_parameter(-1, "rpc_server:spoolss", "embedded");
+ lp_do_parameter(-1, "rpc_daemon:spoolssd", "embedded");
+ lp_do_parameter(-1, "rpc_server:tcpip", "no");
+}
+
/***************************************************************************
Load the services array from the services file. Return true on success,
false on failure.
@@ -3778,19 +3793,7 @@ static bool lp_load_ex(const char *pszFname,
* is why we force these settings.
*/
if (lp_server_role() == ROLE_ACTIVE_DIRECTORY_DC) {
- lp_do_parameter(-1, "passdb backend", "samba_dsdb");
-
- lp_do_parameter(-1, "winbindd:use external pipes", "true");
-
- lp_do_parameter(-1, "rpc_server:default", "external");
- lp_do_parameter(-1, "rpc_server:svcctl", "embedded");
- lp_do_parameter(-1, "rpc_server:srvsvc", "embedded");
- lp_do_parameter(-1, "rpc_server:eventlog", "embedded");
- lp_do_parameter(-1, "rpc_server:ntsvcs", "embedded");
- lp_do_parameter(-1, "rpc_server:winreg", "embedded");
- lp_do_parameter(-1, "rpc_server:spoolss", "embedded");
- lp_do_parameter(-1, "rpc_daemon:spoolssd", "embedded");
- lp_do_parameter(-1, "rpc_server:tcpip", "no");
+ lp_enforce_ad_dc_settings();
}
bAllowIncludeRegistry = true;
--
2.1.0
From b66f50ce791396a7ae4ebccd8eb7badc6870e66d Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Sat, 20 Sep 2014 04:45:45 +0200
Subject: [PATCH 20/26] s3:param: use GLOBAL_SECTION_SNUM in
lp_enforce_ad_dc_settings()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/param/loadparm.c | 23 ++++++++++++-----------
1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 53078e9..b399f68 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3629,17 +3629,18 @@ static bool lp_is_in_client(void)
static void lp_enforce_ad_dc_settings(void)
{
- lp_do_parameter(-1, "passdb backend", "samba_dsdb");
- lp_do_parameter(-1, "winbindd:use external pipes", "true");
- lp_do_parameter(-1, "rpc_server:default", "external");
- lp_do_parameter(-1, "rpc_server:svcctl", "embedded");
- lp_do_parameter(-1, "rpc_server:srvsvc", "embedded");
- lp_do_parameter(-1, "rpc_server:eventlog", "embedded");
- lp_do_parameter(-1, "rpc_server:ntsvcs", "embedded");
- lp_do_parameter(-1, "rpc_server:winreg", "embedded");
- lp_do_parameter(-1, "rpc_server:spoolss", "embedded");
- lp_do_parameter(-1, "rpc_daemon:spoolssd", "embedded");
- lp_do_parameter(-1, "rpc_server:tcpip", "no");
+ lp_do_parameter(GLOBAL_SECTION_SNUM, "passdb backend", "samba_dsdb");
+ lp_do_parameter(GLOBAL_SECTION_SNUM,
+ "winbindd:use external pipes", "true");
+ lp_do_parameter(GLOBAL_SECTION_SNUM, "rpc_server:default", "external");
+ lp_do_parameter(GLOBAL_SECTION_SNUM, "rpc_server:svcctl", "embedded");
+ lp_do_parameter(GLOBAL_SECTION_SNUM, "rpc_server:srvsvc", "embedded");
+ lp_do_parameter(GLOBAL_SECTION_SNUM, "rpc_server:eventlog", "embedded");
+ lp_do_parameter(GLOBAL_SECTION_SNUM, "rpc_server:ntsvcs", "embedded");
+ lp_do_parameter(GLOBAL_SECTION_SNUM, "rpc_server:winreg", "embedded");
+ lp_do_parameter(GLOBAL_SECTION_SNUM, "rpc_server:spoolss", "embedded");
+ lp_do_parameter(GLOBAL_SECTION_SNUM, "rpc_daemon:spoolssd", "embedded");
+ lp_do_parameter(GLOBAL_SECTION_SNUM, "rpc_server:tcpip", "no");
}
/***************************************************************************
--
2.1.0
From d919e655041908989796df2df34a60b7f2ec641f Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Sat, 20 Sep 2014 04:46:41 +0200
Subject: [PATCH 21/26] s3:param: fix a comment
Signed-off-by: Michael Adam <obnox 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 b399f68..22f5cfd 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3790,7 +3790,7 @@ static bool lp_load_ex(const char *pszFname,
/*
* We run this check once the whole smb.conf is parsed, to
* force some settings for the standard way a AD DC is
- * operated. We may changed these as our code evolves, which
+ * operated. We may change these as our code evolves, which
* is why we force these settings.
*/
if (lp_server_role() == ROLE_ACTIVE_DIRECTORY_DC) {
--
2.1.0
From d6a80c53425e9fed50bb50efc2874d01fc70281a Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Sat, 20 Sep 2014 04:48:11 +0200
Subject: [PATCH 22/26] s3:param: rename arg initialize_globals->reinit_globals
in lp_load_ex()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/param/loadparm.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 22f5cfd..59ff442 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3652,7 +3652,7 @@ static bool lp_load_ex(const char *pszFname,
bool global_only,
bool save_defaults,
bool add_ipc,
- bool initialize_globals,
+ bool reinit_globals,
bool allow_include_registry,
bool load_all_shares)
{
@@ -3671,7 +3671,7 @@ static bool lp_load_ex(const char *pszFname,
lp_ctx = setup_lp_context(talloc_tos());
- init_globals(lp_ctx, initialize_globals);
+ init_globals(lp_ctx, reinit_globals);
free_file_list();
@@ -3680,7 +3680,7 @@ static bool lp_load_ex(const char *pszFname,
lp_save_defaults();
}
- if (!initialize_globals) {
+ if (!reinit_globals) {
free_param_opts(&Globals.param_opt);
apply_lp_set_cmdline();
}
@@ -3731,7 +3731,7 @@ static bool lp_load_ex(const char *pszFname,
lp_kill_all_services();
ok = lp_load_ex(pszFname, global_only, save_defaults,
- add_ipc, initialize_globals,
+ add_ipc, reinit_globals,
allow_include_registry,
load_all_shares);
TALLOC_FREE(frame);
@@ -3824,7 +3824,7 @@ bool lp_load_initial_only(const char *pszFname)
true, /* global only */
true, /* save_defaults */
false, /* add_ipc */
- true, /* initialize_globals */
+ true, /* reinit_globals */
false, /* allow_include_registry */
false); /* load_all_shares*/
}
--
2.1.0
From 60779d594910de2b229808a11f161aa2212ded7f Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Sat, 20 Sep 2014 04:49:10 +0200
Subject: [PATCH 23/26] s3:param: rename arg initialize_globals->reinit_globals
in lp_load()
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/param/loadparm.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 59ff442..ca773a7 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3807,13 +3807,13 @@ static bool lp_load(const char *pszFname,
bool global_only,
bool save_defaults,
bool add_ipc,
- bool initialize_globals)
+ bool reinit_globals)
{
return lp_load_ex(pszFname,
global_only,
save_defaults,
add_ipc,
- initialize_globals,
+ reinit_globals,
true, /* allow_include_registry */
false); /* load_all_shares*/
}
@@ -3838,7 +3838,7 @@ bool lp_load_global(const char *file_name)
true, /* global_only */
false, /* save_defaults */
false, /* add_ipc */
- true); /* initialize_globals */
+ true); /* reinit_globals */
}
/**
@@ -3852,7 +3852,7 @@ bool lp_load_with_shares(const char *file_name)
false, /* global_only */
false, /* save_defaults */
true, /* add_ipc */
- true); /* initialize_globals */
+ true); /* reinit_globals */
}
/**
@@ -3876,7 +3876,7 @@ bool lp_load_global_no_reinit(const char *file_name)
true, /* global_only */
false, /* save_defaults */
false, /* add_ipc */
- false); /* initialize_globals */
+ false); /* reinit_globals */
}
/**
--
2.1.0
From 47eac8a1e0cff4a230149d1f6fa49055652393e4 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 21 Apr 2015 14:48:42 +0200
Subject: [PATCH 24/26] s3:param: remove arg initialize_globals from
lp_load_with_registry_shares()
This is only ever called in client context, and only called once.
So there is no point at all in requesting reinit_globals.
Set it to false.
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/include/proto.h | 3 +--
source3/param/loadparm.c | 5 ++---
source3/param/test_lp_load.c | 3 +--
source3/utils/sharesec.c | 2 +-
source3/utils/testparm.c | 2 +-
5 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index e66ce5f..ce68640 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1064,8 +1064,7 @@ bool lp_load_global_no_reinit(const char *file_name);
bool lp_load_no_reinit(const char *file_name);
bool lp_load_client_no_reinit(const char *file_name);
bool lp_load_with_registry_shares(const char *pszFname,
- bool save_defaults,
- bool initialize_globals);
+ bool save_defaults);
int lp_numservices(void);
void lp_dump(FILE *f, bool show_defaults, int maxtoprint);
void lp_dump_one(FILE * f, bool show_defaults, int snum);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index ca773a7..8e2a13b 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3905,14 +3905,13 @@ bool lp_load_client_no_reinit(const char *file_name)
}
bool lp_load_with_registry_shares(const char *pszFname,
- bool save_defaults,
- bool initialize_globals)
+ bool save_defaults)
{
return lp_load_ex(pszFname,
false, /* global_only */
save_defaults,
false, /* add_ipc */
- initialize_globals,
+ false, /* reinit_globals */
true, /* allow_include_registry */
true); /* load_all_shares*/
}
diff --git a/source3/param/test_lp_load.c b/source3/param/test_lp_load.c
index bd373b9..3bb0b89 100644
--- a/source3/param/test_lp_load.c
+++ b/source3/param/test_lp_load.c
@@ -62,8 +62,7 @@ int main(int argc, const char **argv)
for (i=0; i < count; i++) {
printf("call lp_load() #%d: ", i+1);
if (!lp_load_with_registry_shares(config_file,
- True, /* save defaults */
- True)) /*init globals */
+ True)) /* save defaults */
{
printf("ERROR.\n");
ret = 1;
diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c
index 914cc4f..a2f36fb 100644
--- a/source3/utils/sharesec.c
+++ b/source3/utils/sharesec.c
@@ -599,7 +599,7 @@ int main(int argc, const char *argv[])
setlinebuf(stdout);
- lp_load_with_registry_shares(get_dyn_CONFIGFILE(), False, True);
+ lp_load_with_registry_shares(get_dyn_CONFIGFILE(), False);
/* check for initializing secrets.tdb first */
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index 3cef0d6..a92fc3a 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -491,7 +491,7 @@ static void do_per_share_checks(int s)
fprintf(stderr,"Load smb config files from %s\n",config_file);
- if (!lp_load_with_registry_shares(config_file, True, True)) {
+ if (!lp_load_with_registry_shares(config_file, True)) {
fprintf(stderr,"Error loading services.\n");
ret = 1;
goto done;
--
2.1.0
From 33fb14c58bb1939da90c5ef3d5dbc8b50962b3bd Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Tue, 21 Apr 2015 15:24:42 +0200
Subject: [PATCH 25/26] s3:param: remove arg save_defaults from
lp_load_with_registry_shares()
This is only used in command line contexts, especially for testparm
which relies on safe defaults. The only changed use is in sharesec,
but it does not harm to also safe the defaults there.
Signed-off-by: Michael Adam <obnox at samba.org>
---
source3/include/proto.h | 3 +--
source3/param/loadparm.c | 5 ++---
source3/param/test_lp_load.c | 4 +---
source3/utils/sharesec.c | 2 +-
source3/utils/testparm.c | 2 +-
5 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/source3/include/proto.h b/source3/include/proto.h
index ce68640..4acad41 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -1063,8 +1063,7 @@ bool lp_load_client(const char *file_name);
bool lp_load_global_no_reinit(const char *file_name);
bool lp_load_no_reinit(const char *file_name);
bool lp_load_client_no_reinit(const char *file_name);
-bool lp_load_with_registry_shares(const char *pszFname,
- bool save_defaults);
+bool lp_load_with_registry_shares(const char *pszFname);
int lp_numservices(void);
void lp_dump(FILE *f, bool show_defaults, int maxtoprint);
void lp_dump_one(FILE * f, bool show_defaults, int snum);
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 8e2a13b..b53cae2 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -3904,12 +3904,11 @@ bool lp_load_client_no_reinit(const char *file_name)
return lp_load_global_no_reinit(file_name);
}
-bool lp_load_with_registry_shares(const char *pszFname,
- bool save_defaults)
+bool lp_load_with_registry_shares(const char *pszFname)
{
return lp_load_ex(pszFname,
false, /* global_only */
- save_defaults,
+ true, /* save_defaults */
false, /* add_ipc */
false, /* reinit_globals */
true, /* allow_include_registry */
diff --git a/source3/param/test_lp_load.c b/source3/param/test_lp_load.c
index 3bb0b89..fb3b95d 100644
--- a/source3/param/test_lp_load.c
+++ b/source3/param/test_lp_load.c
@@ -61,9 +61,7 @@ int main(int argc, const char **argv)
for (i=0; i < count; i++) {
printf("call lp_load() #%d: ", i+1);
- if (!lp_load_with_registry_shares(config_file,
- True)) /* save defaults */
- {
+ if (!lp_load_with_registry_shares(config_file)) {
printf("ERROR.\n");
ret = 1;
goto done;
diff --git a/source3/utils/sharesec.c b/source3/utils/sharesec.c
index a2f36fb..132ca7e 100644
--- a/source3/utils/sharesec.c
+++ b/source3/utils/sharesec.c
@@ -599,7 +599,7 @@ int main(int argc, const char *argv[])
setlinebuf(stdout);
- lp_load_with_registry_shares(get_dyn_CONFIGFILE(), False);
+ lp_load_with_registry_shares(get_dyn_CONFIGFILE());
/* check for initializing secrets.tdb first */
diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c
index a92fc3a..7850b43 100644
--- a/source3/utils/testparm.c
+++ b/source3/utils/testparm.c
@@ -491,7 +491,7 @@ static void do_per_share_checks(int s)
fprintf(stderr,"Load smb config files from %s\n",config_file);
- if (!lp_load_with_registry_shares(config_file, True)) {
+ if (!lp_load_with_registry_shares(config_file)) {
fprintf(stderr,"Error loading services.\n");
ret = 1;
goto done;
--
2.1.0
From 95dcd5be1dd4b29a8db14eab2c25c0b28739f716 Mon Sep 17 00:00:00 2001
From: Michael Adam <obnox at samba.org>
Date: Wed, 24 Sep 2014 10:30:17 +0200
Subject: [PATCH 26/26] param: remove two unused #defines
Signed-off-by: Michael Adam <obnox at samba.org>
---
lib/param/loadparm.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/lib/param/loadparm.c b/lib/param/loadparm.c
index ddb806a..34974d7 100644
--- a/lib/param/loadparm.c
+++ b/lib/param/loadparm.c
@@ -140,9 +140,6 @@ static const char *lpcfg_string(const char *s)
/* this global context supports the lp_*() function varients */
static struct loadparm_context *global_loadparm_context;
-#define lpcfg_default_service global_loadparm_context->sDefault
-#define lpcfg_global_service(i) global_loadparm_context->services[i]
-
#define FN_GLOBAL_STRING(fn_name,var_name) \
_PUBLIC_ char *lpcfg_ ## fn_name(struct loadparm_context *lp_ctx, TALLOC_CTX *ctx) {\
if (lp_ctx == NULL) return NULL; \
--
2.1.0
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20150421/12d431b2/attachment.pgp>
More information about the samba-technical
mailing list