3 # Run a backup of the Bacula build directory with some acls then restore it.
6 # Your filesystem must be mounted with the acl option (mount -o remount,acl,user_xattr /tmp)
7 # on ubuntu, the attr package must be installed
9 # For this script to work, you will also need a number of acl packages loaded
10 # not default on Debian derivatives:
11 # apt-get install acl libacl1 libacl1-dev attr
13 # For OSX and Solaris:
15 # Defaults should be ok
19 # Your filesystem must have acls enabled and needs to be mounted with acls.
20 # tunefs -a enable <device>
21 # acls mountoption in /etc/fstab
25 # Defaults should be ok (As NetBSD doesn't support native acls we skip that test).
27 TestName="acl-xattr-test"
32 # See if the right software is installed.
36 # Require getfacl to be installed
37 getfacl Makefile 2>&1 >/dev/null
38 if test $? -ne 0; then
39 echo "$TestName skipped: getfacl not installed"
43 # Require getfattr to be installed
44 getfattr -d Makefile 2>&1 >/dev/null
45 if test $? -ne 0; then
46 echo "$TestName skipped: getfattr not installed"
55 # Require getfacl to be installed
56 getfacl Makefile 2>&1 >/dev/null
57 if test $? -ne 0; then
58 echo "$TestName skipped: getfacl not installed"
62 # Require lsextattr to be installed
63 lsextattr user Makefile 2>&1 >/dev/null
64 if test $? -ne 0; then
65 echo "$TestName skipped: lsextattr not installed"
70 # Require lsextattr to be installed
71 lsextattr user Makefile 2>&1 >/dev/null
72 if test $? -ne 0; then
73 echo "$TestName skipped: lsextattr not installed"
87 # Zap out any schedule in default conf file so that
88 # it doesn't start during our test
91 echo "s% Schedule =%# Schedule =%g" > $outf
92 echo "s/Options {/Options { aclsupport=yes; xattrsupport = yes/" >> $outf
93 cp ${cwd}/bin/bacula-dir.conf $cwd/tmp/1
94 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
102 cp ${cwd}/bin/bconsole $d
106 setfacl -m d:user:$uid:r-x $d/acl-dir
107 setfacl -m d:user:root:-wx $d/acl-dir
108 setfacl -m user:nobody:--- $d/acl-dir
109 setfacl -m user:nobody:--- $d/bconsole
110 setfacl -m group:nogroup:--x $d/bconsole
111 cp ${cwd}/bin/bconsole $d/acl-dir
112 cp ${cwd}/bin/bconsole $d/other
113 setfattr -h -n user.bacula.test -v rulez $d/other 2>/dev/null 1>/dev/null
114 setfattr -h -n user.bacula.secondtest -v rulez $d/other 2>/dev/null 1>/dev/null
117 getfacl -R acl > $cwd/tmp/org
118 getfattr -h -n user.bacula.test $d/other > $cwd/tmp/attr.org
119 getfattr -h -n user.bacula.secondtest $d/other > $cwd/tmp/attr.org
124 chmod +a "user:$username allow read,execute" $d/acl-dir
125 chmod +a "user:root allow write,execute" $d/acl-dir
126 chmod +a "user:nobody deny read,write,execute" $d/acl-dir
127 chmod +a "user:nobody deny read,write,execute" $d/bconsole
128 chmod +a "group:nogroup allow execute" $d/bconsole
129 cp ${cwd}/bin/bconsole $d/acl-dir
130 cp ${cwd}/bin/bconsole $d/other
131 xattr -w bacula.test "rulez" $d/other 2>/dev/null 1>/dev/null
132 xattr -w bacula.secondtest "rulez" $d/other 2>/dev/null 1>/dev/null
135 ls -lde -R acl > $cwd/tmp/org
136 xattr -p bacula.test $d/other > $cwd/tmp/attr.org
137 xattr -p bacula.secondtest $d/other > $cwd/tmp/attr.org
142 # See if we need to set ZFS or POSIX acls
144 df -F zfs $d > /dev/null 2>&1
146 /bin/chmod A+user:$uid:rx:allow $d/acl-dir
147 /bin/chmod A+user:root:wx:allow $d/acl-dir
148 /bin/chmod A+user:nobody:rwx:deny $d/acl-dir
149 /bin/chmod A+user:nobody:rwx:deny $d/bconsole
150 /bin/chmod A+group:nogroup:x:allow $d/bconsole
152 /bin/chmod A+user:$uid:r-x $d/acl-dir
153 /bin/chmod A+user:root:-wx $d/acl-dir
154 /bin/chmod A+user:nobody:--- $d/acl-dir
155 /bin/chmod A+user:nobody:--- $d/bconsole
156 /bin/chmod A+group:nogroup:--x $d/bconsole
158 cp ${cwd}/bin/bconsole $d/other
159 /bin/runat $d/other 'cat > bacula.test' << EOF
162 /bin/runat $d/other 'cat > bacula.secondtest' << EOF
166 /bin/ls -ldv -R acl > $cwd/tmp/org
167 /bin/runat $d/other 'cat bacula.test' > $cwd/tmp/attr.org
168 /bin/runat $d/other 'cat bacula.secondtest' > $cwd/tmp/attr.org
172 setfacl -m d:user:$uid:r-x $d/acl-dir
173 setfacl -m d:user:root:-wx $d/acl-dir
174 setfacl -m user:nobody:--- $d/acl-dir
175 setfacl -m user:nobody:--- $d/bconsole
176 setfacl -m group:nogroup:--x $d/bconsole
177 cp ${cwd}/bin/bconsole $d/acl-dir
178 cp ${cwd}/bin/bconsole $d/other
179 setextattr user bacula.test rulez $d/other 2>/dev/null 1>/dev/null
180 setextattr user bacula.secondtest rulez $d/other 2>/dev/null 1>/dev/null
187 getextattr user bacula.test $d/other > $cwd/tmp/attr.org
188 getextattr user bacula.secondtest $d/other > $cwd/tmp/attr.org
192 cp ${cwd}/bin/bconsole $d/other
193 setextattr user bacula.test rulez $d/other 2>/dev/null 1>/dev/null
194 setextattr user bacula.secondtest rulez $d/other 2>/dev/null 1>/dev/null
197 cp /dev/null $cwd/tmp/org
198 getextattr user bacula.test $d/other > $cwd/tmp/attr.org
199 getextattr user bacula.secondtest $d/other > $cwd/tmp/attr.org
204 change_jobname BackupClient1 $JobName
207 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
210 @$out ${cwd}/tmp/log1.out
211 label volume=TestVolume001 storage=File pool=File
212 setdebug level=400 trace=1 client
213 setdebug level=300 trace=1 director
214 setdebug level=300 trace=1 storage
221 @$out ${cwd}/tmp/log2.out
222 restore where=${cwd}/tmp/bacula-restores select all done
230 check_for_zombie_jobs storage=File
235 ( cd $cwd/tmp/bacula-restores/$cwd/build
236 getfacl -R acl > $cwd/tmp/new
237 getfattr -h -n user.bacula.test $d/other > $cwd/tmp/attr.new
238 getfattr -h -n user.bacula.secondtest $d/other > $cwd/tmp/attr.new
242 ( cd $cwd/tmp/bacula-restores/$cwd/build
243 ls -lde -R acl > $cwd/tmp/new
244 xattr -p bacula.test $d/other > $cwd/tmp/attr.new
245 xattr -p bacula.secondtest $d/other > $cwd/tmp/attr.new
249 ( cd $cwd/tmp/bacula-restores/$cwd/build
250 /bin/ls -ldv -R acl > $cwd/tmp/new
251 /bin/runat $d/other 'cat bacula.test' > $cwd/tmp/attr.new
252 /bin/runat $d/other 'cat bacula.secondtest' > $cwd/tmp/attr.new
256 ( cd $cwd/tmp/bacula-restores/$cwd/build
261 getextattr user bacula.test $d/other > $cwd/tmp/attr.new
262 getextattr user bacula.secondtest $d/other > $cwd/tmp/attr.new
266 ( cd $cwd/tmp/bacula-restores/$cwd/build
267 cp /dev/null $cwd/tmp/new
268 getextattr user bacula.test $d/other > $cwd/tmp/attr.new
269 getextattr user bacula.secondtest $d/other > $cwd/tmp/attr.new
274 diff -u $cwd/tmp/org $cwd/tmp/new
275 if [ $? -ne 0 ]; then
279 diff $cwd/tmp/attr.org $cwd/tmp/attr.new
280 if [ $? -ne 0 ]; then
287 if [ x$REGRESS_DEBUG != x ]; then