test_acl_pax.c revision 228753
1228753Smm/*- 2228753Smm * Copyright (c) 2003-2007 Tim Kientzle 3228753Smm * All rights reserved. 4228753Smm * 5228753Smm * Redistribution and use in source and binary forms, with or without 6228753Smm * modification, are permitted provided that the following conditions 7228753Smm * are met: 8228753Smm * 1. Redistributions of source code must retain the above copyright 9228753Smm * notice, this list of conditions and the following disclaimer. 10228753Smm * 2. Redistributions in binary form must reproduce the above copyright 11228753Smm * notice, this list of conditions and the following disclaimer in the 12228753Smm * documentation and/or other materials provided with the distribution. 13228753Smm * 14228753Smm * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15228753Smm * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16228753Smm * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17228753Smm * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18228753Smm * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19228753Smm * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20228753Smm * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21228753Smm * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22228753Smm * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23228753Smm * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24228753Smm */ 25228753Smm#include "test.h" 26228753Smm__FBSDID("$FreeBSD: head/lib/libarchive/test/test_acl_pax.c 201247 2009-12-30 05:59:21Z kientzle $"); 27228753Smm 28228753Smm/* 29228753Smm * Exercise the system-independent portion of the ACL support. 30228753Smm * Check that pax archive can save and restore ACL data. 31228753Smm * 32228753Smm * This should work on all systems, regardless of whether local 33228753Smm * filesystems support ACLs or not. 34228753Smm */ 35228753Smm 36228753Smmstatic unsigned char buff[16384]; 37228753Smm 38228753Smmstatic unsigned char reference[] = { 39228753Smm'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,0,0,0,0,0,0, 40228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 41228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 42228753Smm0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0', 43228753Smm'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','6','2',' ','0', 44228753Smm'0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','6','7',0,' ', 45228753Smm'x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 46228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 47228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r', 48228753Smm0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 49228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', 50228753Smm'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 51228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 52228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 53228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 54228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 55228753Smm0,0,0,0,0,0,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',10, 56228753Smm'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',' ', 57228753Smm'S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,0,0, 58228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 59228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 60228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 61228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 62228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 63228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 64228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 65228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 66228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 67228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 68228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 69228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 70228753Smm0,0,0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 71228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 72228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 73228753Smm0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0', 74228753Smm'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0', 75228753Smm'0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',0,' ', 76228753Smm'0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 77228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 78228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r', 79228753Smm0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 80228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', 81228753Smm'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 82228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 83228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 84228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 85228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 86228753Smm0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0, 87228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 88228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 89228753Smm0,0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ', 90228753Smm0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','1','7','2', 91228753Smm' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','7','1', 92228753Smm0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 93228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 94228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t', 95228753Smm'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 96228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', 97228753Smm'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, 98228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 99228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 100228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 101228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 102228753Smm0,0,0,0,0,0,0,0,0,0,'7','2',' ','S','C','H','I','L','Y','.','a','c','l','.', 103228753Smm'a','c','c','e','s','s','=','u','s','e','r',':',':','-','-','x',',','g','r', 104228753Smm'o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w','-', 105228753Smm',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7','7', 106228753Smm10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',10,'1','6', 107228753Smm' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',' ','S','C', 108228753Smm'H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,0,0,0,0,0,0, 109228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 110228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 111228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 112228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 113228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 114228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 115228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 116228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 117228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 118228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 119228753Smm0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 120228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 121228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 122228753Smm0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0','0', 123228753Smm'0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0','0', 124228753Smm'0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',0,' ','0', 125228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 126228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 127228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r',0, 128228753Smm'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 129228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', 130228753Smm'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 131228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 132228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 133228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 134228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 135228753Smm0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0, 136228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 137228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 138228753Smm0,0,0,0,0,0,0,0,0,'0','0','0','5','4','3',' ',0,'0','0','0','0','0','0',' ', 139228753Smm0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','2','4','3', 140228753Smm' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','7','5', 141228753Smm0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 142228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 143228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t', 144228753Smm'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 145228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', 146228753Smm'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, 147228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 148228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 149228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 150228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 151228753Smm0,0,0,0,0,0,0,0,0,0,'1','1','3',' ','S','C','H','I','L','Y','.','a','c','l', 152228753Smm'.','a','c','c','e','s','s','=','u','s','e','r',':',':','r','-','x',',','g', 153228753Smm'r','o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w', 154228753Smm'x',',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7', 155228753Smm'7',',','u','s','e','r',':','u','s','e','r','7','8',':','-','-','-',':','7', 156228753Smm'8',',','g','r','o','u','p',':','g','r','o','u','p','7','8',':','r','w','x', 157228753Smm':','7','8',10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0', 158228753Smm10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8', 159228753Smm' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0, 160228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 161228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 162228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 163228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 164228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 165228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 166228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 167228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 168228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 169228753Smm0,0,0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 170228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 171228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 172228753Smm0,0,0,0,'0','0','0','5','4','3',' ',0,'0','0','0','0','0','0',' ',0,'0','0', 173228753Smm'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0', 174228753Smm'0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','1','3',0,' ', 175228753Smm'0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 176228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 177228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t','a','r', 178228753Smm0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 179228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', 180228753Smm'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 181228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 182228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 183228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 184228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 185228753Smm0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0, 186228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 187228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 188228753Smm0,0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ', 189228753Smm0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','6','2', 190228753Smm' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','6','7', 191228753Smm0,' ','x',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 192228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 193228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t', 194228753Smm'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 195228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', 196228753Smm'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, 197228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 198228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 199228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 200228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 201228753Smm0,0,0,0,0,0,0,0,0,0,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=', 202228753Smm'0',10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1', 203228753Smm'8',' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0, 204228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 205228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 206228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 207228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 208228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 209228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 210228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 211228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 212228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 213228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 214228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 215228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 216228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'f','i','l','e',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 217228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 218228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 219228753Smm0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ', 220228753Smm0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0', 221228753Smm' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6', 222228753Smm0,' ','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 223228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 224228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'u','s','t', 225228753Smm'a','r',0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 226228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', 227228753Smm'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, 228228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 229228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 230228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 231228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 232228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 233228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 234228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 235228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 236228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 237228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 238228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 239228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 240228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 241228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 242228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 243228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 244228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 245228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 246228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 247228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 248228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 249228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 250228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 251228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 252228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 253228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 254228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 255228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 256228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 257228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 258228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 259228753Smm0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 260228753Smm 261228753Smm 262228753Smmstruct acl_t { 263228753Smm int type; /* Type of ACL: "access" or "default" */ 264228753Smm int permset; /* Permissions for this class of users. */ 265228753Smm int tag; /* Owner, User, Owning group, group, other, etc. */ 266228753Smm int qual; /* GID or UID of user/group, depending on tag. */ 267228753Smm const char *name; /* Name of user/group, depending on tag. */ 268228753Smm}; 269228753Smm 270228753Smmstatic struct acl_t acls0[] = { 271228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, 272228753Smm ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, 273228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, 274228753Smm ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, 275228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE, 276228753Smm ARCHIVE_ENTRY_ACL_OTHER, 0, "" }, 277228753Smm}; 278228753Smm 279228753Smmstatic struct acl_t acls1[] = { 280228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, 281228753Smm ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, 282228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, 283228753Smm ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, 284228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, 285228753Smm ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, 286228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE, 287228753Smm ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, 288228753Smm}; 289228753Smm 290228753Smmstatic struct acl_t acls2[] = { 291228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ, 292228753Smm ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, 293228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, 294228753Smm ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, 295228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0, 296228753Smm ARCHIVE_ENTRY_ACL_USER, 78, "user78" }, 297228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, 298228753Smm ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, 299228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007, 300228753Smm ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, 301228753Smm { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE, 302228753Smm ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, 303228753Smm}; 304228753Smm 305228753Smmstatic void 306228753Smmset_acls(struct archive_entry *ae, struct acl_t *acls, int n) 307228753Smm{ 308228753Smm int i; 309228753Smm 310228753Smm archive_entry_acl_clear(ae); 311228753Smm for (i = 0; i < n; i++) { 312228753Smm archive_entry_acl_add_entry(ae, 313228753Smm acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual, 314228753Smm acls[i].name); 315228753Smm } 316228753Smm} 317228753Smm 318228753Smmstatic int 319228753Smmacl_match(struct acl_t *acl, int type, int permset, int tag, int qual, const char *name) 320228753Smm{ 321228753Smm if (type != acl->type) 322228753Smm return (0); 323228753Smm if (permset != acl->permset) 324228753Smm return (0); 325228753Smm if (tag != acl->tag) 326228753Smm return (0); 327228753Smm if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) 328228753Smm return (1); 329228753Smm if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) 330228753Smm return (1); 331228753Smm if (tag == ARCHIVE_ENTRY_ACL_OTHER) 332228753Smm return (1); 333228753Smm if (qual != acl->qual) 334228753Smm return (0); 335228753Smm if (name == NULL) 336228753Smm return (acl->name == NULL || acl->name[0] == '\0'); 337228753Smm if (acl->name == NULL) 338228753Smm return (name == NULL || name[0] == '\0'); 339228753Smm return (0 == strcmp(name, acl->name)); 340228753Smm} 341228753Smm 342228753Smmstatic void 343228753Smmcompare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode) 344228753Smm{ 345228753Smm int *marker = malloc(sizeof(marker[0]) * n); 346228753Smm int i; 347228753Smm int r; 348228753Smm int type, permset, tag, qual; 349228753Smm int matched; 350228753Smm const char *name; 351228753Smm 352228753Smm for (i = 0; i < n; i++) 353228753Smm marker[i] = i; 354228753Smm 355228753Smm while (0 == (r = archive_entry_acl_next(ae, 356228753Smm ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 357228753Smm &type, &permset, &tag, &qual, &name))) { 358228753Smm for (i = 0, matched = 0; i < n && !matched; i++) { 359228753Smm if (acl_match(&acls[marker[i]], type, permset, 360228753Smm tag, qual, name)) { 361228753Smm /* We found a match; remove it. */ 362228753Smm marker[i] = marker[n - 1]; 363228753Smm n--; 364228753Smm matched = 1; 365228753Smm } 366228753Smm } 367228753Smm if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) { 368228753Smm if (!matched) printf("No match for user_obj perm\n"); 369228753Smm failure("USER_OBJ permset (%02o) != user mode (%02o)", 370228753Smm permset, 07 & (mode >> 6)); 371228753Smm assert((permset << 6) == (mode & 0700)); 372228753Smm } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) { 373228753Smm if (!matched) printf("No match for group_obj perm\n"); 374228753Smm failure("GROUP_OBJ permset %02o != group mode %02o", 375228753Smm permset, 07 & (mode >> 3)); 376228753Smm assert((permset << 3) == (mode & 0070)); 377228753Smm } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) { 378228753Smm if (!matched) printf("No match for other perm\n"); 379228753Smm failure("OTHER permset (%02o) != other mode (%02o)", 380228753Smm permset, mode & 07); 381228753Smm assert((permset << 0) == (mode & 0007)); 382228753Smm } else { 383228753Smm failure("Could not find match for ACL " 384228753Smm "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", 385228753Smm type, permset, tag, qual, name); 386228753Smm assert(matched == 1); 387228753Smm } 388228753Smm } 389228753Smm#if ARCHIVE_VERSION_NUMBER < 1009000 390228753Smm /* Known broken before 1.9.0. */ 391228753Smm skipping("archive_entry_acl_next() exits with ARCHIVE_EOF"); 392228753Smm#else 393228753Smm assertEqualInt(ARCHIVE_EOF, r); 394228753Smm#endif 395228753Smm assert((mode & 0777) == (archive_entry_mode(ae) & 0777)); 396228753Smm failure("Could not find match for ACL " 397228753Smm "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", 398228753Smm acls[marker[0]].type, acls[marker[0]].permset, 399228753Smm acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); 400228753Smm assert(n == 0); /* Number of ACLs not matched should == 0 */ 401228753Smm free(marker); 402228753Smm} 403228753Smm 404228753SmmDEFINE_TEST(test_acl_pax) 405228753Smm{ 406228753Smm struct archive *a; 407228753Smm struct archive_entry *ae; 408228753Smm size_t used; 409228753Smm FILE *f; 410228753Smm 411228753Smm /* Write an archive to memory. */ 412228753Smm assert(NULL != (a = archive_write_new())); 413228753Smm assertA(0 == archive_write_set_format_pax(a)); 414228753Smm assertA(0 == archive_write_set_compression_none(a)); 415228753Smm assertA(0 == archive_write_set_bytes_per_block(a, 1)); 416228753Smm assertA(0 == archive_write_set_bytes_in_last_block(a, 1)); 417228753Smm assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); 418228753Smm 419228753Smm /* Write a series of files to the archive with different ACL info. */ 420228753Smm 421228753Smm /* Create a simple archive_entry. */ 422228753Smm assert((ae = archive_entry_new()) != NULL); 423228753Smm archive_entry_set_pathname(ae, "file"); 424228753Smm archive_entry_set_mode(ae, S_IFREG | 0777); 425228753Smm 426228753Smm /* Basic owner/owning group should just update mode bits. */ 427228753Smm set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); 428228753Smm assertA(0 == archive_write_header(a, ae)); 429228753Smm 430228753Smm /* With any extended ACL entry, we should read back a full set. */ 431228753Smm set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); 432228753Smm assertA(0 == archive_write_header(a, ae)); 433228753Smm 434228753Smm 435228753Smm /* A more extensive set of ACLs. */ 436228753Smm set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); 437228753Smm assertA(0 == archive_write_header(a, ae)); 438228753Smm 439228753Smm /* 440228753Smm * Check that clearing ACLs gets rid of them all by repeating 441228753Smm * the first test. 442228753Smm */ 443228753Smm set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); 444228753Smm assertA(0 == archive_write_header(a, ae)); 445228753Smm archive_entry_free(ae); 446228753Smm 447228753Smm /* Close out the archive. */ 448228753Smm assertA(0 == archive_write_close(a)); 449228753Smm#if ARCHIVE_VERSION_NUMBER < 2000000 450228753Smm archive_write_finish(a); 451228753Smm#else 452228753Smm assertA(0 == archive_write_finish(a)); 453228753Smm#endif 454228753Smm 455228753Smm /* Write out the data we generated to a file for manual inspection. */ 456228753Smm assert(NULL != (f = fopen("testout", "wb"))); 457228753Smm assertEqualInt(used, (size_t)fwrite(buff, 1, (unsigned int)used, f)); 458228753Smm fclose(f); 459228753Smm 460228753Smm /* Write out the reference data to a file for manual inspection. */ 461228753Smm assert(NULL != (f = fopen("reference", "wb"))); 462228753Smm assert(sizeof(reference) == fwrite(reference, 1, sizeof(reference), f)); 463228753Smm fclose(f); 464228753Smm 465228753Smm /* Assert that the generated data matches the built-in reference data.*/ 466228753Smm failure("Generated pax archive does not match reference; check 'testout' and 'reference' files."); 467228753Smm assertEqualMem(buff, reference, sizeof(reference)); 468228753Smm failure("Generated pax archive does not match reference; check 'testout' and 'reference' files."); 469228753Smm assertEqualInt((int)used, sizeof(reference)); 470228753Smm 471228753Smm /* Read back each entry and check that the ACL data is right. */ 472228753Smm assert(NULL != (a = archive_read_new())); 473228753Smm assertA(0 == archive_read_support_format_all(a)); 474228753Smm assertA(0 == archive_read_support_compression_all(a)); 475228753Smm assertA(0 == archive_read_open_memory(a, buff, used)); 476228753Smm 477228753Smm /* First item has no ACLs */ 478228753Smm assertA(0 == archive_read_next_header(a, &ae)); 479228753Smm failure("Basic ACLs shouldn't be stored as extended ACLs"); 480228753Smm assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 481228753Smm failure("Basic ACLs should set mode to 0142, not %04o", 482228753Smm archive_entry_mode(ae)&0777); 483228753Smm assert((archive_entry_mode(ae) & 0777) == 0142); 484228753Smm 485228753Smm /* Second item has a few ACLs */ 486228753Smm assertA(0 == archive_read_next_header(a, &ae)); 487228753Smm failure("One extended ACL should flag all ACLs to be returned."); 488228753Smm assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 489228753Smm compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0142); 490228753Smm failure("Basic ACLs should set mode to 0142, not %04o", 491228753Smm archive_entry_mode(ae)&0777); 492228753Smm assert((archive_entry_mode(ae) & 0777) == 0142); 493228753Smm 494228753Smm /* Third item has pretty extensive ACLs */ 495228753Smm assertA(0 == archive_read_next_header(a, &ae)); 496228753Smm assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 497228753Smm compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0543); 498228753Smm failure("Basic ACLs should set mode to 0543, not %04o", 499228753Smm archive_entry_mode(ae)&0777); 500228753Smm assert((archive_entry_mode(ae) & 0777) == 0543); 501228753Smm 502228753Smm /* Fourth item has no ACLs */ 503228753Smm assertA(0 == archive_read_next_header(a, &ae)); 504228753Smm failure("Basic ACLs shouldn't be stored as extended ACLs"); 505228753Smm assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 506228753Smm failure("Basic ACLs should set mode to 0142, not %04o", 507228753Smm archive_entry_mode(ae)&0777); 508228753Smm assert((archive_entry_mode(ae) & 0777) == 0142); 509228753Smm 510228753Smm /* Close the archive. */ 511228753Smm assertA(0 == archive_read_close(a)); 512228753Smm#if ARCHIVE_VERSION_NUMBER < 2000000 513228753Smm archive_read_finish(a); 514228753Smm#else 515228753Smm assertA(0 == archive_read_finish(a)); 516228753Smm#endif 517228753Smm} 518