]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbclient: Give a message if we try and use any POSIX command without negotiating...
authorJeremy Allison <jra@samba.org>
Sun, 21 Nov 2021 04:17:11 +0000 (20:17 -0800)
committerRalph Boehme <slow@samba.org>
Sat, 11 Dec 2021 11:14:31 +0000 (11:14 +0000)
Ensure we only use a POSIX command if POSIX is set up.
Issue the message: Command "posix" must be issued before the "XXXX" command can be used.
After the parameter parsing has been done.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/client/client.c

index a45215a77958c903f1708da9f1d271177d129d33..7ea9f4f96aa03aa2a2b2e74d39599d1d9902750e 100644 (file)
@@ -2815,6 +2815,11 @@ static int cmd_posix_open(void)
                d_printf("posix_open <filename> 0<mode>\n");
                return 1;
        }
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                       "the \"posix_open\" command can be used.\n");
+               return 1;
+       }
        mode = (mode_t)strtol(buf, (char **)NULL, 8);
 
        status = cli_resolve_path(ctx, "",
@@ -2876,6 +2881,11 @@ static int cmd_posix_mkdir(void)
                d_printf("posix_mkdir <filename> 0<mode>\n");
                return 1;
        }
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                       "the \"posix_mkdir\" command can be used.\n");
+               return 1;
+       }
        mode = (mode_t)strtol(buf, (char **)NULL, 8);
 
        status = cli_resolve_path(ctx, "",
@@ -2910,6 +2920,11 @@ static int cmd_posix_unlink(void)
                d_printf("posix_unlink <filename>\n");
                return 1;
        }
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                       "the \"posix_unlink\" command can be used.\n");
+               return 1;
+       }
        mask = talloc_asprintf(ctx,
                        "%s%s",
                        client_get_cur_dir(),
@@ -2955,6 +2970,11 @@ static int cmd_posix_rmdir(void)
                d_printf("posix_rmdir <filename>\n");
                return 1;
        }
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                       "the \"posix_rmdir\" command can be used.\n");
+               return 1;
+       }
        mask = talloc_asprintf(ctx,
                        "%s%s",
                        client_get_cur_dir(),
@@ -3154,6 +3174,12 @@ static int cmd_lock(void)
                return 1;
        }
 
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                       "the \"lock\" command can be used.\n");
+               return 1;
+       }
+
        len = (uint64_t)strtol(buf, (char **)NULL, 16);
 
        status = cli_posix_lock(cli, fnum, start, len, true, lock_type);
@@ -3190,6 +3216,12 @@ static int cmd_unlock(void)
                return 1;
        }
 
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                       "the \"unlock\" command can be used.\n");
+               return 1;
+       }
+
        len = (uint64_t)strtol(buf, (char **)NULL, 16);
 
        status = cli_posix_unlock(cli, fnum, start, len);
@@ -3213,6 +3245,12 @@ static int cmd_posix_whoami(void)
        bool guest = false;
        uint32_t i;
 
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                       "the \"posix_whoami\" command can be used.\n");
+               return 1;
+       }
+
        status = cli_posix_whoami(cli,
                        ctx,
                        &uid,
@@ -3350,6 +3388,12 @@ static int cmd_link(void)
                return 1;
        }
 
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                        "the \"link\" command can be used.\n");
+               return 1;
+       }
+
        status = cli_posix_hardlink(targetcli, targetname, newname);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("%s linking files (%s -> %s)\n",
@@ -3403,6 +3447,12 @@ static int cmd_readlink(void)
                return 1;
        }
 
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                        "the \"readlink\" command can be used.\n");
+               return 1;
+       }
+
        status = cli_posix_readlink(targetcli, name, talloc_tos(), &linkname);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("%s readlink on file %s\n",
@@ -3442,6 +3492,11 @@ static int cmd_symlink(void)
        link_target = buf;
 
        if (SERVER_HAS_UNIX_CIFS(cli)) {
+               if (CLI_DIRSEP_CHAR != '/') {
+                       d_printf("Command \"posix\" must be issued before "
+                               "the \"symlink\" command can be used.\n");
+                       return 1;
+               }
                newname = talloc_asprintf(ctx, "%s%s", client_get_cur_dir(),
                                          buf2);
                if (!newname) {
@@ -3525,6 +3580,12 @@ static int cmd_chmod(void)
                return 1;
        }
 
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                        "the \"chmod\" command can be used.\n");
+               return 1;
+       }
+
        status = cli_posix_chmod(targetcli, targetname, mode);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("%s chmod file %s 0%o\n",
@@ -3689,6 +3750,12 @@ static int cmd_getfacl(void)
                return 1;
        }
 
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                        "the \"getfacl\" command can be used.\n");
+               return 1;
+       }
+
        status = cli_unix_extensions_version(targetcli, &major, &minor,
                                             &caplow, &caphigh);
        if (!NT_STATUS_IS_OK(status)) {
@@ -3988,6 +4055,12 @@ static int cmd_stat(void)
                return 1;
        }
 
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                        "the \"stat\" command can be used.\n");
+               return 1;
+       }
+
        status = cli_posix_stat(targetcli, targetname, &sbuf);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("%s stat file %s\n",
@@ -4102,6 +4175,12 @@ static int cmd_chown(void)
                return 1;
        }
 
+       if (CLI_DIRSEP_CHAR != '/') {
+               d_printf("Command \"posix\" must be issued before "
+                        "the \"chown\" command can be used.\n");
+               return 1;
+       }
+
        status = cli_posix_chown(targetcli, targetname, uid, gid);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("%s chown file %s uid=%d, gid=%d\n",