]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmbclient: Read the file type from the server with posix enabled
authorVolker Lendecke <vl@samba.org>
Wed, 23 Aug 2023 14:04:00 +0000 (16:04 +0200)
committerJeremy Allison <jra@samba.org>
Thu, 12 Oct 2023 16:55:34 +0000 (16:55 +0000)
This does not really request posix extensions, but it depends on them
being activated because it changes behaviour.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/libsmb_file.c

index 858679a8cc1e91b87b452097935d58596ea651cd..ff18d5697577e9f1a31956553655529bc3475755 100644 (file)
@@ -467,6 +467,7 @@ SMBC_getatr(SMBCCTX * context,
        struct timespec w_time_ts = {0};
        time_t write_time = 0;
        SMB_INO_T ino = 0;
+       mode_t mode = S_IFREG;
        struct cli_credentials *creds = NULL;
        TALLOC_CTX *frame = talloc_stackframe();
        NTSTATUS status;
@@ -517,7 +518,7 @@ SMBC_getatr(SMBCCTX * context,
                                        &size,
                                        &attr,
                                        &ino,
-                                       NULL);
+                                       &mode);
                if (NT_STATUS_IS_OK(status)) {
                        goto setup_stat;
                }
@@ -584,6 +585,10 @@ setup_stat:
                   change_time_ts,
                   write_time_ts);
 
+       if ((context->internal->posix_extensions) && (mode != S_IFREG)) {
+               sb->st_mode = (sb->st_mode & ~S_IFMT) | mode;
+       }
+
        TALLOC_FREE(frame);
        return NT_STATUS_OK;