]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
sharesec: Check if share exists in configuration
authorVinit Agnihotri <vagnihot@redhat.com>
Tue, 3 Dec 2024 05:51:09 +0000 (11:21 +0530)
committerJule Anger <janger@samba.org>
Tue, 21 Jan 2025 08:42:09 +0000 (08:42 +0000)
Load config from registry without share info and check if sharename
exists from configuration. This results into lesser delay for the same.

In case of view we load config with all shares to ensure we get all
shares for diplay purpose.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=15780

Signed-off-by: Vinit Agnihotri <vagnihot@redhat.com>
Reviewed-by: John Mulligan <jmulligan@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Fri Jan 10 10:45:30 UTC 2025 on atb-devel-224

(cherry picked from commit 1410803713440caf29a40aec30516489d1944665)

Autobuild-User(v4-20-test): Jule Anger <janger@samba.org>
Autobuild-Date(v4-20-test): Tue Jan 21 08:42:09 UTC 2025 on atb-devel-224

source3/utils/sharesec.c

index 6094746e3ccb80d83e74bdf3122d40c24d07d69c..47182894a66890325c4c2deb24f784f78156b185 100644 (file)
@@ -409,7 +409,6 @@ int main(int argc, const char *argv[])
        static char *the_acl = NULL;
        fstring sharename;
        bool force_acl = False;
-       int snum;
        poptContext pc;
        bool initialize_sid = False;
        bool ok;
@@ -604,7 +603,10 @@ int main(int argc, const char *argv[])
 
        setlinebuf(stdout);
 
-       lp_load_with_registry_shares(get_dyn_CONFIGFILE());
+       if (mode == SMB_ACL_VIEW_ALL)
+               lp_load_with_registry_shares(get_dyn_CONFIGFILE());
+       else
+               lp_load_with_registry_without_shares(get_dyn_CONFIGFILE());
 
        /* check for initializing secrets.tdb first */
 
@@ -631,7 +633,6 @@ int main(int argc, const char *argv[])
 
        if (mode == SMB_ACL_VIEW_ALL) {
                int i;
-
                for (i=0; i<lp_numservices(); i++) {
                        TALLOC_CTX *frame = talloc_stackframe();
                        const struct loadparm_substitution *lp_sub =
@@ -661,9 +662,7 @@ int main(int argc, const char *argv[])
 
        fstrcpy(sharename, poptGetArg(pc));
 
-       snum = lp_servicenumber( sharename );
-
-       if ( snum == -1 && !force_acl ) {
+       if (!share_exists(sharename)) {
                fprintf( stderr, "Invalid sharename: %s\n", sharename);
                retval = -1;
                goto done;