summaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
authortrasz <trasz@FreeBSD.org>2009-12-26 10:06:45 +0000
committertrasz <trasz@FreeBSD.org>2009-12-26 10:06:45 +0000
commit0d8feb4153ecf50f763a2d1ce9074675cf68aae1 (patch)
tree69da4084dd7940b1bc884ce84515d2b52bc68da0 /bin
parente11fe899ea4c6f36c564e59d30a2d022dfb7f33c (diff)
downloadFreeBSD-src-0d8feb4153ecf50f763a2d1ce9074675cf68aae1.zip
FreeBSD-src-0d8feb4153ecf50f763a2d1ce9074675cf68aae1.tar.gz
Improve ACL branding mismatch detection and reporting in some rare cases,
such as "setfacl -m ''".
Diffstat (limited to 'bin')
-rw-r--r--bin/setfacl/merge.c10
-rw-r--r--bin/setfacl/remove.c5
-rw-r--r--bin/setfacl/setfacl.h2
-rw-r--r--bin/setfacl/util.c23
4 files changed, 32 insertions, 8 deletions
diff --git a/bin/setfacl/merge.c b/bin/setfacl/merge.c
index 495e66c..0a42eec 100644
--- a/bin/setfacl/merge.c
+++ b/bin/setfacl/merge.c
@@ -100,11 +100,10 @@ merge_acl(acl_t acl, acl_t *prev_acl, const char *filename)
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, acl_t *prev_acl, const char *filename)
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);
}
diff --git a/bin/setfacl/remove.c b/bin/setfacl/remove.c
index 6cd82b3..e6feef9 100644
--- a/bin/setfacl/remove.c
+++ b/bin/setfacl/remove.c
@@ -53,11 +53,10 @@ remove_acl(acl_t acl, acl_t *prev_acl, const char *filename)
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);
}
diff --git a/bin/setfacl/setfacl.h b/bin/setfacl/setfacl.h
index 7c11b3a..290ac5b 100644
--- a/bin/setfacl/setfacl.h
+++ b/bin/setfacl/setfacl.h
@@ -71,6 +71,8 @@ void remove_ext(acl_t *prev_acl, const char *filename);
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;
diff --git a/bin/setfacl/util.c b/bin/setfacl/util.c
index 46b9abb..3c42979 100644
--- a/bin/setfacl/util.c
+++ b/bin/setfacl/util.c
@@ -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);
+}
OpenPOWER on IntegriCloud