Skip to contentSkip to conversation

attr: xattr.conf

PATCH Andreas Gruenbacher 1 participant 1 message Oct 28, 2007

lore
Share & tools
lore
#0 lore raw

Hello,

here is another patch which for some reason didn't get merged into the upstream version: the current attribute copying functions attr_copy_file and attr_copy_fd is a static list of exceptions for attributes that need special treatment. The list of those attributes tends to change (slowly) with kernel versions. We replaced the static list with a config file a while ago; this is the patch used. Any objections to merging this into the upstream version as well?

Attached is the patch, and an xattr.conf example.

Thanks,
Andreas

# /etc/xattr.conf
#
# How to handle extended attributes when copying between files
#
# Format:
# <pattern> <action>
#
# Actions:
#   permissions - copy when trying to preserve permissions.
#   skip - do not copy.

system.nfs4_acl permissions
system.nfs4acl permissions
system.posix_acl_access permissions
system.posix_acl_default permissions
trusted.SGI_ACL_DEFAULT skip # xfs specific
trusted.SGI_ACL_FILE skip # xfs specific
trusted.SGI_CAP_FILE skip # xfs specific
trusted.SGI_DMI_* skip # xfs specific
trusted.SGI_MAC_FILE skip # xfs specific
xfsroot.* skip # xfs specific; obsolete
user.Beagle.* skip # ignore Beagle index data

libattr/Makefile +1 -1
Index: attr-2.4.39/libattr/Makefile
===================================================================
@@ -12,7 +12,7 @@ LT_CURRENT = 2
 LT_REVISION = 0
 LT_AGE = 1
 
-CFILES = libattr.c attr_copy_fd.c attr_copy_file.c attr_copy_check.c
+CFILES = libattr.c attr_copy_fd.c attr_copy_file.c attr_copy_check.c attr_copy_action.c
 HFILES = libattr.h
 
 ifeq ($(PKG_PLATFORM),linux)
libattr/attr_copy_action.c new file +163 -0

163 lines not on this page · raw message

libattr/attr_copy_fd.c +2 -1
Index: attr-2.4.39/libattr/attr_copy_fd.c
===================================================================
@@ -119,7 +119,7 @@ attr_copy_fd(const char *src_path, int s
 			quote_free (ctx, qname);
 			quote_free (ctx, qpath);
 			ret = -1;
-			continue;  /* may not have permission to access */
+			continue;
 		}
 		value = (char *) realloc (old_value = value, size);
 		if (size != 0 && value == NULL) {
@@ -136,6 +136,7 @@ attr_copy_fd(const char *src_path, int s
 			quote_free (ctx, qname);
 			quote_free (ctx, qpath);
 			ret = -1;
+			continue;
 		}
 		if (fsetxattr (dst_fd, name, value, size, 0) != 0) {
 			if (errno == ENOTSUP)
libattr/attr_copy_file.c +2 -1
Index: attr-2.4.39/libattr/attr_copy_file.c
===================================================================
@@ -117,7 +117,7 @@ attr_copy_file(const char *src_path, con
 			quote_free (ctx, qname);
 			quote_free (ctx, qpath);
 			ret = -1;
-			continue;  /* may not have permission to access */
+			continue;
 		}
 		value = (char *) realloc (old_value = value, size);
 		if (size != 0 && value == NULL) {
@@ -134,6 +134,7 @@ attr_copy_file(const char *src_path, con
 			quote_free (ctx, qname);
 			quote_free (ctx, qpath);
 			ret = -1;
+			continue;
 		}
 		if (lsetxattr (dst_path, name, value, size, 0) != 0) {
 			if (errno == ENOTSUP)
libattr/attr_copy_check.c +1 -27
Index: attr-2.4.39/libattr/attr_copy_check.c
===================================================================
@@ -23,32 +23,6 @@
 int
 attr_copy_check_permissions(const char *name, struct error_context *ctx)
 {
-	/* Skip POSIX ACLs. */
-	if (strncmp(name, "system.posix_acl_", 17) == 0 &&
-	    (strcmp(name+17, "access") == 0 ||
-	     strcmp(name+17, "default") == 0))
-		return 0;
-
-	/* Skip permissions attributes which are used on IRIX, and
-	   hence are part of the XFS ondisk format (incl. ACLs).
-	   Also skip SGI DMF attributes as they are inappropriate
-	   targets for copying over as well. */
-	if (strncmp(name, "trusted.SGI_", 12) == 0 &&
-	    (strcmp(name+12, "ACL_DEFAULT") == 0 ||
-	     strcmp(name+12, "ACL_FILE") == 0 ||
-	     strcmp(name+12, "CAP_FILE") == 0 ||
-	     strcmp(name+12, "MAC_FILE") == 0 ||
-	     strncmp(name+12, "DMI_", 4) == 0))
-		return 0;
-
-	/* The xfsroot namespace mirrored attributes, some of which
-	   are also also available via the system.* and trusted.*
-	   namespaces.  To avoid the problems this would cause,
-	   we skip xfsroot altogether.
-	   Note: xfsroot namespace has now been removed from XFS. */
-	if (strncmp(name, "xfsroot.", 8) == 0)
-		return 0;
-
-	return 1;
+	return attr_copy_action(name, ctx) == 0;
 }
 
include/libattr.h +6 -1
Index: attr-2.4.39/include/libattr.h
===================================================================
@@ -14,9 +14,14 @@ extern int attr_copy_fd (const char *, i
 			 int (*) (const char *, struct error_context *),
 			 struct error_context *);
 
-/* The default check function used by attr_copy_{fd,file}. */
+/* Keep this function for backwards compatibility. */
 extern int attr_copy_check_permissions(const char *, struct error_context *);
 
+#define ATTR_ACTION_SKIP	1
+#define ATTR_ACTION_PERMISSIONS	2
+
+extern int attr_copy_action(const char *, struct error_context *);
+
 #ifdef __cplusplus
 }
 #endif