1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-09 08:58:35 +03:00

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
This commit is contained in:
Volker Lendecke 2022-05-18 16:01:08 +02:00 committed by Jeremy Allison
parent 20cbade5b1
commit 04e0e02c69
2 changed files with 15 additions and 2 deletions

View File

@ -1 +0,0 @@
.*samba3.blackbox.netshareenum_username.*

View File

@ -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;
}