svn commit: r241187 - stable/9/bin/setfacl

Edward Tomasz Napierala trasz at FreeBSD.org
Thu Oct 4 08:52:19 UTC 2012


Author: trasz
Date: Thu Oct  4 08:47:05 2012
New Revision: 241187
URL: http://svn.freebsd.org/changeset/base/241187

Log:
  MFC r240087:
  
  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.

Modified:
  stable/9/bin/setfacl/merge.c
Directory Properties:
  stable/9/bin/setfacl/   (props changed)

Modified: stable/9/bin/setfacl/merge.c
==============================================================================
--- stable/9/bin/setfacl/merge.c	Thu Oct  4 08:43:49 2012	(r241186)
+++ stable/9/bin/setfacl/merge.c	Thu Oct  4 08:47:05 2012	(r241187)
@@ -94,7 +94,7 @@ merge_acl(acl_t acl, acl_t *prev_acl, co
 	acl_tag_t tag, tag_new;
 	acl_entry_type_t entry_type, entry_type_new;
 	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;
 
 	acl_get_brand_np(acl, &acl_brand);
@@ -116,6 +116,7 @@ merge_acl(acl_t acl, acl_t *prev_acl, co
 	while (acl_get_entry(acl, entry_id, &entry) == 1) {
 		entry_id = ACL_NEXT_ENTRY;
 		have_entry = 0;
+		had_entry = 0;
 
 		/* keep track of existing ACL_MASK entries */
 		if (acl_get_tag_type(entry, &tag) == -1)
@@ -187,7 +188,7 @@ merge_acl(acl_t acl, acl_t *prev_acl, co
 						err(1, "%s: acl_set_flagset_np() failed",
 						    filename);
 				}
-				have_entry = 1;
+				had_entry = have_entry = 1;
 				break;
 			default:
 				/* should never be here */
@@ -197,7 +198,7 @@ merge_acl(acl_t acl, acl_t *prev_acl, co
 		}
 
 		/* 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.


More information about the svn-src-stable-9 mailing list