Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 4 Sep 2012 12:19:34 +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: r240087 - head/bin/setfacl
Message-ID:  <201209041219.q84CJYQK052737@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: trasz
Date: Tue Sep  4 12:19:34 2012
New Revision: 240087
URL: http://svn.freebsd.org/changeset/base/240087

Log:
  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

Modified:
  head/bin/setfacl/merge.c

Modified: head/bin/setfacl/merge.c
==============================================================================
--- head/bin/setfacl/merge.c	Tue Sep  4 12:07:33 2012	(r240086)
+++ head/bin/setfacl/merge.c	Tue Sep  4 12:19:34 2012	(r240087)
@@ -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.



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