3 # Copyright (C) 2000-2015 Kern Sibbald
4 # License: BSD 2-Clause; see file LICENSE-FOSS
8 # Run a backup of the Bacula build directory with some acls then restore it.
11 # Your filesystem must be mounted with the acl option (mount -o remount,acl,user_xattr /tmp)
12 # on ubuntu, the attr package must be installed
14 # For this script to work, you will also need a number of acl packages loaded
15 # not default on Debian derivatives:
16 # apt-get install acl libacl1 libacl1-dev attr
18 # For OSX and Solaris:
20 # Defaults should be ok
24 # Your filesystem must have acls enabled and needs to be mounted with acls.
25 # tunefs -a enable <device>
26 # acls mountoption in /etc/fstab
30 # Defaults should be ok (As NetBSD doesn't support native acls we skip that test).
32 TestName="acl-xattr-test"
37 # See if the right software is installed.
41 # Require getfacl to be installed
42 getfacl Makefile 2>&1 >/dev/null
43 if test $? -ne 0; then
44 echo "$TestName skipped: getfacl not installed"
48 # Require getfattr to be installed
49 getfattr -d Makefile 2>&1 >/dev/null
50 if test $? -ne 0; then
51 echo "$TestName skipped: getfattr not installed"
60 # Require getfacl to be installed
61 getfacl Makefile 2>&1 >/dev/null
62 if test $? -ne 0; then
63 echo "$TestName skipped: getfacl not installed"
67 # Require lsextattr to be installed
68 lsextattr user Makefile 2>&1 >/dev/null
69 if test $? -ne 0; then
70 echo "$TestName skipped: lsextattr not installed"
75 # Require lsextattr to be installed
76 lsextattr user Makefile 2>&1 >/dev/null
77 if test $? -ne 0; then
78 echo "$TestName skipped: lsextattr not installed"
92 # Zap out any schedule in default conf file so that
93 # it doesn't start during our test
96 echo "s% Schedule =%# Schedule =%g" > $outf
97 echo "s/Options {/Options { aclsupport=yes; xattrsupport = yes/" >> $outf
98 cp ${cwd}/bin/bacula-dir.conf $cwd/tmp/1
99 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
107 cp ${cwd}/bin/bconsole $d
111 setfacl -m d:user:$uid:r-x $d/acl-dir 2>/dev/null 1>/dev/null
112 setfacl -m d:user:root:-wx $d/acl-dir 2>/dev/null 1>/dev/null
113 setfacl -m user:nobody:--- $d/acl-dir 2>/dev/null 1>/dev/null
114 setfacl -m user:nobody:--- $d/bconsole 2>/dev/null 1>/dev/null
115 setfacl -m group:nogroup:--x $d/bconsole 2>/dev/null 1>/dev/null
116 cp ${cwd}/bin/bconsole $d/acl-dir
117 cp ${cwd}/bin/bconsole $d/other
118 setfattr -h -n user.bacula.test -v rulez $d/other 2>/dev/null 1>/dev/null
119 setfattr -h -n user.bacula.secondtest -v rulez $d/other 2>/dev/null 1>/dev/null
122 getfacl -R acl 2>/dev/null > $cwd/tmp/org
123 getfattr -h -n user.bacula.test $d/other 2>/dev/null > $cwd/tmp/attr.org
124 getfattr -h -n user.bacula.secondtest $d/other 2>/dev/null >> $cwd/tmp/attr.org
129 chmod +a "user:$username allow read,execute" $d/acl-dir
130 chmod +a "user:root allow write,execute" $d/acl-dir
131 chmod +a "user:nobody deny read,write,execute" $d/acl-dir
132 chmod +a "user:nobody deny read,write,execute" $d/bconsole
133 chmod +a "group:nogroup allow execute" $d/bconsole
134 cp ${cwd}/bin/bconsole $d/acl-dir
135 cp ${cwd}/bin/bconsole $d/other
136 xattr -w bacula.test "rulez" $d/other 2>/dev/null 1>/dev/null
137 xattr -w bacula.secondtest "rulez" $d/other 2>/dev/null 1>/dev/null
140 ls -lde -R acl > $cwd/tmp/org
141 xattr -p bacula.test $d/other 2>/dev/null > $cwd/tmp/attr.org
142 xattr -p bacula.secondtest $d/other 2>/dev/null >> $cwd/tmp/attr.org
147 # See if we need to set ZFS or POSIX acls
149 df -F zfs $d > /dev/null 2>&1
151 /bin/chmod A+user:$uid:rx:allow $d/acl-dir
152 /bin/chmod A+user:root:wx:allow $d/acl-dir
153 /bin/chmod A+user:nobody:rwx:deny $d/acl-dir
154 /bin/chmod A+user:nobody:rwx:deny $d/bconsole
155 /bin/chmod A+group:nogroup:x:allow $d/bconsole
157 /bin/chmod A+user:$uid:r-x $d/acl-dir
158 /bin/chmod A+user:root:-wx $d/acl-dir
159 /bin/chmod A+user:nobody:--- $d/acl-dir
160 /bin/chmod A+user:nobody:--- $d/bconsole
161 /bin/chmod A+group:nogroup:--x $d/bconsole
163 cp ${cwd}/bin/bconsole $d/other
164 /bin/runat $d/other 'cat > bacula.test' << EOF
167 /bin/runat $d/other 'cat > bacula.secondtest' << EOF
171 /bin/ls -ldv -R acl > $cwd/tmp/org
172 /bin/runat $d/other 'cat bacula.test' > $cwd/tmp/attr.org
173 /bin/runat $d/other 'cat bacula.secondtest' >> $cwd/tmp/attr.org
177 setfacl -m d:user:$uid:r-x $d/acl-dir
178 setfacl -m d:user:root:-wx $d/acl-dir
179 setfacl -m user:nobody:--- $d/acl-dir
180 setfacl -m user:nobody:--- $d/bconsole
181 setfacl -m group:nogroup:--x $d/bconsole
182 cp ${cwd}/bin/bconsole $d/acl-dir
183 cp ${cwd}/bin/bconsole $d/other
184 setextattr user bacula.test rulez $d/other 2>/dev/null 1>/dev/null
185 setextattr user bacula.secondtest rulez $d/other 2>/dev/null 1>/dev/null
192 getextattr user bacula.test $d/other 2>/dev/null > $cwd/tmp/attr.org
193 getextattr user bacula.secondtest $d/other 2>/dev/null >> $cwd/tmp/attr.org
197 cp ${cwd}/bin/bconsole $d/other
198 setextattr user bacula.test rulez $d/other 2>/dev/null 1>/dev/null
199 setextattr user bacula.secondtest rulez $d/other 2>/dev/null 1>/dev/null
202 cp /dev/null $cwd/tmp/org
203 getextattr user bacula.test $d/other > $cwd/tmp/attr.org
204 getextattr user bacula.secondtest $d/other >> $cwd/tmp/attr.org
209 change_jobname BackupClient1 $JobName
212 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
215 @$out ${cwd}/tmp/log1.out
216 label volume=TestVolume001 storage=File1 pool=File slot=1 drive=0
217 @#setdebug level=400 trace=1 client
218 @#setdebug level=300 trace=1 director
219 @#setdebug level=300 trace=1 storage=File1
226 @$out ${cwd}/tmp/log2.out
227 restore where=${cwd}/tmp/bacula-restores select all done
235 check_for_zombie_jobs storage=File1
240 ( cd $cwd/tmp/bacula-restores/$cwd/build
241 getfacl -R acl > $cwd/tmp/new
242 getfattr -h -n user.bacula.test $d/other 2>/dev/null > $cwd/tmp/attr.new
243 getfattr -h -n user.bacula.secondtest $d/other 2>/dev/null >> $cwd/tmp/attr.new
247 ( cd $cwd/tmp/bacula-restores/$cwd/build
248 ls -lde -R acl > $cwd/tmp/new
249 xattr -p bacula.test $d/other > $cwd/tmp/attr.new
250 xattr -p bacula.secondtest $d/other >> $cwd/tmp/attr.new
254 ( cd $cwd/tmp/bacula-restores/$cwd/build
255 /bin/ls -ldv -R acl > $cwd/tmp/new
256 /bin/runat $d/other 'cat bacula.test' > $cwd/tmp/attr.new
257 /bin/runat $d/other 'cat bacula.secondtest' >> $cwd/tmp/attr.new
261 ( cd $cwd/tmp/bacula-restores/$cwd/build
266 getextattr user bacula.test $d/other > $cwd/tmp/attr.new
267 getextattr user bacula.secondtest $d/other >> $cwd/tmp/attr.new
271 ( cd $cwd/tmp/bacula-restores/$cwd/build
272 cp /dev/null $cwd/tmp/new
273 getextattr user bacula.test $d/other > $cwd/tmp/attr.new
274 getextattr user bacula.secondtest $d/other >> $cwd/tmp/attr.new
279 diff -u $cwd/tmp/org $cwd/tmp/new
280 if [ $? -ne 0 ]; then
284 diff $cwd/tmp/attr.org $cwd/tmp/attr.new
285 if [ $? -ne 0 ]; then
292 if [ x$REGRESS_DEBUG != x ]; then