]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmbclient: Intercept "posix.attr.enabled" for fgetxattr
authorVolker Lendecke <vl@samba.org>
Mon, 2 Jun 2025 13:24:04 +0000 (15:24 +0200)
committerRalph Boehme <slow@samba.org>
Mon, 16 Jun 2025 15:05:32 +0000 (15:05 +0000)
Local call to find out whether the file was opened with smb311 posix
extensions.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/libsmb/libsmb_xattr.c

index 81753bfbfa863eccad89d58b2544bdbb56322d98..79e520d470d0463cad755235478a6ea144ef55ab 100644 (file)
@@ -25,6 +25,7 @@
 #include "includes.h"
 #include "source3/include/client.h"
 #include "source3/libsmb/proto.h"
+#include "source3/libsmb/cli_smb2_fnum.h"
 #include "libsmbclient.h"
 #include "libsmb_internal.h"
 #include "../librpc/gen_ndr/ndr_lsa.h"
@@ -2224,6 +2225,32 @@ SMBC_fgetxattr_ctx(SMBCCTX *context,
 
        DEBUG(4, ("smbc_fgetxattr(%s, %s)\n", file->fname, name));
 
+       if (strequal(name, "posix.attr.enabled")) {
+               bool is_posix;
+               int len;
+
+               is_posix = cli_smb2_fnum_is_posix(file->targetcli,
+                                                 file->cli_fd);
+               len = snprintf(discard_const_p(char, value),
+                              size,
+                              "%d",
+                              is_posix ? 1 : 0);
+               if (len < 0) {
+                       TALLOC_FREE(frame);
+                       errno = EINVAL;
+                       return -1;
+               }
+
+               if ((size_t)len > size) {
+                       TALLOC_FREE(frame);
+                       errno = ERANGE;
+                       return -1;
+               }
+
+               TALLOC_FREE(frame);
+               return len;
+       }
+
        ret = SMBC_getxattr_ctx(context, file->fname, name, value, size);
 
        {