eab3d9
diff -up rsync-3.1.2/exclude.c.orig rsync-3.1.2/exclude.c
eab3d9
--- rsync-3.1.2/exclude.c.orig	2018-09-27 17:06:15.413701320 -0300
eab3d9
+++ rsync-3.1.2/exclude.c	2018-09-27 17:06:19.259579122 -0300
eab3d9
@@ -44,6 +44,8 @@ filter_rule_list filter_list = { .debug_
eab3d9
 filter_rule_list cvs_filter_list = { .debug_type = " [global CVS]" };
eab3d9
 filter_rule_list daemon_filter_list = { .debug_type = " [daemon]" };
eab3d9
 
eab3d9
+int saw_xattr_filter = 0;
eab3d9
+
eab3d9
 /* Need room enough for ":MODS " prefix plus some room to grow. */
eab3d9
 #define MAX_RULE_PREFIX (16)
eab3d9
 
eab3d9
@@ -622,7 +624,7 @@ void change_local_filter_dir(const char
eab3d9
 	filt_array[cur_depth] = push_local_filters(dname, dlen);
eab3d9
 }
eab3d9
 
eab3d9
-static int rule_matches(const char *fname, filter_rule *ex, int name_is_dir)
eab3d9
+static int rule_matches(const char *fname, filter_rule *ex, int name_flags)
eab3d9
 {
eab3d9
 	int slash_handling, str_cnt = 0, anchored_match = 0;
eab3d9
 	int ret_match = ex->rflags & FILTRULE_NEGATE ? 0 : 1;
eab3d9
@@ -633,6 +635,9 @@ static int rule_matches(const char *fnam
eab3d9
 	if (!*name)
eab3d9
 		return 0;
eab3d9
 
eab3d9
+	if (!(name_flags & NAME_IS_XATTR) ^ !(ex->rflags & FILTRULE_XATTR))
eab3d9
+		return 0;
eab3d9
+
eab3d9
 	if (!ex->u.slash_cnt && !(ex->rflags & FILTRULE_WILD2)) {
eab3d9
 		/* If the pattern does not have any slashes AND it does
eab3d9
 		 * not have a "**" (which could match a slash), then we
eab3d9
@@ -650,7 +655,7 @@ static int rule_matches(const char *fnam
eab3d9
 		strings[str_cnt++] = "/";
eab3d9
 	}
eab3d9
 	strings[str_cnt++] = name;
eab3d9
-	if (name_is_dir) {
eab3d9
+	if (name_flags & NAME_IS_DIR) {
eab3d9
 		/* Allow a trailing "/"+"***" to match the directory. */
eab3d9
 		if (ex->rflags & FILTRULE_WILD3_SUFFIX)
eab3d9
 			strings[str_cnt++] = "/";
eab3d9
@@ -702,7 +707,7 @@ static int rule_matches(const char *fnam
eab3d9
 
eab3d9
 static void report_filter_result(enum logcode code, char const *name,
eab3d9
 				 filter_rule const *ent,
eab3d9
-				 int name_is_dir, const char *type)
eab3d9
+				 int name_flags, const char *type)
eab3d9
 {
eab3d9
 	/* If a trailing slash is present to match only directories,
eab3d9
 	 * then it is stripped out by add_rule().  So as a special
eab3d9
@@ -712,17 +717,40 @@ static void report_filter_result(enum lo
eab3d9
 		static char *actions[2][2]
eab3d9
 		    = { {"show", "hid"}, {"risk", "protect"} };
eab3d9
 		const char *w = who_am_i();
eab3d9
+		const char *t = name_flags & NAME_IS_XATTR ? "xattr"
eab3d9
+			      : name_flags & NAME_IS_DIR ? "directory"
eab3d9
+			      : "file";
eab3d9
 		rprintf(code, "[%s] %sing %s %s because of pattern %s%s%s\n",
eab3d9
 		    w, actions[*w!='s'][!(ent->rflags & FILTRULE_INCLUDE)],
eab3d9
-		    name_is_dir ? "directory" : "file", name, ent->pattern,
eab3d9
+		    t, name, ent->pattern,
eab3d9
 		    ent->rflags & FILTRULE_DIRECTORY ? "/" : "", type);
eab3d9
 	}
eab3d9
 }
eab3d9
 
eab3d9
+/* This function is used to check if a file should be included/excluded
eab3d9
+ * from the list of files based on its name and type etc.  The value of
eab3d9
+ * filter_level is set to either SERVER_FILTERS or ALL_FILTERS. */
eab3d9
+int name_is_excluded(const char *fname, int name_flags, int filter_level)
eab3d9
+{
eab3d9
+	if (daemon_filter_list.head && check_filter(&daemon_filter_list, FLOG, fname, name_flags) < 0) {
eab3d9
+		if (!(name_flags & NAME_IS_XATTR))
eab3d9
+			errno = ENOENT;
eab3d9
+		return 1;
eab3d9
+	}
eab3d9
+
eab3d9
+	if (filter_level != ALL_FILTERS)
eab3d9
+		return 0;
eab3d9
+
eab3d9
+	if (filter_list.head && check_filter(&filter_list, FINFO, fname, name_flags) < 0)
eab3d9
+		return 1;
eab3d9
+
eab3d9
+	return 0;
eab3d9
+}
eab3d9
+
eab3d9
 /* Return -1 if file "name" is defined to be excluded by the specified
eab3d9
  * exclude list, 1 if it is included, and 0 if it was not matched. */
eab3d9
 int check_filter(filter_rule_list *listp, enum logcode code,
eab3d9
-		 const char *name, int name_is_dir)
eab3d9
+		 const char *name, int name_flags)
eab3d9
 {
eab3d9
 	filter_rule *ent;
eab3d9
 
eab3d9
@@ -730,22 +758,19 @@ int check_filter(filter_rule_list *listp
eab3d9
 		if (ignore_perishable && ent->rflags & FILTRULE_PERISHABLE)
eab3d9
 			continue;
eab3d9
 		if (ent->rflags & FILTRULE_PERDIR_MERGE) {
eab3d9
-			int rc = check_filter(ent->u.mergelist, code, name,
eab3d9
-					      name_is_dir);
eab3d9
+			int rc = check_filter(ent->u.mergelist, code, name, name_flags);
eab3d9
 			if (rc)
eab3d9
 				return rc;
eab3d9
 			continue;
eab3d9
 		}
eab3d9
 		if (ent->rflags & FILTRULE_CVS_IGNORE) {
eab3d9
-			int rc = check_filter(&cvs_filter_list, code, name,
eab3d9
-					      name_is_dir);
eab3d9
+			int rc = check_filter(&cvs_filter_list, code, name, name_flags);
eab3d9
 			if (rc)
eab3d9
 				return rc;
eab3d9
 			continue;
eab3d9
 		}
eab3d9
-		if (rule_matches(name, ent, name_is_dir)) {
eab3d9
-			report_filter_result(code, name, ent, name_is_dir,
eab3d9
-					     listp->debug_type);
eab3d9
+		if (rule_matches(name, ent, name_flags)) {
eab3d9
+			report_filter_result(code, name, ent, name_flags, listp->debug_type);
eab3d9
 			return ent->rflags & FILTRULE_INCLUDE ? 1 : -1;
eab3d9
 		}
eab3d9
 	}
eab3d9
@@ -970,6 +995,10 @@ static filter_rule *parse_rule_tok(const
eab3d9
 					goto invalid;
eab3d9
 				rule->rflags |= FILTRULE_WORD_SPLIT;
eab3d9
 				break;
eab3d9
+			case 'x':
eab3d9
+				rule->rflags |= FILTRULE_XATTR;
eab3d9
+				saw_xattr_filter = 1;
eab3d9
+				break;
eab3d9
 			}
eab3d9
 		}
eab3d9
 		if (*s)
eab3d9
@@ -1286,6 +1286,8 @@ char *get_rule_prefix(filter_rule *rule, const char *pat, int for_xfer,
eab3d9
 	}
eab3d9
 	if (rule->rflags & FILTRULE_EXCLUDE_SELF)
eab3d9
 		*op++ = 'e';
eab3d9
+	if (rule->rflags & FILTRULE_XATTR)
eab3d9
+		*op++ = 'x';
eab3d9
 	if (rule->rflags & FILTRULE_SENDER_SIDE
eab3d9
 	    && (!for_xfer || protocol_version >= 29))
eab3d9
 		*op++ = 's';
eab3d9
diff -up rsync-3.1.2/flist.c.orig rsync-3.1.2/flist.c
eab3d9
--- rsync-3.1.2/flist.c.orig	2018-09-27 17:06:15.420701098 -0300
eab3d9
+++ rsync-3.1.2/flist.c	2018-09-27 17:06:19.262579026 -0300
eab3d9
@@ -237,16 +237,6 @@ int link_stat(const char *path, STRUCT_S
eab3d9
 #endif
eab3d9
 }
eab3d9
 
eab3d9
-static inline int is_daemon_excluded(const char *fname, int is_dir)
eab3d9
-{
eab3d9
-	if (daemon_filter_list.head
eab3d9
-	 && check_filter(&daemon_filter_list, FLOG, fname, is_dir) < 0) {
eab3d9
-		errno = ENOENT;
eab3d9
-		return 1;
eab3d9
-	}
eab3d9
-	return 0;
eab3d9
-}
eab3d9
-
eab3d9
 static inline int path_is_daemon_excluded(char *path, int ignore_filename)
eab3d9
 {
eab3d9
 	if (daemon_filter_list.head) {
eab3d9
@@ -273,23 +263,10 @@ static inline int path_is_daemon_exclude
eab3d9
 	return 0;
eab3d9
 }
eab3d9
 
eab3d9
-/* This function is used to check if a file should be included/excluded
eab3d9
- * from the list of files based on its name and type etc.  The value of
eab3d9
- * filter_level is set to either SERVER_FILTERS or ALL_FILTERS. */
eab3d9
-static int is_excluded(const char *fname, int is_dir, int filter_level)
eab3d9
+
eab3d9
+static inline int is_excluded(const char *fname, int is_dir, int filter_level)
eab3d9
 {
eab3d9
-#if 0 /* This currently never happens, so avoid a useless compare. */
eab3d9
-	if (filter_level == NO_FILTERS)
eab3d9
-		return 0;
eab3d9
-#endif
eab3d9
-	if (is_daemon_excluded(fname, is_dir))
eab3d9
-		return 1;
eab3d9
-	if (filter_level != ALL_FILTERS)
eab3d9
-		return 0;
eab3d9
-	if (filter_list.head
eab3d9
-	    && check_filter(&filter_list, FINFO, fname, is_dir) < 0)
eab3d9
-		return 1;
eab3d9
-	return 0;
eab3d9
+	return name_is_excluded(fname, is_dir ? NAME_IS_DIR : NAME_IS_FILE, filter_level);
eab3d9
 }
eab3d9
 
eab3d9
 static void send_directory(int f, struct file_list *flist,
eab3d9
@@ -2262,7 +2239,7 @@ struct file_list *send_file_list(int f,
eab3d9
 			memmove(fbuf, fn, len + 1);
eab3d9
 
eab3d9
 		if (link_stat(fbuf, &st, copy_dirlinks || name_type != NORMAL_NAME) != 0
eab3d9
-		 || (name_type != DOTDIR_NAME && is_daemon_excluded(fbuf, S_ISDIR(st.st_mode)))
eab3d9
+		 || (name_type != DOTDIR_NAME && is_excluded(fbuf, S_ISDIR(st.st_mode) != 0, SERVER_FILTERS))
eab3d9
 		 || (relative_paths && path_is_daemon_excluded(fbuf, 1))) {
eab3d9
 			if (errno != ENOENT || missing_args == 0) {
eab3d9
 				/* This is a transfer error, but inhibit deletion
eab3d9
diff -up rsync-3.1.2/rsync.h.orig rsync-3.1.2/rsync.h
eab3d9
--- rsync-3.1.2/rsync.h.orig	2018-09-27 17:06:15.426700907 -0300
eab3d9
+++ rsync-3.1.2/rsync.h	2018-09-27 17:06:19.263578995 -0300
eab3d9
@@ -856,6 +856,10 @@ struct map_struct {
eab3d9
 	int status;		/* first errno from read errors		*/
eab3d9
 };
eab3d9
 
eab3d9
+#define NAME_IS_FILE		(0)    /* filter name as a file */
eab3d9
+#define NAME_IS_DIR		(1<<0) /* filter name as a dir */
eab3d9
+#define NAME_IS_XATTR		(1<<2) /* filter name as an xattr */
eab3d9
+
eab3d9
 #define FILTRULE_WILD		(1<<0) /* pattern has '*', '[', and/or '?' */
eab3d9
 #define FILTRULE_WILD2		(1<<1) /* pattern has '**' */
eab3d9
 #define FILTRULE_WILD2_PREFIX	(1<<2) /* pattern starts with "**" */
eab3d9
@@ -876,6 +880,7 @@ struct map_struct {
eab3d9
 #define FILTRULE_RECEIVER_SIDE	(1<<17)/* rule applies to the receiving side */
eab3d9
 #define FILTRULE_CLEAR_LIST	(1<<18)/* this item is the "!" token */
eab3d9
 #define FILTRULE_PERISHABLE	(1<<19)/* perishable if parent dir goes away */
eab3d9
+#define FILTRULE_XATTR		(1<<20)/* rule only applies to xattr names */
eab3d9
 
eab3d9
 #define FILTRULES_SIDES (FILTRULE_SENDER_SIDE | FILTRULE_RECEIVER_SIDE)
eab3d9
 
eab3d9
diff -up rsync-3.1.2/rsync.yo.orig rsync-3.1.2/rsync.yo
eab3d9
--- rsync-3.1.2/rsync.yo.orig	2018-09-27 17:06:15.433700685 -0300
eab3d9
+++ rsync-3.1.2/rsync.yo	2018-09-27 17:06:19.266578899 -0300
eab3d9
@@ -1109,9 +1109,27 @@ super-user copies all namespaces except
eab3d9
 the user.* namespace.  To be able to backup and restore non-user namespaces as
eab3d9
 a normal user, see the bf(--fake-super) option.
eab3d9
 
eab3d9
-Note that this option does not copy rsyncs special xattr values (e.g. those
eab3d9
-used by bf(--fake-super)) unless you repeat the option (e.g. -XX).  This
eab3d9
-"copy all xattrs" mode cannot be used with bf(--fake-super).
eab3d9
+The above name filtering can be overridden by using one or more filter options
eab3d9
+with the bf(x) modifier. When you specify an xattr-affecting filter rule, rsync
eab3d9
+requires that you do your own system/user filtering, as well as any additional
eab3d9
+filtering for what xattr names are copied and what names are allowed to be
eab3d9
+deleted.  For example, to skip the system namespace, you could specify:
eab3d9
+
eab3d9
+quote(--filter='-x system.*')
eab3d9
+
eab3d9
+To skip all namespaces except the user namespace, you could specify a
eab3d9
+negated-user match:
eab3d9
+
eab3d9
+quote(--filter='-x! user.*')
eab3d9
+
eab3d9
+To prevent any attributes from being deleted, you could specify a receiver-only
eab3d9
+rule that excludes all names:
eab3d9
+
eab3d9
+quote(--filter='-xr *')
eab3d9
+
eab3d9
+Note that the bf(-X) option does not copy rsync's special xattr values (e.g.
eab3d9
+those used by bf(--fake-super)) unless you repeat the option (e.g. -XX).
eab3d9
+This "copy all xattrs" mode cannot be used with bf(--fake-super).
eab3d9
 
eab3d9
 dit(bf(--chmod)) This option tells rsync to apply one or more
eab3d9
 comma-separated "chmod" modes to the permission of the files in the
eab3d9
@@ -2890,6 +2908,10 @@ itemization(
eab3d9
   option's default rules that exclude things like "CVS" and "*.o" are
eab3d9
   marked as perishable, and will not prevent a directory that was removed
eab3d9
   on the source from being deleted on the destination.
eab3d9
+  it() An bf(x) indicates that a rule affects xattr names in xattr copy/delete
eab3d9
+  operations (and is thus ignored when matching file/dir names). If no
eab3d9
+  xattr-matching rules are specified, a default xattr filtering rule is
eab3d9
+  used (see the bf(--xattrs) option).
eab3d9
 )
eab3d9
 
eab3d9
 manpagesection(MERGE-FILE FILTER RULES)
eab3d9
diff -up rsync-3.1.2/testsuite/xattrs.test.orig rsync-3.1.2/testsuite/xattrs.test
eab3d9
--- rsync-3.1.2/testsuite/xattrs.test.orig	2018-09-27 17:06:15.439700494 -0300
eab3d9
+++ rsync-3.1.2/testsuite/xattrs.test	2018-09-27 17:06:19.267578867 -0300
eab3d9
@@ -127,8 +127,10 @@ esac
eab3d9
 
eab3d9
 xls $dirs $files >"$scratchdir/xattrs.txt"
eab3d9
 
eab3d9
+XFILT='-f-x_system.* -f-x_security.*'
eab3d9
+
eab3d9
 # OK, let's try a simple xattr copy.
eab3d9
-checkit "$RSYNC -avX $dashH --super . '$chkdir/'" "$fromdir" "$chkdir"
eab3d9
+checkit "$RSYNC -avX $XFILT $dashH --super . '$chkdir/'" "$fromdir" "$chkdir"
eab3d9
 
eab3d9
 cd "$chkdir"
eab3d9
 xls $dirs $files | diff $diffopt "$scratchdir/xattrs.txt" -
eab3d9
@@ -142,7 +144,7 @@ if [ "$dashH" ]; then
eab3d9
     done
eab3d9
 fi
eab3d9
 
eab3d9
-checkit "$RSYNC -aiX $dashH --super $altDest=../chk . ../to" "$fromdir" "$todir"
eab3d9
+checkit "$RSYNC -aiX $XFILT $dashH --super $altDest=../chk . ../to" "$fromdir" "$todir"
eab3d9
 
eab3d9
 cd "$todir"
eab3d9
 xls $dirs $files | diff $diffopt "$scratchdir/xattrs.txt" -
eab3d9
@@ -156,7 +158,7 @@ xset user.nice 'this is nice, but differ
eab3d9
 
eab3d9
 xls $dirs $files >"$scratchdir/xattrs.txt"
eab3d9
 
eab3d9
-checkit "$RSYNC -aiX $dashH --fake-super --link-dest=../chk . ../to" "$chkdir" "$todir"
eab3d9
+checkit "$RSYNC -aiX $XFILT $dashH --fake-super --link-dest=../chk . ../to" "$chkdir" "$todir"
eab3d9
 
eab3d9
 cd "$todir"
eab3d9
 xls $dirs $files | diff $diffopt "$scratchdir/xattrs.txt" -
eab3d9
@@ -186,7 +188,7 @@ cd "$fromdir"
eab3d9
 rm -rf "$todir"
eab3d9
 
eab3d9
 # When run by a non-root tester, this checks if no-user-perm files/dirs can be copied.
eab3d9
-checkit "$RSYNC -aiX $dashH --fake-super --chmod=a= . ../to" "$chkdir" "$todir" # 2>"$scratchdir/errors.txt"
eab3d9
+checkit "$RSYNC -aiX $XFILT $dashH --fake-super --chmod=a= . ../to" "$chkdir" "$todir" # 2>"$scratchdir/errors.txt"
eab3d9
 
eab3d9
 cd "$todir"
eab3d9
 xls $dirs $files | diff $diffopt "$scratchdir/xattrs.txt" -
eab3d9
@@ -202,7 +204,7 @@ $RSYNC -aX file1 ../lnk/
eab3d9
 
eab3d9
 xls file1 file2 >"$scratchdir/xattrs.txt"
eab3d9
 
eab3d9
-checkit "$RSYNC -aiiX $dashH $altDest=../lnk . ../to" "$chkdir" "$todir"
eab3d9
+checkit "$RSYNC -aiiX $XFILT $dashH $altDest=../lnk . ../to" "$chkdir" "$todir"
eab3d9
 
eab3d9
 [ "$dashH" ] && rm ../lnk/extra-link
eab3d9
 
eab3d9
@@ -215,7 +217,7 @@ rm "$todir/file2"
eab3d9
 echo extra >file1
eab3d9
 $RSYNC -aX . ../chk/
eab3d9
 
eab3d9
-checkit "$RSYNC -aiiX . ../to" "$chkdir" "$todir"
eab3d9
+checkit "$RSYNC -aiiX $XFILT . ../to" "$chkdir" "$todir"
eab3d9
 
eab3d9
 cd "$todir"
eab3d9
 xls file1 file2 | diff $diffopt "$scratchdir/xattrs.txt" -
eab3d9
diff -up rsync-3.1.2/xattrs.c.orig rsync-3.1.2/xattrs.c
eab3d9
--- rsync-3.1.2/xattrs.c.orig	2018-09-27 17:06:15.442700399 -0300
eab3d9
+++ rsync-3.1.2/xattrs.c	2018-09-27 17:07:50.900667319 -0300
eab3d9
@@ -39,6 +39,7 @@ extern int preserve_devices;
eab3d9
 extern int preserve_specials;
eab3d9
 extern int checksum_seed;
eab3d9
 extern int protocol_version;
eab3d9
+extern int saw_xattr_filter;
eab3d9
 
eab3d9
 #define RSYNC_XAL_INITIAL 5
eab3d9
 #define RSYNC_XAL_LIST_INITIAL 100
eab3d9
@@ -234,11 +235,14 @@ static int rsync_xal_get(const char *fna
eab3d9
 		name_len = strlen(name) + 1;
eab3d9
 		list_len -= name_len;
eab3d9
 
eab3d9
+		if (saw_xattr_filter) {
eab3d9
+			if (name_is_excluded(name, NAME_IS_XATTR, ALL_FILTERS))
eab3d9
+				continue;
eab3d9
+		}
eab3d9
 #ifdef HAVE_LINUX_XATTRS
eab3d9
 		/* We always ignore the system namespace, and non-root
eab3d9
 		 * ignores everything but the user namespace. */
eab3d9
-		if (user_only ? !HAS_PREFIX(name, USER_PREFIX)
eab3d9
-			      : HAS_PREFIX(name, SYSTEM_PREFIX))
eab3d9
+		else if (user_only ? !HAS_PREFIX(name, USER_PREFIX) : HAS_PREFIX(name, SYSTEM_PREFIX))
eab3d9
 			continue;
eab3d9
 #endif
eab3d9
 
eab3d9
@@ -337,11 +341,14 @@ int copy_xattrs(const char *source, cons
eab3d9
 		name_len = strlen(name) + 1;
eab3d9
 		list_len -= name_len;
eab3d9
 
eab3d9
+		if (saw_xattr_filter) {
eab3d9
+			if (name_is_excluded(name, NAME_IS_XATTR, ALL_FILTERS))
eab3d9
+				continue;
eab3d9
+		}
eab3d9
 #ifdef HAVE_LINUX_XATTRS
eab3d9
 		/* We always ignore the system namespace, and non-root
eab3d9
 		 * ignores everything but the user namespace. */
eab3d9
-		if (user_only ? !HAS_PREFIX(name, USER_PREFIX)
eab3d9
-			      : HAS_PREFIX(name, SYSTEM_PREFIX))
eab3d9
+		else if (user_only ? !HAS_PREFIX(name, USER_PREFIX) : HAS_PREFIX(name, SYSTEM_PREFIX))
eab3d9
 			continue;
eab3d9
 #endif
eab3d9
 
eab3d9
@@ -735,10 +742,17 @@ void receive_xattr(int f, struct file_st
eab3d9
 			*ptr = XSTATE_ABBREV;
eab3d9
 			read_buf(f, ptr + 1, MAX_DIGEST_LEN);
eab3d9
 		}
eab3d9
+
eab3d9
+		if (saw_xattr_filter) {
eab3d9
+			if (name_is_excluded(name, NAME_IS_XATTR, ALL_FILTERS)) {
eab3d9
+				free(ptr);
eab3d9
+				continue;
eab3d9
+			}
eab3d9
+		}
eab3d9
 #ifdef HAVE_LINUX_XATTRS
eab3d9
 		/* Non-root can only save the user namespace. */
eab3d9
 		if (am_root <= 0 && !HAS_PREFIX(name, USER_PREFIX)) {
eab3d9
-			if (!am_root) {
eab3d9
+			if (!am_root && !saw_xattr_filter) {
eab3d9
 				free(ptr);
eab3d9
 				continue;
eab3d9
 			}
eab3d9
@@ -899,11 +913,14 @@ static int rsync_xal_set(const char *fna
eab3d9
 		name_len = strlen(name) + 1;
eab3d9
 		list_len -= name_len;
eab3d9
 
eab3d9
+		if (saw_xattr_filter) {
eab3d9
+			if (name_is_excluded(name, NAME_IS_XATTR, ALL_FILTERS))
eab3d9
+				continue;
eab3d9
+		}
eab3d9
 #ifdef HAVE_LINUX_XATTRS
eab3d9
 		/* We always ignore the system namespace, and non-root
eab3d9
 		 * ignores everything but the user namespace. */
eab3d9
-		if (user_only ? !HAS_PREFIX(name, USER_PREFIX)
eab3d9
-			      : HAS_PREFIX(name, SYSTEM_PREFIX))
eab3d9
+		else if (user_only ? !HAS_PREFIX(name, USER_PREFIX) : HAS_PREFIX(name, SYSTEM_PREFIX))
eab3d9
 			continue;
eab3d9
 #endif
eab3d9
 		if (am_root < 0 && name_len > RPRE_LEN