s3: libsmb: Change cli_setpathinfo_ext() to take 32-bit attributes.
authorJeremy Allison <jra@samba.org>
Thu, 4 Jun 2020 03:48:23 +0000 (20:48 -0700)
committerJeremy Allison <jra@samba.org>
Thu, 4 Jun 2020 17:11:38 +0000 (17:11 +0000)
Fix the callers. Note the special casing of mapping (uint16)-1 -> (uint32_t)-1
in SMBC_setatr() where we can't change the ABI.

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

index f423b5d3d586060a2964e1f35b2f62fd96b33446..69f6fd688dc5364096cbcd9e10ac4a16b727ab3b 100644 (file)
@@ -5282,7 +5282,8 @@ static int cmd_utimes(void)
                   timespec_string_buf(&times[3], false, &tbuf[3])));
 
        status = cli_setpathinfo_ext(
-               cli, fname, times[0], times[1], times[2], times[3], -1);
+               cli, fname, times[0], times[1], times[2], times[3],
+               (uint32_t)-1);
        if (!NT_STATUS_IS_OK(status)) {
                d_printf("cli_setpathinfo_ext failed: %s\n",
                         nt_errstr(status));
index 85d1327650a141822063be9634475efb11445ae3..ab7e085e80c97242eed8da79c70c42b4ad239294 100644 (file)
@@ -688,7 +688,7 @@ static void prep_basic_information_buf(
        struct timespec access_time,
        struct timespec write_time,
        struct timespec change_time,
-       uint16_t attr)
+       uint32_t attr)
 {
        char *p = (char *)buf;
        /*
@@ -710,7 +710,7 @@ static void prep_basic_information_buf(
                TIMESTAMP_SET_NT_OR_BETTER, p, &change_time);
        p += 8;
 
-       if (attr == (uint16_t)-1 || attr == FILE_ATTRIBUTE_NORMAL) {
+       if (attr == (uint32_t)-1 || attr == FILE_ATTRIBUTE_NORMAL) {
                /* No change. */
                attr = 0;
        } else if (attr == 0) {
@@ -735,7 +735,7 @@ NTSTATUS cli_setpathinfo_ext(struct cli_state *cli, const char *fname,
                             struct timespec access_time,
                             struct timespec write_time,
                             struct timespec change_time,
-                            uint16_t attr)
+                            uint32_t attr)
 {
        uint8_t buf[40];
 
@@ -797,7 +797,7 @@ struct tevent_req *cli_setfileinfo_ext_send(
                access_time,
                write_time,
                change_time,
-               attr);
+               (uint32_t)attr);
 
        if (smbXcli_conn_protocol(cli->conn) >= PROTOCOL_SMB2_02) {
                state->in_data = (DATA_BLOB) {
index d93cc838889004c4423db966d0dbb336057552bf..170876160a8e3a77c0838ebd78579b49b6f379c1 100644 (file)
@@ -62,7 +62,7 @@ NTSTATUS cli_setpathinfo_ext(struct cli_state *cli, const char *fname,
                             struct timespec access_time,
                             struct timespec write_time,
                             struct timespec change_time,
-                            uint16_t attr);
+                            uint32_t attr);
 struct tevent_req *cli_setfileinfo_ext_send(
        TALLOC_CTX *mem_ctx,
        struct tevent_context *ev,
index 5f50439c41be76746126ad4c18271bfc0850730e..540f80d50586b50ee898736b224a45481dc40e08 100644 (file)
@@ -592,8 +592,22 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
 {
         uint16_t fd;
         int ret;
+       uint32_t lattr = (uint32_t)attr;
        TALLOC_CTX *frame = talloc_stackframe();
 
+       if (attr == (uint16_t)-1) {
+               /*
+                * External ABI only passes in
+                * 16-bits of attribute. Make
+                * sure we correctly map to
+                * (uint32_t)-1 meaning don't
+                * change attributes if attr was
+                * passed in as 16-bit -1.
+                */
+               lattr = (uint32_t)-1;
+       }
+
+
         /*
          * First, try setpathinfo (if qpathinfo succeeded), for it is the
          * modern function for "new code" to be using, and it works given a
@@ -606,7 +620,7 @@ SMBC_setatr(SMBCCTX * context, SMBCSRV *srv, char *path,
                                                 access_time,
                                                 write_time,
                                                 change_time,
-                                                attr))) {
+                                                lattr))) {
 
                 /*
                  * setpathinfo is not supported; go to plan B.
index a4ffc25de4c91723029a8d285f75420b469e2c0f..00fc7529c500954a921917e7a9d25534802534c1 100644 (file)
@@ -4126,7 +4126,7 @@ static bool run_attrtest(int dummy)
                (struct timespec) { .tv_nsec = SAMBA_UTIME_OMIT }, /* access */
                (struct timespec) { .tv_nsec = SAMBA_UTIME_OMIT }, /* write */
                (struct timespec) { .tv_nsec = SAMBA_UTIME_OMIT }, /* change */
-               (uint16_t)-1);
+               (uint32_t)-1);
        if (!NT_STATUS_IS_OK(status)) {
                printf("cli_setpathinfo_ext failed with %s\n",
                        nt_errstr(status));