summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2022-05-18 16:01:08 +0200
committerJule Anger <janger@samba.org>2022-05-20 09:10:43 +0000
commitf23f9132f7c0205220e11732ee5b0c69ea8467dd (patch)
treeb04078b4fe8bf4434a180f9abedd070e2dfb6424
parent344ff937f203a9545ab8a56710499bf2c25691ee (diff)
downloadsamba-f23f9132f7c0205220e11732ee5b0c69ea8467dd.tar.gz
srvsvc: Announce [username] in NetShareEnum
This patch has two flaws: First, it does not cover api_RNetShareEnum() for SMB1, and the second one is: To make this elegant, we would have to restructure our share handling. It is really only listing shares for which we have to pull in everything from smb.conf, registry, usershares and potentially printers. What we should do is modify our loadparm handling to only load share definitions on demand and for listing shares handle all the potential sources specially. Add code that walks the registry shares without adding them to our services list and so on. This patch is the quick&dirty way to fix the bug, the alternative would be weeks or more. And hopefully nobody notices the SMB1 problem... Bug: https://bugzilla.samba.org/show_bug.cgi?id=15062 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed May 18 17:42:20 UTC 2022 on sn-devel-184 (cherry picked from commit 04e0e02c6951e327130210e44deb87b9a303cdb3) Autobuild-User(v4-16-test): Jule Anger <janger@samba.org> Autobuild-Date(v4-16-test): Fri May 20 09:10:43 UTC 2022 on sn-devel-184
-rw-r--r--selftest/knownfail.d/netshareenum_user1
-rw-r--r--source3/rpc_server/srvsvc/srv_srvsvc_nt.c16
2 files changed, 15 insertions, 2 deletions
diff --git a/selftest/knownfail.d/netshareenum_user b/selftest/knownfail.d/netshareenum_user
deleted file mode 100644
index 5ad1a499623..00000000000
--- a/selftest/knownfail.d/netshareenum_user
+++ /dev/null
@@ -1 +0,0 @@
-.*samba3.blackbox.netshareenum_username.* \ No newline at end of file
diff --git a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
index 54209e3e7b6..0bd79b595a9 100644
--- a/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
+++ b/source3/rpc_server/srvsvc/srv_srvsvc_nt.c
@@ -610,6 +610,9 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
uint32_t *total_entries,
bool all_shares)
{
+ struct dcesrv_call_state *dce_call = p->dce_call;
+ struct auth_session_info *session_info =
+ dcesrv_call_session_info(dce_call);
const struct loadparm_substitution *lp_sub =
loadparm_s3_global_substitution();
uint32_t num_entries = 0;
@@ -622,6 +625,9 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
bool *allowed = 0;
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 added_home = -1;
WERROR ret = WERR_OK;
DEBUG(5,("init_srv_share_info_ctr\n"));
@@ -631,9 +637,14 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
delete_and_reload_printers();
load_usershare_shares(NULL, connections_snum_used);
load_registry_shares();
- num_services = lp_numservices();
unbecome_root();
+ if (existing_home == -1) {
+ added_home = register_homes_share(unix_name);
+ }
+
+ num_services = lp_numservices();
+
allowed = talloc_zero_array(ctx, bool, num_services);
if (allowed == NULL) {
goto nomem;
@@ -896,6 +907,9 @@ static WERROR init_srv_share_info_ctr(struct pipes_struct *p,
nomem:
ret = WERR_NOT_ENOUGH_MEMORY;
done:
+ if (added_home != -1) {
+ lp_killservice(added_home);
+ }
return ret;
}