1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-10-19 02:29:40 +00:00

Fix an error in setfacl(1) that manifested like this:

# setfacl -m u:trasz:rwx x
# setfacl -m u:root:rwx x
# getfacl x
# file: x
# owner: root
# group: wheel
user::rw-
user:root:rwx
user:trasz:rwx
group::r--
mask::rwx
other::r--
# setfacl -m u:root:rwx x
setfacl: x: acl_calc_mask() failed: Invalid argument
setfacl: x: failed to set ACL mask

For NFSv4 ACLs, this sort of situation would result in duplicated
entries.

MFC after:	1 month
This commit is contained in:
Edward Tomasz Napierala 2012-09-04 12:19:34 +00:00
parent 62208ca5d2
commit 6e924edbde
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=240087

View File

@ -94,7 +94,7 @@ merge_acl(acl_t acl, acl_t *prev_acl, const char *filename)
acl_tag_t tag, tag_new; acl_tag_t tag, tag_new;
acl_entry_type_t entry_type, entry_type_new; acl_entry_type_t entry_type, entry_type_new;
acl_flagset_t flagset; acl_flagset_t flagset;
int entry_id, entry_id_new, have_entry, entry_number = 0; int entry_id, entry_id_new, have_entry, had_entry, entry_number = 0;
int acl_brand, prev_acl_brand; int acl_brand, prev_acl_brand;
acl_get_brand_np(acl, &acl_brand); acl_get_brand_np(acl, &acl_brand);
@ -116,6 +116,7 @@ merge_acl(acl_t acl, acl_t *prev_acl, const char *filename)
while (acl_get_entry(acl, entry_id, &entry) == 1) { while (acl_get_entry(acl, entry_id, &entry) == 1) {
entry_id = ACL_NEXT_ENTRY; entry_id = ACL_NEXT_ENTRY;
have_entry = 0; have_entry = 0;
had_entry = 0;
/* keep track of existing ACL_MASK entries */ /* keep track of existing ACL_MASK entries */
if (acl_get_tag_type(entry, &tag) == -1) if (acl_get_tag_type(entry, &tag) == -1)
@ -187,7 +188,7 @@ merge_acl(acl_t acl, acl_t *prev_acl, const char *filename)
err(1, "%s: acl_set_flagset_np() failed", err(1, "%s: acl_set_flagset_np() failed",
filename); filename);
} }
have_entry = 1; had_entry = have_entry = 1;
break; break;
default: default:
/* should never be here */ /* should never be here */
@ -197,7 +198,7 @@ merge_acl(acl_t acl, acl_t *prev_acl, const char *filename)
} }
/* if this entry has not been found, it must be new */ /* if this entry has not been found, it must be new */
if (have_entry == 0) { if (had_entry == 0) {
/* /*
* NFSv4 ACL entries must be prepended to the ACL. * NFSv4 ACL entries must be prepended to the ACL.