From: Volker Lendecke Date: Wed, 23 Aug 2023 14:04:00 +0000 (+0200) Subject: libsmbclient: Read the file type from the server with posix enabled X-Git-Tag: tevent-0.16.0~153 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6a4413c65c980e54c2010f0adb0722d1b8972f85;p=thirdparty%2Fsamba.git libsmbclient: Read the file type from the server with posix enabled This does not really request posix extensions, but it depends on them being activated because it changes behaviour. Signed-off-by: Volker Lendecke Reviewed-by: Ralph Böhme Reviewed-by: Jeremy Allison --- diff --git a/source3/libsmb/libsmb_file.c b/source3/libsmb/libsmb_file.c index 858679a8cc1..ff18d569757 100644 --- a/source3/libsmb/libsmb_file.c +++ b/source3/libsmb/libsmb_file.c @@ -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;