Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Aug 2008 17:07:30 GMT
From:      Edward Tomasz Napierala <trasz@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 147313 for review
Message-ID:  <200808131707.m7DH7Uav077422@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=147313

Change 147313 by trasz@trasz_traszkan on 2008/08/13 17:07:01

	Merging (setfacl -m) and removing (setfacl -x) should affect all
	the matching entries, not just the first one.

Affected files ...

.. //depot/projects/soc2008/trasz_nfs4acl/bin/setfacl/merge.c#8 edit
.. //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_delete_entry.c#6 edit

Differences ...

==== //depot/projects/soc2008/trasz_nfs4acl/bin/setfacl/merge.c#8 (text+ko) ====

@@ -129,8 +129,7 @@
 
 		/* check against the existing ACL entries */
 		entry_id_new = ACL_FIRST_ENTRY;
-		while (have_entry == 0 &&
-		    acl_get_entry(acl_new, entry_id_new, &entry_new) == 1) {
+		while (acl_get_entry(acl_new, entry_id_new, &entry_new) == 1) {
 			entry_id_new = ACL_NEXT_ENTRY;
 
 			if (acl_get_tag_type(entry, &tag) == -1)

==== //depot/projects/soc2008/trasz_nfs4acl/lib/libc/posix1e/acl_delete_entry.c#6 (text+ko) ====

@@ -77,7 +77,7 @@
 acl_delete_entry(acl_t acl, acl_entry_t entry_d)
 {
 	struct acl *acl_int;
-	int i, found = 0;
+	int i, j, found = 0;
 
 	if (acl == NULL || entry_d == NULL) {
 		errno = EINVAL;
@@ -96,21 +96,22 @@
 		errno = EINVAL;
 		return (-1);
 	}
-	for (i = 0; i < acl->ats_acl.acl_cnt; i++) {
+	for (i = 0; i < acl->ats_acl.acl_cnt;) {
 		if (_entry_matches(&(acl->ats_acl.acl_entry[i]), entry_d)) {
 			/* ...shift the remaining entries... */
-			for (; i < acl->ats_acl.acl_cnt - 1; ++i)
-				acl->ats_acl.acl_entry[i] =
-				    acl->ats_acl.acl_entry[i+1];
+			for (j = i; j < acl->ats_acl.acl_cnt - 1; ++j)
+				acl->ats_acl.acl_entry[j] =
+				    acl->ats_acl.acl_entry[j+1];
 			/* ...drop the count and zero the unused entry... */
 			acl->ats_acl.acl_cnt--;
-			bzero(&acl->ats_acl.acl_entry[i],
+			bzero(&acl->ats_acl.acl_entry[j],
 			    sizeof(struct acl_entry));
 			acl->ats_cur_entry = 0;
 			
 			/* Continue with the loop to remove all maching entries. */
 			found = 1;
-		}
+		} else
+			i++;
 	}
 
 	if (found)



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