]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libarchive/test/test_acl_pax.c
This commit was generated by cvs2svn to compensate for changes in r167961,
[FreeBSD/FreeBSD.git] / lib / libarchive / test / test_acl_pax.c
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$");
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,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0,0,0,0,0,0,0,0,0,0,0,0,0,0,
69 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,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',',','g','r','o','u','p',':','g','r','o','u','p','7','8',':','r','w','x',
155 ':','7','8',',','u','s','e','r',':','u','s','e','r','7','8',':','-','-','-',
156 ':','7','8',',','u','s','e','r',':','u','s','e','r','7','7',':','r','-','-',
157 ':','7','7',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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','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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
223 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
224 0,0,0,0,0,0,0,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,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
226 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,'0',
227 '0','0','0','0','0',' ',0,'0','0','0','0','0','0',' ',0,0,0,0,0,0,0,0,0,0,
228 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
229 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
230 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
231 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
232 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
233 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
234 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
235 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,
249 0,0,0,0,0,0,0,0,0,0,0,0,0,0,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         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                 if (acl->name == NULL || acl->name[0] == '\0')
337                         return (1);
338         }
339         if (acl->name == NULL) {
340                 if (name[0] == '\0')
341                         return (1);
342         }
343         return (0 == strcmp(name, acl->name));
344 }
345
346 static void
347 compare_acls(struct archive_entry *ae, struct acl_t *acls, int n, int mode)
348 {
349         int *marker = malloc(sizeof(marker[0]) * n);
350         int marker_i, i;
351         int r;
352         int type, permset, tag, qual;
353         int matched;
354         const char *name;
355
356         for (i = 0; i < n; i++)
357                 marker[i] = i;
358
359         while (0 == (r = archive_entry_acl_next(ae,
360                          ARCHIVE_ENTRY_ACL_TYPE_ACCESS,
361                          &type, &permset, &tag, &qual, &name))) {
362                 for (i = 0, matched = 0; i < n && !matched; i++) {
363                         if (acl_match(&acls[marker[i]], type, permset,
364                                 tag, qual, name)) {
365                                 /* We found a match; remove it. */
366                                 marker[i] = marker[n - 1];
367                                 n--;
368                                 matched = 1;
369                         }
370                 }
371                 if (tag == ARCHIVE_ENTRY_ACL_USER_OBJ) {
372                         if (!matched) printf("No match for user_obj perm\n");
373                         failure("USER_OBJ permset (%02o) != user mode (%02o)",
374                             permset, 07 & (mode >> 6));
375                         assert((permset << 6) == (mode & 0700));
376                 } else if (tag == ARCHIVE_ENTRY_ACL_GROUP_OBJ) {
377                         if (!matched) printf("No match for group_obj perm\n");
378                         failure("GROUP_OBJ permset %02o != group mode %02o",
379                             permset, 07 & (mode >> 3));
380                         assert((permset << 3) == (mode & 0070));
381                 } else if (tag == ARCHIVE_ENTRY_ACL_OTHER) {
382                         if (!matched) printf("No match for other perm\n");
383                         failure("OTHER permset (%02o) != other mode (%02o)",
384                             permset, mode & 07);
385                         assert((permset << 0) == (mode & 0007));
386                 } else {
387                         failure("Could not find match for ACL "
388                             "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
389                             type, permset, tag, qual, name);
390                         assert(matched == 1);
391                 }
392         }
393         assertEqualInt(ARCHIVE_EOF, r);
394         assert((mode & 0777) == (archive_entry_mode(ae) & 0777));
395         failure("Could not find match for ACL "
396             "(type=%d,permset=%d,tag=%d,qual=%d,name=``%s'')",
397             acls[marker[0]].type, acls[marker[0]].permset,
398             acls[marker[0]].tag, acls[marker[0]].qual, acls[marker[0]].name);
399         assert(n == 0); /* Number of ACLs not matched should == 0 */
400 }
401
402 DEFINE_TEST(test_acl_pax)
403 {
404         int i;
405         struct archive *a;
406         struct archive_entry *ae;
407         size_t used;
408         int fd;
409
410         /* Write an archive to memory. */
411         assert(NULL != (a = archive_write_new()));
412         assertA(0 == archive_write_set_format_pax(a));
413         assertA(0 == archive_write_set_compression_none(a));
414         assertA(0 == archive_write_set_bytes_per_block(a, 1));
415         assertA(0 == archive_write_set_bytes_in_last_block(a, 1));
416         assertA(0 == archive_write_open_memory(a, buff, sizeof(buff), &used));
417
418         /* Write a series of files to the archive with different ACL info. */
419
420         /* Create a simple archive_entry. */
421         assert((ae = archive_entry_new()) != NULL);
422         archive_entry_set_pathname(ae, "file");
423         archive_entry_set_mode(ae, S_IFREG | 0777);
424
425         /* Basic owner/owning group should just update mode bits. */
426         set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
427         assertA(0 == archive_write_header(a, ae));
428
429         /* With any extended ACL entry, we should read back a full set. */
430         set_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]));
431         assertA(0 == archive_write_header(a, ae));
432
433
434         /* A more extensive set of ACLs. */
435         set_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]));
436         assertA(0 == archive_write_header(a, ae));
437
438         /*
439          * Check that clearing ACLs gets rid of them all by repeating
440          * the first test.
441          */
442         set_acls(ae, acls0, sizeof(acls0)/sizeof(acls0[0]));
443         assertA(0 == archive_write_header(a, ae));
444
445         /* Close out the archive. */
446         assertA(0 == archive_write_close(a));
447 #if ARCHIVE_API_VERSION > 1
448         assertA(0 == archive_write_finish(a));
449 #else
450         archive_write_finish(a);
451 #endif
452
453         /* Write out the data we generated to a file for manual inspection. */
454         assert(-1 < (fd = open("testout", O_WRONLY | O_CREAT | O_TRUNC, 0775)));
455         assert(used == write(fd, buff, used));
456         close(fd);
457
458         /* Write out the reference data to a file for manual inspection. */
459         assert(-1 < (fd = open("reference", O_WRONLY | O_CREAT | O_TRUNC, 0775)));
460         assert(sizeof(reference) == write(fd, reference, sizeof(reference)));
461         close(fd);
462
463         /* Assert that the generated data matches the built-in reference data.*/
464         failure("Generated pax archive does not match reference; check 'testout' and 'reference' files.");
465         assert(0 == memcmp(buff, reference, sizeof(reference)));
466         failure("Generated pax archive does not match reference; check 'testout' and 'reference' files.");
467         assertEqualInt(used, sizeof(reference));
468
469         /* Read back each entry and check that the ACL data is right. */
470         assert(NULL != (a = archive_read_new()));
471         assertA(0 == archive_read_support_format_all(a));
472         assertA(0 == archive_read_support_compression_all(a));
473         assertA(0 == archive_read_open_memory(a, buff, used));
474
475         /* First item has no ACLs */
476         assertA(0 == archive_read_next_header(a, &ae));
477         failure("Basic ACLs shouldn't be stored as extended ACLs");
478         assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
479         failure("Basic ACLs should set mode to 0142, not %04o",
480             archive_entry_mode(ae)&0777);
481         assert((archive_entry_mode(ae) & 0777) == 0142);
482
483         /* Second item has a few ACLs */
484         assertA(0 == archive_read_next_header(a, &ae));
485         failure("One extended ACL should flag all ACLs to be returned.");
486         assert(4 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
487         compare_acls(ae, acls1, sizeof(acls1)/sizeof(acls1[0]), 0142);
488         failure("Basic ACLs should set mode to 0142, not %04o",
489             archive_entry_mode(ae)&0777);
490         assert((archive_entry_mode(ae) & 0777) == 0142);
491
492         /* Third item has pretty extensive ACLs */
493         assertA(0 == archive_read_next_header(a, &ae));
494         assertEqualInt(6, archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
495         compare_acls(ae, acls2, sizeof(acls2)/sizeof(acls2[0]), 0543);
496         failure("Basic ACLs should set mode to 0543, not %04o",
497             archive_entry_mode(ae)&0777);
498         assert((archive_entry_mode(ae) & 0777) == 0543);
499
500         /* Fourth item has no ACLs */
501         assertA(0 == archive_read_next_header(a, &ae));
502         failure("Basic ACLs shouldn't be stored as extended ACLs");
503         assert(0 == archive_entry_acl_reset(ae, ARCHIVE_ENTRY_ACL_TYPE_ACCESS));
504         failure("Basic ACLs should set mode to 0142, not %04o",
505             archive_entry_mode(ae)&0777);
506         assert((archive_entry_mode(ae) & 0777) == 0142);
507
508         /* Close the archive. */
509         assertA(0 == archive_read_close(a));
510 #if ARCHIVE_API_VERSION > 1
511         assert(0 == archive_read_finish(a));
512 #else
513         archive_read_finish(a);
514 #endif
515 }