srvsvc: Announce [username] in NetShareEnum master origin/HEAD origin/master
authorVolker Lendecke <vl@samba.org>
Wed, 18 May 2022 14:01:08 +0000 (16:01 +0200)
committerJeremy Allison <jra@samba.org>
Wed, 18 May 2022 17:42:20 +0000 (17:42 +0000)
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

selftest/knownfail.d/netshareenum_user [deleted file]
source3/rpc_server/srvsvc/srv_srvsvc_nt.c

diff --git a/selftest/knownfail.d/netshareenum_user b/selftest/knownfail.d/netshareenum_user
deleted file mode 100644 (file)
index 5ad1a49..0000000
+++ /dev/null
@@ -1 +0,0 @@
-.*samba3.blackbox.netshareenum_username.*
\ No newline at end of file
index a0e4d125a83bdf71b31ff6141c97a82b3e534335..99808ee8f3a25300e2cf819a46c34360c8da6754 100644 (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;
 }