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
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 #include "test.h"
26 __FBSDID("$FreeBSD: head/lib/libarchive/test/test_acl_pax.c 201247 2009-12-30 05:59:21Z kientzle $");
27 
28 /*
29  * Exercise the system-independent portion of the ACL support.
30  * Check that pax archive can save and restore ACL data.
31  *
32  * This should work on all systems, regardless of whether local
33  * filesystems support ACLs or not.
34  */
35 
36 static unsigned char buff[16384];
37 
38 static unsigned char reference[] = {
39 'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,0,0,0,0,0,0,
40 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
41 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
42 0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0',
43 '0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','6','2',' ','0',
44 '0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','6','7',0,' ',
45 '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,
46 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
47 0,0,0,0,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',
48 0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
49 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0',
50 '0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0,
51 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
52 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
53 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
54 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
55 0,0,0,0,0,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
70 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,0,0,0,0,
71 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
72 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
73 0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0',
74 '0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0',
75 '0','0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',0,' ',
76 '0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
77 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
78 0,0,0,0,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',
79 0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
80 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0',
81 '0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0,
82 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
83 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
84 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
85 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
86 0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,
87 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
88 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
89 0,0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',
90 0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','1','7','2',
91 ' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','7','1',
92 0,' ','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,
93 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
94 0,0,0,0,0,0,0,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',
95 '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,
96 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0',
97 '0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,
98 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
99 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
100 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
101 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
102 0,0,0,0,0,0,0,0,0,0,'7','2',' ','S','C','H','I','L','Y','.','a','c','l','.',
103 'a','c','c','e','s','s','=','u','s','e','r',':',':','-','-','x',',','g','r',
104 'o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w','-',
105 ',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7','7',
106 10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',10,'1','6',
107 ' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',' ','S','C',
108 'H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,0,0,0,0,0,0,
109 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
110 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
111 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
112 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
113 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
114 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
115 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
116 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
117 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
118 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
119 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,0,0,
120 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
121 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
122 0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',0,'0','0','0',
123 '0','0','0',' ',0,'0','0','0','0','0','0','0','0','0','0','0',' ','0','0',
124 '0','0','0','0','0','0','0','0','0',' ','0','1','0','0','0','6',0,' ','0',
125 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
126 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
127 0,0,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,
128 '0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
129 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0','0','0',
130 '0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,0,0,0,0,
131 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
132 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
133 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
134 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
135 0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,
136 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
137 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
138 0,0,0,0,0,0,0,0,0,'0','0','0','5','4','3',' ',0,'0','0','0','0','0','0',' ',
139 0,'0','0','0','0','0','0',' ',0,'0','0','0','0','0','0','0','0','2','4','3',
140 ' ','0','0','0','0','0','0','0','0','0','0','0',' ','0','1','1','7','7','5',
141 0,' ','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,
142 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
143 0,0,0,0,0,0,0,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',
144 '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,
145 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0',
146 '0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,
147 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
148 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
149 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
150 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
151 0,0,0,0,0,0,0,0,0,0,'1','1','3',' ','S','C','H','I','L','Y','.','a','c','l',
152 '.','a','c','c','e','s','s','=','u','s','e','r',':',':','r','-','x',',','g',
153 'r','o','u','p',':',':','r','-','-',',','o','t','h','e','r',':',':','-','w',
154 'x',',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',':','7',
155 '7',',','u','s','e','r',':','u','s','e','r','7','8',':','-','-','-',':','7',
156 '8',',','g','r','o','u','p',':','g','r','o','u','p','7','8',':','r','w','x',
157 ':','7','8',10,'1','6',' ','S','C','H','I','L','Y','.','d','e','v','=','0',
158 10,'1','6',' ','S','C','H','I','L','Y','.','i','n','o','=','0',10,'1','8',
159 ' ','S','C','H','I','L','Y','.','n','l','i','n','k','=','0',10,0,0,0,0,0,
160 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
161 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
162 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
163 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
164 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
165 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
166 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
167 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
168 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
169 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,0,0,0,0,
170 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
171 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
172 0,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,
176 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
177 0,0,0,0,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',
178 0,'0','0',0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
179 0,0,0,0,0,0,0,0,0,0,0,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,
181 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
182 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
183 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
184 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
185 0,0,0,0,0,0,'P','a','x','H','e','a','d','e','r','/','f','i','l','e',0,0,0,
186 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
187 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
188 0,0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',
189 0,'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',
191 0,' ','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,
192 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
193 0,0,0,0,0,0,0,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,
195 0,0,0,0,0,0,0,0,0,0,0,0,0,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,
197 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
198 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
199 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
200 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
201 0,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,
204 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
205 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
206 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
207 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
208 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
209 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
210 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
211 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
212 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
213 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
214 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
215 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
216 0,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,
217 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
218 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
219 0,0,0,0,0,0,0,0,'0','0','0','1','4','2',' ',0,'0','0','0','0','0','0',' ',
220 0,'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',
222 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,0,0,0,0,0,0,0,0,0,0,0,0,
250 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
251 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
252 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
253 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
254 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
255 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
256 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
257 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
258 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
259 0,0,0,0,0,0,0,0,0,0,0,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 
262 struct 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 
270 static 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 
279 static 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 
290 static 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 
305 static void
306 set_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 
318 static int
319 acl_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 
342 static void
343 compare_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 
404 DEFINE_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