clitar: Use do_list()'s recursion in clitar.c
authorVolker Lendecke <vl@samba.org>
Tue, 1 Dec 2020 07:58:14 +0000 (08:58 +0100)
committerKarolin Seeger <kseeger@samba.org>
Wed, 2 Dec 2020 13:14:22 +0000 (13:14 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Aurelien Aptel <aaptel@samba.org>
Reviewed-by: Noel Power <noel.power@suse.com>
(cherry picked from commit 20e0ce508844fec2dd0011423b10484dc7ccfdb7)

source3/client/clitar.c

index 3fe3622aba667c564b0e6d3a2cc3626fdeeeb156..4fd1f3c47d9bca06a5879d4be0447e8a8814a2f5 100644 (file)
@@ -711,7 +711,7 @@ static int tar_create(struct tar* t)
                        goto out_close;
                }
                DBG(5, ("tar_process do_list with mask: %s\n", mask));
-               status = do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, false, true);
+               status = do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, true, true);
                if (!NT_STATUS_IS_OK(status)) {
                        DBG(0, ("do_list fail %s\n", nt_errstr(status)));
                        err = 1;
@@ -806,7 +806,7 @@ static int tar_create_from_list(struct tar *t)
                        DBG(5, ("cd '%s' before do_list\n", base));
                        client_set_cur_dir(base);
                }
-               status = do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, false, true);
+               status = do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, true, true);
                if (base != NULL) {
                        client_set_cur_dir(start_dir);
                }
@@ -837,7 +837,7 @@ static NTSTATUS get_file_callback(struct cli_state *cli,
        char *remote_name;
        char *old_dir = NULL;
        char *new_dir = NULL;
-       const char *initial_dir = client_get_cur_dir();
+       const char *initial_dir = dir;
        bool skip = false;
        bool isdir;
        int rc;
@@ -846,7 +846,7 @@ static NTSTATUS get_file_callback(struct cli_state *cli,
                return NT_STATUS_NO_MEMORY;
        }
 
-       remote_name = talloc_asprintf(ctx, "%s%s", initial_dir, finfo->name);
+       remote_name = talloc_asprintf(ctx, "%s\\%s", initial_dir, finfo->name);
        if (remote_name == NULL) {
                status = NT_STATUS_NO_MEMORY;
                goto out;
@@ -884,35 +884,10 @@ static NTSTATUS get_file_callback(struct cli_state *cli,
                goto out;
        }
 
-       if (isdir) {
-               char *mask;
-               mask = talloc_asprintf(ctx, "%s*", new_dir);
-               if (mask == NULL) {
-                       status = NT_STATUS_NO_MEMORY;
-                       goto out;
-               }
-               mask = client_clean_name(ctx, mask);
-               if (mask == NULL) {
-                       status = NT_STATUS_NO_MEMORY;
-                       goto out;
-               }
-
-               rc = tar_get_file(&tar_ctx, remote_name, finfo);
-               if (rc != 0) {
-                       status = NT_STATUS_UNSUCCESSFUL;
-                       goto out;
-               }
-
-               client_set_cur_dir(new_dir);
-               do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, false, true);
-               client_set_cur_dir(old_dir);
-               tar_ctx.numdir++;
-       } else {
-               rc = tar_get_file(&tar_ctx, remote_name, finfo);
-               if (rc != 0) {
-                       status = NT_STATUS_UNSUCCESSFUL;
-                       goto out;
-               }
+       rc = tar_get_file(&tar_ctx, remote_name, finfo);
+       if (rc != 0) {
+               status = NT_STATUS_UNSUCCESSFUL;
+               goto out;
        }
 
 out: