test_acl_posix1e.c (313570) | test_acl_posix1e.c (315432) |
---|---|
1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 102 unchanged lines hidden (view full) --- 111 112 /* 113 * Note: This features of libarchive's ACL implementation 114 * shouldn't be relied on and should probably be removed. It 115 * was done to identify trivial ACLs so we could avoid 116 * triggering unnecessary extensions. It's better to identify 117 * trivial ACLs at the point they are being read from disk. 118 */ | 1/*- 2 * Copyright (c) 2003-2007 Tim Kientzle 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 102 unchanged lines hidden (view full) --- 111 112 /* 113 * Note: This features of libarchive's ACL implementation 114 * shouldn't be relied on and should probably be removed. It 115 * was done to identify trivial ACLs so we could avoid 116 * triggering unnecessary extensions. It's better to identify 117 * trivial ACLs at the point they are being read from disk. 118 */ |
119 archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); | 119 assertEntrySetAcls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); |
120 failure("Basic ACLs shouldn't be stored as extended ACLs"); 121 assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 122 failure("Basic ACLs should set mode to 0142, not %04o", 123 archive_entry_mode(ae)&0777); 124 assert((archive_entry_mode(ae) & 0777) == 0142); 125 | 120 failure("Basic ACLs shouldn't be stored as extended ACLs"); 121 assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 122 failure("Basic ACLs should set mode to 0142, not %04o", 123 archive_entry_mode(ae)&0777); 124 assert((archive_entry_mode(ae) & 0777) == 0142); 125 |
126 | |
127 /* With any extended ACL entry, we should read back a full set. */ | 126 /* With any extended ACL entry, we should read back a full set. */ |
128 archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); | 127 assertEntrySetAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); |
129 failure("One extended ACL should flag all ACLs to be returned."); 130 131 /* Check that entry contains only POSIX.1e types */ 132 assert((archive_entry_acl_types(ae) & 133 ARCHIVE_ENTRY_ACL_TYPE_NFS4) == 0); 134 assert((archive_entry_acl_types(ae) & 135 ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0); 136 137 assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); | 128 failure("One extended ACL should flag all ACLs to be returned."); 129 130 /* Check that entry contains only POSIX.1e types */ 131 assert((archive_entry_acl_types(ae) & 132 ARCHIVE_ENTRY_ACL_TYPE_NFS4) == 0); 133 assert((archive_entry_acl_types(ae) & 134 ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0); 135 136 assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); |
138 archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), | 137 assertEntryCompareAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), |
139 ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142); 140 failure("Basic ACLs should set mode to 0142, not %04o", 141 archive_entry_mode(ae)&0777); 142 assert((archive_entry_mode(ae) & 0777) == 0142); 143 144 145 /* A more extensive set of ACLs. */ | 138 ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142); 139 failure("Basic ACLs should set mode to 0142, not %04o", 140 archive_entry_mode(ae)&0777); 141 assert((archive_entry_mode(ae) & 0777) == 0142); 142 143 144 /* A more extensive set of ACLs. */ |
146 archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); | 145 assertEntrySetAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); |
147 assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); | 146 assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); |
148 archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), | 147 assertEntryCompareAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), |
149 ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543); 150 failure("Basic ACLs should set mode to 0543, not %04o", 151 archive_entry_mode(ae)&0777); 152 assert((archive_entry_mode(ae) & 0777) == 0543); 153 154 /* 155 * Check that clearing ACLs gets rid of them all by repeating 156 * the first test. 157 */ | 148 ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543); 149 failure("Basic ACLs should set mode to 0543, not %04o", 150 archive_entry_mode(ae)&0777); 151 assert((archive_entry_mode(ae) & 0777) == 0543); 152 153 /* 154 * Check that clearing ACLs gets rid of them all by repeating 155 * the first test. 156 */ |
158 archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); | 157 assertEntrySetAcls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); |
159 failure("Basic ACLs shouldn't be stored as extended ACLs"); 160 assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 161 failure("Basic ACLs should set mode to 0142, not %04o", 162 archive_entry_mode(ae)&0777); 163 assert((archive_entry_mode(ae) & 0777) == 0142); 164 165 /* 166 * Different types of malformed ACL entries that should 167 * fail when added to existing POSIX.1e ACLs. 168 */ | 158 failure("Basic ACLs shouldn't be stored as extended ACLs"); 159 assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 160 failure("Basic ACLs should set mode to 0142, not %04o", 161 archive_entry_mode(ae)&0777); 162 assert((archive_entry_mode(ae) & 0777) == 0142); 163 164 /* 165 * Different types of malformed ACL entries that should 166 * fail when added to existing POSIX.1e ACLs. 167 */ |
169 archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); | 168 assertEntrySetAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); |
170 for (i = 0; i < (int)(sizeof(acls_nfs4)/sizeof(acls_nfs4[0])); ++i) { 171 struct archive_test_acl_t *p = &acls_nfs4[i]; 172 failure("Malformed ACL test #%d", i); 173 assertEqualInt(ARCHIVE_FAILED, 174 archive_entry_acl_add_entry(ae, 175 p->type, p->permset, p->tag, p->qual, p->name)); 176 assertEqualInt(6, 177 archive_entry_acl_reset(ae, 178 ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 179 } 180 archive_entry_free(ae); 181} | 169 for (i = 0; i < (int)(sizeof(acls_nfs4)/sizeof(acls_nfs4[0])); ++i) { 170 struct archive_test_acl_t *p = &acls_nfs4[i]; 171 failure("Malformed ACL test #%d", i); 172 assertEqualInt(ARCHIVE_FAILED, 173 archive_entry_acl_add_entry(ae, 174 p->type, p->permset, p->tag, p->qual, p->name)); 175 assertEqualInt(6, 176 archive_entry_acl_reset(ae, 177 ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 178 } 179 archive_entry_free(ae); 180} |