]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbclient: Use cli_checkpath in "cd" command
authorVolker Lendecke <vl@samba.org>
Tue, 26 Oct 2021 08:14:28 +0000 (10:14 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 11 Nov 2021 19:08:37 +0000 (19:08 +0000)
No need for special qpathinfo_basic code

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/client/client.c

index 98425048f4bc23cca4ae86edeb2115c8cabcf631..a45215a77958c903f1708da9f1d271177d129d33 100644 (file)
@@ -388,8 +388,6 @@ static int do_cd(const char *new_dir)
        char *new_cd = NULL;
        char *targetpath = NULL;
        struct cli_state *targetcli = NULL;
-       SMB_STRUCT_STAT sbuf;
-       uint32_t attributes;
        int ret = 1;
        TALLOC_CTX *ctx = talloc_stackframe();
        struct cli_credentials *creds = samba_cmdline_get_creds();
@@ -449,46 +447,24 @@ static int do_cd(const char *new_dir)
                return 0;
        }
 
-       /* Use a trans2_qpathinfo to test directories for modern servers.
-          Except Win9x doesn't support the qpathinfo_basic() call..... */
-
-       if (smbXcli_conn_protocol(targetcli->conn) > PROTOCOL_LANMAN2 && !targetcli->win95) {
-
-               status = cli_qpathinfo_basic(targetcli, targetpath, &sbuf,
-                                            &attributes);
-               if (!NT_STATUS_IS_OK(status)) {
-                       d_printf("cd %s: %s\n", new_cd, nt_errstr(status));
-                       client_set_cur_dir(saved_dir);
-                       goto out;
-               }
-
-               if (!(attributes & FILE_ATTRIBUTE_DIRECTORY)) {
-                       d_printf("cd %s: not a directory\n", new_cd);
-                       client_set_cur_dir(saved_dir);
-                       goto out;
-               }
-       } else {
 
-               targetpath = talloc_asprintf(ctx,
-                               "%s%s",
-                               targetpath,
-                               CLI_DIRSEP_STR );
-               if (!targetpath) {
-                       client_set_cur_dir(saved_dir);
-                       goto out;
-               }
-               targetpath = client_clean_name(ctx, targetpath);
-               if (!targetpath) {
-                       client_set_cur_dir(saved_dir);
-                       goto out;
-               }
+       targetpath = talloc_asprintf(
+               ctx, "%s%s", targetpath, CLI_DIRSEP_STR);
+       if (!targetpath) {
+               client_set_cur_dir(saved_dir);
+               goto out;
+       }
+       targetpath = client_clean_name(ctx, targetpath);
+       if (!targetpath) {
+               client_set_cur_dir(saved_dir);
+               goto out;
+       }
 
-               status = cli_chkpath(targetcli, targetpath);
-               if (!NT_STATUS_IS_OK(status)) {
-                       d_printf("cd %s: %s\n", new_cd, nt_errstr(status));
-                       client_set_cur_dir(saved_dir);
-                       goto out;
-               }
+       status = cli_chkpath(targetcli, targetpath);
+       if (!NT_STATUS_IS_OK(status)) {
+               d_printf("cd %s: %s\n", new_cd, nt_errstr(status));
+               client_set_cur_dir(saved_dir);
+               goto out;
        }
 
        ret = 0;