s3:smbcacls: Add support for DFS path
authorAnubhav Rakshit <anubhav.rakshit@gmail.com>
Sun, 7 Jun 2020 19:09:59 +0000 (00:39 +0530)
committerJeremy Allison <jra@samba.org>
Tue, 7 Jul 2020 23:03:00 +0000 (23:03 +0000)
smbcacls does not handle DFS paths correctly. This is beacuse once the
command encounters a path which returns STATUS_PATH_NOT_COVERED, it does
not attempt a GET REFERRAL.

We use cli_resolve_path API to perform a DFS path resolution to solve
the above problem.

Additionally this removes the known fail against smbcacls tests
Signed-off-by: Anubhav Rakshit <anubhav.rakshit@gmail.com>
Reviewed-by: Noel Power <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Jul  7 23:03:00 UTC 2020 on sn-devel-184

selftest/knownfail.d/smbcacls
source3/utils/smbcacls.c

index bcd78ce7b335e51d822e0d0578ca06e470b99179..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 (file)
@@ -1 +0,0 @@
-^samba.tests.blackbox.smbcacls_basic\(DFS\)
index ecd2aa0e824b3028f520dc986ceab6e6c009f310..f3209c31877efd3f6ca33aee16777817d31005d6 100644 (file)
@@ -816,6 +816,9 @@ int main(int argc, char *argv[])
        /* numeric is set when the user wants numeric SIDs and ACEs rather
           than going via LSA calls to resolve them */
        int numeric = 0;
+       struct cli_state *targetcli = NULL;
+       char *targetfile = NULL;
+       NTSTATUS status;
 
        struct poptOption long_options[] = {
                POPT_AUTOHELP
@@ -1077,16 +1080,28 @@ int main(int argc, char *argv[])
                }
        }
 
+       status = cli_resolve_path(frame,
+                                 "",
+                                 popt_get_cmdline_auth_info(),
+                                 cli,
+                                 filename,
+                                 &targetcli,
+                                 &targetfile);
+       if (!NT_STATUS_IS_OK(status)) {
+               DEBUG(0,("cli_resolve_path failed for %s! (%s)\n", filename, nt_errstr(status)));
+               return -1;
+       }
+
        /* Perform requested action */
 
        if (change_mode == REQUEST_INHERIT) {
-               result = inherit(cli, filename, owner_username);
+               result = inherit(targetcli, targetfile, owner_username);
        } else if (change_mode != REQUEST_NONE) {
-               result = owner_set(cli, change_mode, filename, owner_username);
+               result = owner_set(targetcli, change_mode, targetfile, owner_username);
        } else if (the_acl) {
-               result = cacl_set(cli, filename, the_acl, mode, numeric);
+               result = cacl_set(targetcli, targetfile, the_acl, mode, numeric);
        } else {
-               result = cacl_dump(cli, filename, numeric);
+               result = cacl_dump(targetcli, targetfile, numeric);
        }
 
        popt_free_cmdline_auth_info();