Deleted Added
full compact
test_acl_pax.c (313570) test_acl_pax.c (315432)
1/*-
2 * Copyright (c) 2003-2007 Tim Kientzle
3 * Copyright (c) 2016 Martin Matuska
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26#include "test.h"
1/*-
2 * Copyright (c) 2003-2007 Tim Kientzle
3 * Copyright (c) 2016 Martin Matuska
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */
26#include "test.h"
27__FBSDID("$FreeBSD: stable/11/contrib/libarchive/libarchive/test/test_acl_pax.c 313570 2017-02-11 00:54:16Z mm $");
27__FBSDID("$FreeBSD: stable/11/contrib/libarchive/libarchive/test/test_acl_pax.c 315432 2017-03-16 23:07:35Z mm $");
28
29/*
30 * Exercise the system-independent portion of the ACL support.
31 * Check that pax archive can save and restore POSIX.1e ACL data.
32 *
33 * This should work on all systems, regardless of whether local
34 * filesystems support ACLs or not.
35 */

--- 197 unchanged lines hidden (view full) ---

233 /* Write a series of files to the archive with different ACL info. */
234
235 /* Create a simple archive_entry. */
236 assert((ae = archive_entry_new()) != NULL);
237 archive_entry_set_pathname(ae, "file");
238 archive_entry_set_mode(ae, S_IFREG | 0777);
239
240 /* Basic owner/owning group should just update mode bits. */
28
29/*
30 * Exercise the system-independent portion of the ACL support.
31 * Check that pax archive can save and restore POSIX.1e ACL data.
32 *
33 * This should work on all systems, regardless of whether local
34 * filesystems support ACLs or not.
35 */

--- 197 unchanged lines hidden (view full) ---

233 /* Write a series of files to the archive with different ACL info. */
234
235 /* Create a simple archive_entry. */
236 assert((ae = archive_entry_new()) != NULL);
237 archive_entry_set_pathname(ae, "file");
238 archive_entry_set_mode(ae, S_IFREG | 0777);
239
240 /* Basic owner/owning group should just update mode bits. */
241 archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
241 assertEntrySetAcls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
242 assertA(0 == archive_write_header(a, ae));
243
244 /* With any extended ACL entry, we should read back a full set. */
242 assertA(0 == archive_write_header(a, ae));
243
244 /* With any extended ACL entry, we should read back a full set. */
245 archive_test_set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
245 assertEntrySetAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
246 assertA(0 == archive_write_header(a, ae));
247
246 assertA(0 == archive_write_header(a, ae));
247
248
249 /* A more extensive set of ACLs. */
248 /* A more extensive set of ACLs. */
250 archive_test_set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
249 assertEntrySetAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
251 assertA(0 == archive_write_header(a, ae));
252
253 /*
254 * Check that clearing ACLs gets rid of them all by repeating
255 * the first test.
256 */
250 assertA(0 == archive_write_header(a, ae));
251
252 /*
253 * Check that clearing ACLs gets rid of them all by repeating
254 * the first test.
255 */
257 archive_test_set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
256 assertEntrySetAcls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
258 assertA(0 == archive_write_header(a, ae));
259 archive_entry_free(ae);
260
261 /* Close out the archive. */
262 assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
263 assertEqualInt(ARCHIVE_OK, archive_write_free(a));
264
265 /* Write out the data we generated to a file for manual inspection. */

--- 25 unchanged lines hidden (view full) ---

291 failure("Basic ACLs should set mode to 0142, not %04o",
292 archive_entry_mode(ae)&0777);
293 assert((archive_entry_mode(ae) & 0777) == 0142);
294
295 /* Second item has a few ACLs */
296 assertA(0 == archive_read_next_header(a, &ae));
297 failure("One extended ACL should flag all ACLs to be returned.");
298 assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
257 assertA(0 == archive_write_header(a, ae));
258 archive_entry_free(ae);
259
260 /* Close out the archive. */
261 assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
262 assertEqualInt(ARCHIVE_OK, archive_write_free(a));
263
264 /* Write out the data we generated to a file for manual inspection. */

--- 25 unchanged lines hidden (view full) ---

290 failure("Basic ACLs should set mode to 0142, not %04o",
291 archive_entry_mode(ae)&0777);
292 assert((archive_entry_mode(ae) & 0777) == 0142);
293
294 /* Second item has a few ACLs */
295 assertA(0 == archive_read_next_header(a, &ae));
296 failure("One extended ACL should flag all ACLs to be returned.");
297 assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
299 archive_test_compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
298 assertEntryCompareAcls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]),
300 ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142);
301 failure("Basic ACLs should set mode to 0142, not %04o",
302 archive_entry_mode(ae)&0777);
303 assert((archive_entry_mode(ae) & 0777) == 0142);
304
305 /* Third item has pretty extensive ACLs */
306 assertA(0 == archive_read_next_header(a, &ae));
307 assertEqualInt(6, archive_entry_acl_reset(ae,
308 ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
299 ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0142);
300 failure("Basic ACLs should set mode to 0142, not %04o",
301 archive_entry_mode(ae)&0777);
302 assert((archive_entry_mode(ae) & 0777) == 0142);
303
304 /* Third item has pretty extensive ACLs */
305 assertA(0 == archive_read_next_header(a, &ae));
306 assertEqualInt(6, archive_entry_acl_reset(ae,
307 ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
309 archive_test_compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]),
308 assertEntryCompareAcls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]),
310 ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543);
311 failure("Basic ACLs should set mode to 0543, not %04o",
312 archive_entry_mode(ae)&0777);
313 assert((archive_entry_mode(ae) & 0777) == 0543);
314
315 /* Fourth item has no ACLs */
316 assertA(0 == archive_read_next_header(a, &ae));
317 failure("Basic ACLs shouldn't be stored as extended ACLs");

--- 27 unchanged lines hidden (view full) ---

345 /* Write a series of files to the archive with different ACL info. */
346
347 /* Create a simple archive_entry. */
348 assert((ae = archive_entry_new()) != NULL);
349 archive_entry_set_pathname(ae, "file");
350 archive_entry_set_mode(ae, S_IFREG | 0777);
351
352 /* NFS4 ACLs mirroring 0754 file mode */
309 ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0543);
310 failure("Basic ACLs should set mode to 0543, not %04o",
311 archive_entry_mode(ae)&0777);
312 assert((archive_entry_mode(ae) & 0777) == 0543);
313
314 /* Fourth item has no ACLs */
315 assertA(0 == archive_read_next_header(a, &ae));
316 failure("Basic ACLs shouldn't be stored as extended ACLs");

--- 27 unchanged lines hidden (view full) ---

344 /* Write a series of files to the archive with different ACL info. */
345
346 /* Create a simple archive_entry. */
347 assert((ae = archive_entry_new()) != NULL);
348 archive_entry_set_pathname(ae, "file");
349 archive_entry_set_mode(ae, S_IFREG | 0777);
350
351 /* NFS4 ACLs mirroring 0754 file mode */
353 archive_test_set_acls(ae, acls3, sizeof(acls3)/sizeof(acls3[0]));
352 assertEntrySetAcls(ae, acls3, sizeof(acls3)/sizeof(acls3[0]));
354 assertA(0 == archive_write_header(a, ae));
355
356 /* A more extensive set of NFS4 ACLs. */
353 assertA(0 == archive_write_header(a, ae));
354
355 /* A more extensive set of NFS4 ACLs. */
357 archive_test_set_acls(ae, acls4, sizeof(acls4)/sizeof(acls4[0]));
356 assertEntrySetAcls(ae, acls4, sizeof(acls4)/sizeof(acls4[0]));
358 assertA(0 == archive_write_header(a, ae));
359
360 /* Set with special (audit, alarm) NFS4 ACLs. */
357 assertA(0 == archive_write_header(a, ae));
358
359 /* Set with special (audit, alarm) NFS4 ACLs. */
361 archive_test_set_acls(ae, acls5, sizeof(acls5)/sizeof(acls5[0]));
360 assertEntrySetAcls(ae, acls5, sizeof(acls5)/sizeof(acls5[0]));
362 assertA(0 == archive_write_header(a, ae));
363
364 archive_entry_free(ae);
365
366 /* Close out the archive. */
367 assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
368 assertEqualInt(ARCHIVE_OK, archive_write_free(a));
369

--- 18 unchanged lines hidden (view full) ---

388 assertA(0 == archive_read_support_format_all(a));
389 assertA(0 == archive_read_support_filter_all(a));
390 assertA(0 == archive_read_open_memory(a, buff, used));
391
392 /* First item has NFS4 ACLs mirroring file mode */
393 assertA(0 == archive_read_next_header(a, &ae));
394 assertEqualInt(3, archive_entry_acl_reset(ae,
395 ARCHIVE_ENTRY_ACL_TYPE_ALLOW));
361 assertA(0 == archive_write_header(a, ae));
362
363 archive_entry_free(ae);
364
365 /* Close out the archive. */
366 assertEqualIntA(a, ARCHIVE_OK, archive_write_close(a));
367 assertEqualInt(ARCHIVE_OK, archive_write_free(a));
368

--- 18 unchanged lines hidden (view full) ---

387 assertA(0 == archive_read_support_format_all(a));
388 assertA(0 == archive_read_support_filter_all(a));
389 assertA(0 == archive_read_open_memory(a, buff, used));
390
391 /* First item has NFS4 ACLs mirroring file mode */
392 assertA(0 == archive_read_next_header(a, &ae));
393 assertEqualInt(3, archive_entry_acl_reset(ae,
394 ARCHIVE_ENTRY_ACL_TYPE_ALLOW));
396 archive_test_compare_acls(ae, acls3, sizeof(acls3)/sizeof(acls3[0]),
395 assertEntryCompareAcls(ae, acls3, sizeof(acls3)/sizeof(acls3[0]),
397 ARCHIVE_ENTRY_ACL_TYPE_ALLOW, 0);
398
399 /* Second item has has more fine-grained NFS4 ACLs */
400 assertA(0 == archive_read_next_header(a, &ae));
401 assertEqualInt(6, archive_entry_acl_reset(ae,
402 ARCHIVE_ENTRY_ACL_TYPE_NFS4));
396 ARCHIVE_ENTRY_ACL_TYPE_ALLOW, 0);
397
398 /* Second item has has more fine-grained NFS4 ACLs */
399 assertA(0 == archive_read_next_header(a, &ae));
400 assertEqualInt(6, archive_entry_acl_reset(ae,
401 ARCHIVE_ENTRY_ACL_TYPE_NFS4));
403 archive_test_compare_acls(ae, acls4, sizeof(acls4)/sizeof(acls4[0]),
402 assertEntryCompareAcls(ae, acls4, sizeof(acls4)/sizeof(acls4[0]),
404 ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
405
406 /* Third item has has audit and alarm NFS4 ACLs */
407 assertA(0 == archive_read_next_header(a, &ae));
408 assertEqualInt(6, archive_entry_acl_reset(ae,
409 ARCHIVE_ENTRY_ACL_TYPE_NFS4));
403 ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
404
405 /* Third item has has audit and alarm NFS4 ACLs */
406 assertA(0 == archive_read_next_header(a, &ae));
407 assertEqualInt(6, archive_entry_acl_reset(ae,
408 ARCHIVE_ENTRY_ACL_TYPE_NFS4));
410 archive_test_compare_acls(ae, acls5, sizeof(acls5)/sizeof(acls5[0]),
409 assertEntryCompareAcls(ae, acls5, sizeof(acls5)/sizeof(acls5[0]),
411 ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
412
413 /* Close the archive. */
414 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
415 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
416}
410 ARCHIVE_ENTRY_ACL_TYPE_NFS4, 0);
411
412 /* Close the archive. */
413 assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
414 assertEqualInt(ARCHIVE_OK, archive_read_free(a));
415}