test_acl_pax.c revision 228761
1226586Sdim/*- 2226586Sdim * Copyright (c) 2003-2007 Tim Kientzle 3226586Sdim * All rights reserved. 4226586Sdim * 5226586Sdim * Redistribution and use in source and binary forms, with or without 6226586Sdim * modification, are permitted provided that the following conditions 7226586Sdim * are met: 8226586Sdim * 1. Redistributions of source code must retain the above copyright 9226586Sdim * notice, this list of conditions and the following disclaimer. 10226586Sdim * 2. Redistributions in binary form must reproduce the above copyright 11226586Sdim * notice, this list of conditions and the following disclaimer in the 12226586Sdim * documentation and/or other materials provided with the distribution. 13226586Sdim * 14226586Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR 15226586Sdim * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 16226586Sdim * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 17226586Sdim * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT, 18226586Sdim * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19226586Sdim * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 20226586Sdim * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 21226586Sdim * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22226586Sdim * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23226586Sdim * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24226586Sdim */ 25226586Sdim#include "test.h" 26226586Sdim__FBSDID("$FreeBSD: head/lib/libarchive/test/test_acl_pax.c 201247 2009-12-30 05:59:21Z kientzle $"); 27226586Sdim 28226586Sdim/* 29226586Sdim * Exercise the system-independent portion of the ACL support. 30226586Sdim * Check that pax archive can save and restore ACL data. 31226586Sdim * 32226586Sdim * This should work on all systems, regardless of whether local 33226586Sdim * filesystems support ACLs or not. 34226586Sdim */ 35226586Sdim 36226586Sdimstatic unsigned char buff[16384]; 37226586Sdim 38226586Sdimstatic unsigned char reference[] = { 39226586Sdim'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,0,0,0,0,0,0, 40226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 41226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 42226586Sdim0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0', 43226586Sdim'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','6','2',' ','0', 44226586Sdim'0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','6','7',0,' ', 45226586Sdim'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, 46226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 47226586Sdim0,0,0,0,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', 48226586Sdim0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 49226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', 50226586Sdim'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 51226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 52226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 53226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 54226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 55226586Sdim0,0,0,0,0,0,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',10, 56226586Sdim'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',' ', 57226586Sdim'S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,0,0, 58226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 59226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 60226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 61226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 62226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 63226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 64226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 65226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 66226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 67226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 68226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 69226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 70226586Sdim0,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, 71226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 72226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 73226586Sdim0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0', 74226586Sdim'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0', 75226586Sdim'0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',0,' ', 76226586Sdim'0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 77226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 78226586Sdim0,0,0,0,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', 79226586Sdim0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 80226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', 81226586Sdim'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 82226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 83226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 84226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 85226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 86226586Sdim0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0, 87226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 88226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 89226586Sdim0,0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ', 90226586Sdim0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','1','7','2', 91226586Sdim' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','7','1', 92226586Sdim0,' ','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, 93226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 94226586Sdim0,0,0,0,0,0,0,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', 95226586Sdim'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, 96226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', 97226586Sdim'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, 98226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 99226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 100226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 101226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 102226586Sdim0,0,0,0,0,0,0,0,0,0,'7','2',' ','S','C','H','I','L','Y','.','a','c','l','.', 103226586Sdim'a','c','c','e','s','s','=','u','s','e','r',':',':','-','-','x',',','g','r', 104226586Sdim'o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w','-', 105226586Sdim',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7','7', 106226586Sdim10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',10,'1','6', 107226586Sdim' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',' ','S','C', 108226586Sdim'H','I','L','Y','.','n','l','i','n','k','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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 122226586Sdim0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0','0', 123226586Sdim'0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0','0', 124226586Sdim'0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',0,' ','0', 125226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 126226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 127226586Sdim0,0,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, 128226586Sdim'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 129226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', 130226586Sdim'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 131226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 132226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 133226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 134226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 135226586Sdim0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0, 136226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 137226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 138226586Sdim0,0,0,0,0,0,0,0,0,'0','0','0','5','4','3',' ',0,'0','0','0','0','0','0',' ', 139226586Sdim0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','2','4','3', 140226586Sdim' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','7','5', 141226586Sdim0,' ','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, 142226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 143226586Sdim0,0,0,0,0,0,0,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', 144226586Sdim'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, 145226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', 146226586Sdim'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, 147226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 148226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 149226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 150226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 151226586Sdim0,0,0,0,0,0,0,0,0,0,'1','1','3',' ','S','C','H','I','L','Y','.','a','c','l', 152226586Sdim'.','a','c','c','e','s','s','=','u','s','e','r',':',':','r','-','x',',','g', 153226586Sdim'r','o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w', 154226586Sdim'x',',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7', 155226586Sdim'7',',','u','s','e','r',':','u','s','e','r','7','8',':','-','-','-',':','7', 156226586Sdim'8',',','g','r','o','u','p',':','g','r','o','u','p','7','8',':','r','w','x', 157226586Sdim':','7','8',10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0', 158226586Sdim10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8', 159226586Sdim' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0, 160226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 161226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 162226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 163226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 164226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 165226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 166226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 167226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 168226586Sdim0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1690,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, 1700,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1710,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1720,0,0,0,'0','0','0','5','4','3',' ',0,'0','0','0','0','0','0',' ',0,'0','0', 173'0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0', 174'0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','1','3',0,' ', 175'0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1760,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1770,0,0,0,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', 1780,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1790,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0', 180'0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1810,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1820,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1830,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1840,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1850,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0, 1860,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1870,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1880,0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ', 1890,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','6','2', 190' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','6','7', 1910,' ','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, 1920,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1930,0,0,0,0,0,0,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', 194'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, 1950,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0', 196'0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0, 1970,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1980,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 1990,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2000,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2010,0,0,0,0,0,0,0,0,0,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=', 202'0',10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1', 203'8',' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0, 2040,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2050,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2060,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2070,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2080,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2090,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2100,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2110,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2120,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2130,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2140,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2150,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2160,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, 2170,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2180,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2190,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ', 2200,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0', 221' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6', 2220,' ','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2230,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2240,0,0,0,0,0,0,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', 225'a','r',0,'0','0',0,0,0,0,0,0,0,0,0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0,0,0,0,0,0,0,0,0,0,0, 2530,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2540,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2550,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2560,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2570,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2580,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 2590,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; 260 261 262struct acl_t { 263 int type; /* Type of ACL: "access" or "default" */ 264 int permset; /* Permissions for this class of users. */ 265 int tag; /* Owner, User, Owning group, group, other, etc. */ 266 int qual; /* GID or UID of user/group, depending on tag. */ 267 const char *name; /* Name of user/group, depending on tag. */ 268}; 269 270static struct acl_t acls0[] = { 271 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, 272 ARCHIVE_ENTRY_ACL_USER_OBJ, 0, "" }, 273 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, 274 ARCHIVE_ENTRY_ACL_GROUP_OBJ, 0, "" }, 275 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE, 276 ARCHIVE_ENTRY_ACL_OTHER, 0, "" }, 277}; 278 279static struct acl_t acls1[] = { 280 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE, 281 ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, 282 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, 283 ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, 284 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, 285 ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, 286 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE, 287 ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, 288}; 289 290static struct acl_t acls2[] = { 291 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_EXECUTE | ARCHIVE_ENTRY_ACL_READ, 292 ARCHIVE_ENTRY_ACL_USER_OBJ, -1, "" }, 293 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, 294 ARCHIVE_ENTRY_ACL_USER, 77, "user77" }, 295 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0, 296 ARCHIVE_ENTRY_ACL_USER, 78, "user78" }, 297 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_READ, 298 ARCHIVE_ENTRY_ACL_GROUP_OBJ, -1, "" }, 299 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 0007, 300 ARCHIVE_ENTRY_ACL_GROUP, 78, "group78" }, 301 { ARCHIVE_ENTRY_ACL_TYPE_ACCESS, ARCHIVE_ENTRY_ACL_WRITE | ARCHIVE_ENTRY_ACL_EXECUTE, 302 ARCHIVE_ENTRY_ACL_OTHER, -1, "" }, 303}; 304 305static void 306set_acls(struct archive_entry *ae, struct acl_t *acls, int n) 307{ 308 int i; 309 310 archive_entry_acl_clear(ae); 311 for (i = 0; i < n; i++) { 312 archive_entry_acl_add_entry(ae, 313 acls[i].type, acls[i].permset, acls[i].tag, acls[i].qual, 314 acls[i].name); 315 } 316} 317 318static int 319acl_match(struct acl_t *acl, int type, int permset, int tag, int qual, const char *name) 320{ 321 if (type != acl->type) 322 return (0); 323 if (permset != acl->permset) 324 return (0); 325 if (tag != acl->tag) 326 return (0); 327 if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) 328 return (1); 329 if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) 330 return (1); 331 if (tag == ARCHIVE_ENTRY_ACL_OTHER) 332 return (1); 333 if (qual != acl->qual) 334 return (0); 335 if (name == NULL) 336 return (acl->name == NULL || acl->name[0] == '\0'); 337 if (acl->name == NULL) 338 return (name == NULL || name[0] == '\0'); 339 return (0 == strcmp(name, acl->name)); 340} 341 342static void 343compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode) 344{ 345 int *marker = malloc(sizeof(marker[0]) * n); 346 int i; 347 int r; 348 int type, permset, tag, qual; 349 int matched; 350 const char *name; 351 352 for (i = 0; i < n; i++) 353 marker[i] = i; 354 355 while (0 == (r = archive_entry_acl_next(ae, 356 ARCHIVE_ENTRY_ACL_TYPE_ACCESS, 357 &type, &permset, &tag, &qual, &name))) { 358 for (i = 0, matched = 0; i < n && !matched; i++) { 359 if (acl_match(&acls[marker[i]], type, permset, 360 tag, qual, name)) { 361 /* We found a match; remove it. */ 362 marker[i] = marker[n - 1]; 363 n--; 364 matched = 1; 365 } 366 } 367 if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) { 368 if (!matched) printf("No match for user_obj perm\n"); 369 failure("USER_OBJ permset (%02o) != user mode (%02o)", 370 permset, 07 & (mode >> 6)); 371 assert((permset << 6) == (mode & 0700)); 372 } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) { 373 if (!matched) printf("No match for group_obj perm\n"); 374 failure("GROUP_OBJ permset %02o != group mode %02o", 375 permset, 07 & (mode >> 3)); 376 assert((permset << 3) == (mode & 0070)); 377 } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) { 378 if (!matched) printf("No match for other perm\n"); 379 failure("OTHER permset (%02o) != other mode (%02o)", 380 permset, mode & 07); 381 assert((permset << 0) == (mode & 0007)); 382 } else { 383 failure("Could not find match for ACL " 384 "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", 385 type, permset, tag, qual, name); 386 assert(matched == 1); 387 } 388 } 389#if ARCHIVE_VERSION_NUMBER < 1009000 390 /* Known broken before 1.9.0. */ 391 skipping("archive_entry_acl_next() exits with ARCHIVE_EOF"); 392#else 393 assertEqualInt(ARCHIVE_EOF, r); 394#endif 395 assert((mode & 0777) == (archive_entry_mode(ae) & 0777)); 396 failure("Could not find match for ACL " 397 "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')", 398 acls[marker[0]].type, acls[marker[0]].permset, 399 acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name); 400 assert(n == 0); /* Number of ACLs not matched should == 0 */ 401 free(marker); 402} 403 404DEFINE_TEST(test_acl_pax) 405{ 406 struct archive *a; 407 struct archive_entry *ae; 408 size_t used; 409 FILE *f; 410 411 /* Write an archive to memory. */ 412 assert(NULL != (a = archive_write_new())); 413 assertA(0 == archive_write_set_format_pax(a)); 414 assertA(0 == archive_write_set_compression_none(a)); 415 assertA(0 == archive_write_set_bytes_per_block(a, 1)); 416 assertA(0 == archive_write_set_bytes_in_last_block(a, 1)); 417 assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used)); 418 419 /* Write a series of files to the archive with different ACL info. */ 420 421 /* Create a simple archive_entry. */ 422 assert((ae = archive_entry_new()) != NULL); 423 archive_entry_set_pathname(ae, "file"); 424 archive_entry_set_mode(ae, S_IFREG | 0777); 425 426 /* Basic owner/owning group should just update mode bits. */ 427 set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); 428 assertA(0 == archive_write_header(a, ae)); 429 430 /* With any extended ACL entry, we should read back a full set. */ 431 set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0])); 432 assertA(0 == archive_write_header(a, ae)); 433 434 435 /* A more extensive set of ACLs. */ 436 set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0])); 437 assertA(0 == archive_write_header(a, ae)); 438 439 /* 440 * Check that clearing ACLs gets rid of them all by repeating 441 * the first test. 442 */ 443 set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0])); 444 assertA(0 == archive_write_header(a, ae)); 445 archive_entry_free(ae); 446 447 /* Close out the archive. */ 448 assertA(0 == archive_write_close(a)); 449#if ARCHIVE_VERSION_NUMBER < 2000000 450 archive_write_finish(a); 451#else 452 assertA(0 == archive_write_finish(a)); 453#endif 454 455 /* Write out the data we generated to a file for manual inspection. */ 456 assert(NULL != (f = fopen("testout", "wb"))); 457 assertEqualInt(used, (size_t)fwrite(buff, 1, (unsigned int)used, f)); 458 fclose(f); 459 460 /* Write out the reference data to a file for manual inspection. */ 461 assert(NULL != (f = fopen("reference", "wb"))); 462 assert(sizeof(reference) == fwrite(reference, 1, sizeof(reference), f)); 463 fclose(f); 464 465 /* Assert that the generated data matches the built-in reference data.*/ 466 failure("Generated pax archive does not match reference; check 'testout' and 'reference' files."); 467 assertEqualMem(buff, reference, sizeof(reference)); 468 failure("Generated pax archive does not match reference; check 'testout' and 'reference' files."); 469 assertEqualInt((int)used, sizeof(reference)); 470 471 /* Read back each entry and check that the ACL data is right. */ 472 assert(NULL != (a = archive_read_new())); 473 assertA(0 == archive_read_support_format_all(a)); 474 assertA(0 == archive_read_support_compression_all(a)); 475 assertA(0 == archive_read_open_memory(a, buff, used)); 476 477 /* First item has no ACLs */ 478 assertA(0 == archive_read_next_header(a, &ae)); 479 failure("Basic ACLs shouldn't be stored as extended ACLs"); 480 assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 481 failure("Basic ACLs should set mode to 0142, not %04o", 482 archive_entry_mode(ae)&0777); 483 assert((archive_entry_mode(ae) & 0777) == 0142); 484 485 /* Second item has a few ACLs */ 486 assertA(0 == archive_read_next_header(a, &ae)); 487 failure("One extended ACL should flag all ACLs to be returned."); 488 assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 489 compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0142); 490 failure("Basic ACLs should set mode to 0142, not %04o", 491 archive_entry_mode(ae)&0777); 492 assert((archive_entry_mode(ae) & 0777) == 0142); 493 494 /* Third item has pretty extensive ACLs */ 495 assertA(0 == archive_read_next_header(a, &ae)); 496 assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 497 compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0543); 498 failure("Basic ACLs should set mode to 0543, not %04o", 499 archive_entry_mode(ae)&0777); 500 assert((archive_entry_mode(ae) & 0777) == 0543); 501 502 /* Fourth item has no ACLs */ 503 assertA(0 == archive_read_next_header(a, &ae)); 504 failure("Basic ACLs shouldn't be stored as extended ACLs"); 505 assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS)); 506 failure("Basic ACLs should set mode to 0142, not %04o", 507 archive_entry_mode(ae)&0777); 508 assert((archive_entry_mode(ae) & 0777) == 0142); 509 510 /* Close the archive. */ 511 assertA(0 == archive_read_close(a)); 512#if ARCHIVE_VERSION_NUMBER < 2000000 513 archive_read_finish(a); 514#else 515 assertA(0 == archive_read_finish(a)); 516#endif 517} 518