summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2022-12-28 13:50:45 +0100
committerJule Anger <janger@samba.org>2023-01-13 10:54:14 +0000
commitb1d5552f2e2808db3eeb1e3492df87be12e6b99b (patch)
tree08f20c68b26ee0bcc87e4fe4f94f4afe695f6a7d
parenta8934a92f1a166fb66e247b9fb2be5758f1a91fc (diff)
downloadsamba-b1d5552f2e2808db3eeb1e3492df87be12e6b99b.tar.gz
s3:rpc_server/srvsvc: make sure we (re-)load all shares as root.
This fixes a regression in commit f03665bb7e8ea97699062630f2aa1bac4c5dfc7f The use of reload_services() has a lot of side effects, e.g. reopen of log files and other things, which are only useful in smbd, but not in rpcd_classic. It was also unloading the user and registry shares we loaded a few lines above. We need to do all (re-)loading as root, otherwise we won't be able to read root only smb.conf files, access registry shares, ... BUG: https://bugzilla.samba.org/show_bug.cgi?id=15243 BUG: https://bugzilla.samba.org/show_bug.cgi?id=15266 Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Andrew Walker <awalker@ixsystems.com> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Thu Dec 29 21:14:02 UTC 2022 on sn-devel-184 (cherry picked from commit f28553105be7465026bcc0fcbbed6a1a8c2133dd)
-rw-r--r--selftest/knownfail.d/registry_share1
-rw-r--r--source3/rpc_server/srvsvc/srv_srvsvc_nt.c28
2 files changed, 16 insertions, 13 deletions
diff --git a/selftest/knownfail.d/registry_share b/selftest/knownfail.d/registry_share
deleted file mode 100644
index 4adbf0915b8..00000000000
--- a/selftest/knownfail.d/registry_share
+++ /dev/null
@@ -1 +0,0 @@
-^samba3.blackbox.registry_share.Test.for.share.enum.with.registry.share.clusteredmember
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index fbc617c3ac1..5b57e3e0bdf 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -639,30 +639,34 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
union srvsvc_NetShareCtr ctr;
uint32_t resume_handle = resume_handle_p ? *resume_handle_p : 0;
const char *unix_name = session_info->unix_info->unix_name;
- int existing_home = lp_servicenumber(unix_name);
+ int existing_home = -1;
int added_home = -1;
WERROR ret = WERR_OK;
DEBUG(5,("init_srv_share_info_ctr\n"));
- /* Ensure all the usershares are loaded. */
+ /*
+ * We need to make sure to reload the services for the connecting user.
+ * It is possible that we have includes with substitutions.
+ *
+ * include = /etc/samba/%U.conf
+ *
+ * We also need all printers and usershares.
+ *
+ * We need to be root in order to have access to registry shares
+ * and root only smb.conf files.
+ */
become_root();
+ lp_kill_all_services();
+ lp_load_with_shares(get_dyn_CONFIGFILE());
delete_and_reload_printers();
load_usershare_shares(NULL, connections_snum_used);
load_registry_shares();
- unbecome_root();
-
+ existing_home = lp_servicenumber(unix_name);
if (existing_home == -1) {
added_home = register_homes_share(unix_name);
}
-
- /*
- * We need to make sure to reload the services for the connecting user.
- * It is possible that the we have includes with substitutions.
- *
- * include = /etc/samba/%U.conf
- */
- reload_services(NULL, NULL, false);
+ unbecome_root();
num_services = lp_numservices();