static void compare_entry_acls(struct archive_entry *ae, struct myacl_t *myacls, const char *filename, int start, int end) { int *marker; int matched; int i, n; int type, permset, tag, qual; const char *name; /* Count ACL entries in myacls array and allocate an indirect array. */ n = end - start; marker = malloc(sizeof(marker[0]) * (n + 1)); for (i = 0; i < n; i++) marker[i] = i + start; /* Always include the first ACE. */ if (start > 0) { marker[n] = 0; ++n; } /* * Iterate over acls in entry, try to match each * one with an item in the myacls array. */ assertEqualInt(n, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4)); while (ARCHIVE_OK == archive_entry_acl_next(ae, ARCHIVE_ENTRY_ACL_TYPE_NFS4, &type, &permset, &tag, &qual, &name)) { /* Search for a matching entry (tag and qualifier) */ for (i = 0, matched = 0; i < n && !matched; i++) { if (tag == myacls[marker[i]].tag && qual == myacls[marker[i]].qual && permset == myacls[marker[i]].permset && type == myacls[marker[i]].type) { /* We found a match; remove it. */ marker[i] = marker[n - 1]; n--; matched = 1; } } failure("ACL entry on file that shouldn't be there: " "type=%#010x,permset=%#010x,tag=%d,qual=%d", type,permset,tag,qual); assert(matched == 1); } /* Dump entries in the myacls array that weren't in the system acl. */ for (i = 0; i < n; ++i) { failure(" ACL entry %d missing from %s: " "type=%#010x,permset=%#010x,tag=%d,qual=%d,name=``%s''\n", marker[i], filename, myacls[marker[i]].type, myacls[marker[i]].permset, myacls[marker[i]].tag, myacls[marker[i]].qual, myacls[marker[i]].name); assert(0); /* Record this as a failure. */ } free(marker); }
static void compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode) { int *marker = malloc(sizeof(marker[0]) * n); int i; int r; int type, permset, tag, qual; int matched; const char *name; for (i = 0; i < n; i++) marker[i] = i; while (0 == (r = archive_entry_acl_next(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS, &type, &permset, &tag, &qual, &name))) { for (i = 0, matched = 0; i < n && !matched; i++) { if (acl_match(&acls[marker[i]], type, permset, tag, qual, name)) { /* We found a match; remove it. */ marker[i] = marker[n - 1]; n--; matched = 1; } } if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) { if (!matched) printf("No match for user_obj perm\n"); failure("USER_OBJ permset (%02o) != user mode (%02o)", permset, 07 & (mode >> 6)); assert((permset << 6) == (mode & 0700)); } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) { if (!matched) printf("No match for group_obj perm\n"); failure("GROUP_OBJ permset %02o != group mode %02o", permset, 07 & (mode >> 3)); assert((permset << 3) == (mode & 0070)); } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) {