]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
xattr/setxattr: fix flag support on AIX
authorBjörn Jacke <bj@sernet.de>
Sat, 2 Mar 2019 04:39:54 +0000 (05:39 +0100)
committerBjoern Jacke <bjacke@samba.org>
Thu, 29 Aug 2019 15:53:30 +0000 (15:53 +0000)
AIX requires the flags to be 0, we need to do those checks manually.

Signed-off-by: Bjoern Jacke <bjacke@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
lib/replace/xattr.c

index f142ed61723481249714819e0593988f441b5721..b7fbde2a2cabc311632450eb64d4eb4624e8c517 100644 (file)
@@ -538,7 +538,21 @@ int rep_setxattr (const char *path, const char *name, const void *value, size_t
        return retval;
 #endif
 #elif defined(HAVE_XATTR_EA)
-       return setea(path, name, value, size, flags);
+       if (flags) {
+               retval = getea(path, name, NULL, 0);
+               if (retval < 0) {
+                       if (flags & XATTR_REPLACE && errno == ENOATTR) {
+                               return -1;
+                       }
+               } else {
+                       if (flags & XATTR_CREATE) {
+                               errno = EEXIST;
+                               return -1;
+                       }
+               }
+       }
+       retval = setea(path, name, value, size, 0);
+       return retval;
 #elif defined(HAVE_XATTR_EXTATTR)
        int attrnamespace;
        const char *attrname;
@@ -632,7 +646,21 @@ int rep_fsetxattr (int filedes, const char *name, const void *value, size_t size
        return retval;
 #endif
 #elif defined(HAVE_XATTR_EA)
-       return fsetea(filedes, name, value, size, flags);
+       if (flags) {
+               retval = fgetea(filedes, name, NULL, 0);
+               if (retval < 0) {
+                       if (flags & XATTR_REPLACE && errno == ENOATTR) {
+                               return -1;
+                       }
+               } else {
+                       if (flags & XATTR_CREATE) {
+                               errno = EEXIST;
+                               return -1;
+                       }
+               }
+       }
+       retval = fsetea(filedes, name, value, size, 0);
+       return retval;
 #elif defined(HAVE_XATTR_EXTATTR)
        int attrnamespace;
        const char *attrname;