Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Dec 2009 10:06:45 +0000 (UTC)
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r201016 - head/bin/setfacl
Message-ID:  <200912261006.nBQA6jwt003542@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Sat Dec 26 10:06:45 2009
New Revision: 201016
URL: http://svn.freebsd.org/changeset/base/201016

Log:
  Improve ACL branding mismatch detection and reporting in some rare cases,
  such as "setfacl -m ''".

Modified:
  head/bin/setfacl/merge.c
  head/bin/setfacl/remove.c
  head/bin/setfacl/setfacl.h
  head/bin/setfacl/util.c

Modified: head/bin/setfacl/merge.c
==============================================================================
--- head/bin/setfacl/merge.c	Sat Dec 26 08:36:02 2009	(r201015)
+++ head/bin/setfacl/merge.c	Sat Dec 26 10:06:45 2009	(r201016)
@@ -100,11 +100,10 @@ merge_acl(acl_t acl, acl_t *prev_acl, co
 	acl_get_brand_np(acl, &acl_brand);
 	acl_get_brand_np(*prev_acl, &prev_acl_brand);
 
-	if (acl_brand != prev_acl_brand) {
+	if (branding_mismatch(acl_brand, prev_acl_brand)) {
 		warnx("%s: branding mismatch; existing ACL is %s, "
 		    "entry to be merged is %s", filename,
-		    prev_acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e",
-		    acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e");
+		    brand_name(prev_acl_brand), brand_name(acl_brand));
 		return (-1);
 	}
 
@@ -252,9 +251,10 @@ add_acl(acl_t acl, uint entry_number, ac
 		return (-1);
 	}
 
-	if (acl_brand != ACL_BRAND_NFS4) {
+	if (branding_mismatch(acl_brand, ACL_BRAND_NFS4)) {
 		warnx("%s: branding mismatch; existing ACL is NFSv4, "
-		    "entry to be added is POSIX.1e", filename);
+		    "entry to be added is %s", filename,
+		    brand_name(acl_brand));
 		return (-1);
 	}
 

Modified: head/bin/setfacl/remove.c
==============================================================================
--- head/bin/setfacl/remove.c	Sat Dec 26 08:36:02 2009	(r201015)
+++ head/bin/setfacl/remove.c	Sat Dec 26 10:06:45 2009	(r201016)
@@ -53,11 +53,10 @@ remove_acl(acl_t acl, acl_t *prev_acl, c
 	acl_get_brand_np(acl, &acl_brand);
 	acl_get_brand_np(*prev_acl, &prev_acl_brand);
 
-	if (acl_brand != prev_acl_brand) {
+	if (branding_mismatch(acl_brand, prev_acl_brand)) {
 		warnx("%s: branding mismatch; existing ACL is %s, "
 		    "entry to be removed is %s", filename,
-		    prev_acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e",
-		    acl_brand == ACL_BRAND_NFS4 ? "NFSv4" : "POSIX.1e");
+		    brand_name(prev_acl_brand), brand_name(acl_brand));
 		return (-1);
 	}
 

Modified: head/bin/setfacl/setfacl.h
==============================================================================
--- head/bin/setfacl/setfacl.h	Sat Dec 26 08:36:02 2009	(r201015)
+++ head/bin/setfacl/setfacl.h	Sat Dec 26 10:06:45 2009	(r201016)
@@ -71,6 +71,8 @@ void   remove_ext(acl_t *prev_acl, const
 int    set_acl_mask(acl_t *prev_acl, const char *filename);
 /* util.c */
 void  *zmalloc(size_t size);
+const char *brand_name(int brand);
+int    branding_mismatch(int brand1, int brand2);
 
 uint       have_mask;
 uint       need_mask;

Modified: head/bin/setfacl/util.c
==============================================================================
--- head/bin/setfacl/util.c	Sat Dec 26 08:36:02 2009	(r201015)
+++ head/bin/setfacl/util.c	Sat Dec 26 10:06:45 2009	(r201016)
@@ -43,3 +43,26 @@ zmalloc(size_t size)
 		err(1, "calloc() failed");
 	return (ptr);
 }
+
+const char *
+brand_name(int brand)
+{
+	switch (brand) {
+	case ACL_BRAND_NFS4:
+		return "NFSv4";
+	case ACL_BRAND_POSIX:
+		return "POSIX.1e";
+	default:
+		return "unknown";
+	}
+}
+
+int
+branding_mismatch(int brand1, int brand2)
+{
+	if (brand1 == ACL_BRAND_UNKNOWN || brand2 == ACL_BRAND_UNKNOWN)
+		return (0);
+	if (brand1 != brand2)
+		return (1);
+	return (1);
+}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200912261006.nBQA6jwt003542>