From: Volker Lendecke Date: Wed, 18 May 2022 14:01:08 +0000 (+0200) Subject: srvsvc: Announce [username] in NetShareEnum X-Git-Tag: talloc-2.3.4~111 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=04e0e02c6951e327130210e44deb87b9a303cdb3;p=thirdparty%2Fsamba.git 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 Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Wed May 18 17:42:20 UTC 2022 on sn-devel-184 --- 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 a0e4d125a83..99808ee8f3a 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; }