From 6a4413c65c980e54c2010f0adb0722d1b8972f85 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Wed, 23 Aug 2023 16:04:00 +0200 Subject: [PATCH] libsmbclient: Read the file type from the server with posix enabled MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- source3/libsmb/libsmb_file.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; -- 2.47.3