]> Dogcows Code - chaz/tar/blob - tests/acls03.at
testsuite: add test for buggy default ACLs
[chaz/tar] / tests / acls03.at
1 # Process this file with autom4te to create testsuite. -*- Autotest -*-
2 #
3 # Test suite for GNU tar.
4 # Copyright 2013 Free Software Foundation, Inc.
5
6 # This file is part of GNU tar.
7
8 # GNU tar is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 3 of the License, or
11 # (at your option) any later version.
12
13 # GNU tar is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
17
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #
21 # Test description:
22 #
23 # Check the storing/restoring with/without default ACLs. When --acls is passed,
24 # restored directory tree should always match archive contents (even when the
25 # archive does not contain any ACLs).
26 #
27 # References:
28 # http://www.mail-archive.com/bug-tar@gnu.org/msg04355.html
29
30 AT_SETUP([acls: default ACLs])
31 AT_KEYWORDS([xattrs acls acls03])
32
33 m4_define([ACL_LISTDIR], [
34 cd $1
35 $1="$(find d1 | sort | xargs -n 1 getfacl)"
36 cd ..
37 ])
38
39 m4_define([ACL_ASSERT], [
40 echo "$$1" > $1.log
41 echo "$$2" > $2.log
42 if test ! "$$1" "$3" "$$2"; then
43 echo "bad '$1' against '$2' output"
44 fi
45 ])
46
47 AT_TAR_CHECK([
48 AT_XATTRS_UTILS_PREREQ
49 AT_ACLS_PREREQ
50 AT_SORT_PREREQ
51
52 MYNAME=$( id -un )
53 MYGROUP=$( id -gn )
54
55 # Prepare directory structure with default ACLs
56 mkdir -p pure/d1/d2
57 genfile --file pure/d1/f2a
58 genfile --file pure/d1/f2b
59 genfile --file pure/d1/d2/f3a
60 genfile --file pure/d1/d2/f3b
61 setfacl -m g:$MYGROUP:r-x pure/d1
62 setfacl -d -m g:$MYGROUP:rwx pure/d1
63 setfacl -d -m u:$MYNAME:rwx pure/d1
64 # "*a" files have "some" additional ACLs
65 setfacl -m u:$MYNAME:--- pure/d1/d2/f3a
66 setfacl -m u:$MYNAME:--- pure/d1/f2a
67
68 # use default format (no acls stored)
69 tar -cf noacl.tar -C pure d1
70
71 # use posix format, acls stored
72 tar --acls -cf acl.tar -C pure d1
73
74 # Directory names are chosen based on "how the files were extracted from
75 # archive". Equivalent no* tags are used also:
76 # ^sacl_ — extracted archive has stored ACLs
77 # _def_ — target directory (-C) has default ACLs
78 # _optacl$ — extraction was done with --acls option
79
80 mkdir sacl_def_optacl
81 mkdir sacl_def_optnoacl
82 mkdir sacl_nodef_optacl
83 mkdir sacl_nodef_optnoacl
84 mkdir nosacl_def_optacl
85 mkdir nosacl_def_optnoacl
86 mkdir nosacl_nodef_optacl
87 mkdir nosacl_nodef_optnoacl
88
89 setfacl -d -m u:$MYNAME:--- nosacl_def_optnoacl sacl_def_optnoacl sacl_def_optacl nosacl_def_optacl
90 setfacl -d -m u:$MYGROUP:--- nosacl_def_optnoacl sacl_def_optnoacl sacl_def_optacl nosacl_def_optacl
91
92 tar -xf acl.tar -C sacl_nodef_optnoacl
93 tar --acls -xf acl.tar -C sacl_nodef_optacl
94 tar -xf acl.tar -C sacl_def_optnoacl
95 tar --acls -xf acl.tar -C sacl_def_optacl
96 tar -xf noacl.tar -C nosacl_def_optnoacl
97 # _NO_ ACLs in output
98 tar -xf noacl.tar -C nosacl_nodef_optnoacl
99 tar -xf noacl.tar -C nosacl_nodef_optacl
100 tar -cf noacl_repackaged.tar -C nosacl_nodef_optnoacl d1
101 # _NO_ ACLs in output (even when default ACLs exist)
102 tar --acls -xf noacl_repackaged.tar -C nosacl_def_optacl
103
104 ACL_LISTDIR(pure)
105
106 ACL_LISTDIR(sacl_def_optacl)
107 ACL_LISTDIR(sacl_def_optnoacl)
108 ACL_LISTDIR(sacl_nodef_optacl)
109 ACL_LISTDIR(sacl_nodef_optnoacl)
110 ACL_LISTDIR(nosacl_def_optacl)
111 ACL_LISTDIR(nosacl_def_optnoacl)
112 ACL_LISTDIR(nosacl_nodef_optacl)
113 ACL_LISTDIR(nosacl_nodef_optnoacl)
114
115 ACL_ASSERT(pure, sacl_def_optacl, =)
116
117 ACL_ASSERT(sacl_def_optacl, sacl_nodef_optacl, =)
118 ACL_ASSERT(sacl_def_optnoacl, nosacl_def_optnoacl, =)
119 ACL_ASSERT(sacl_nodef_optnoacl, nosacl_nodef_optnoacl, =)
120 ACL_ASSERT(nosacl_def_optacl, nosacl_nodef_optacl, =)
121 ACL_ASSERT(nosacl_def_optacl, nosacl_nodef_optnoacl, =)
122
123 ACL_ASSERT(sacl_def_optacl, sacl_def_optnoacl, !=)
124 ACL_ASSERT(sacl_def_optacl, nosacl_def_optnoacl, !=)
125 ACL_ASSERT(nosacl_def_optnoacl, nosacl_nodef_optnoacl, !=)
126 ],
127 [0],
128 [],
129 [])
130
131 AT_CLEANUP
This page took 0.034432 seconds and 4 git commands to generate.