3 # Run a backup of the Bacula build directory with some acls then restore it.
5 # Your filesystem must be mounted with the acl option (mount -o remount,acl,user_xattr /tmp)
6 # on ubuntu, the attr package must be installed
8 # For this script to work, you will also need a number of acl packages loaded
9 # not default on Debian derivatives:
10 # apt-get install acl libacl1 libacl1-dev attr
12 TestName="acl-xattr-test"
17 # See if the right software is installed.
21 # Require getfacl to be installed
22 getfacl Makefile 2>&1 >/dev/null
23 if test $? -ne 0; then
24 echo "$TestName skipped: getfacl not installed"
28 # Require getfattr to be installed
29 getfattr -d Makefile 2>&1 >/dev/null
30 if test $? -ne 0; then
31 echo "$TestName skipped: getfattr not installed"
49 # Zap out any schedule in default conf file so that
50 # it doesn't start during our test
53 echo "s% Schedule =%# Schedule =%g" > $outf
54 echo "s/Options {/Options { aclsupport=yes; xattrsupport = yes/" >> $outf
55 cp ${cwd}/bin/bacula-dir.conf $cwd/tmp/1
56 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
64 cp ${cwd}/bin/bconsole $d
68 setfacl -m d:user:$uid:r-x $d/acl-dir
69 setfacl -m d:user:root:-wx $d/acl-dir
70 setfacl -m user:nobody:--- $d/acl-dir
71 setfacl -m user:nobody:--- $d/bconsole
72 setfacl -m group:nogroup:--x $d/bconsole
73 cp ${cwd}/bin/bconsole $d/acl-dir
74 cp ${cwd}/bin/bconsole $d/other
75 setfattr -h -n user.bacula.test -v rulez $d/other 2>/dev/null 1>/dev/null
78 getfacl -R acl > $cwd/tmp/org
79 getfattr -h -n user.bacula.test $d/other > $cwd/tmp/attr.org
83 chmod +a "user:$uid allow read execute" $d/acl-dir
84 chmod +a "user:root allow write execute" $d/acl-dir
85 chmod +a "user:nobody deny read write execute" $d/acl-dir
86 chmod +a "user:nobody deny read write execute" $d/bconsole
87 chmod +a "group:nogroup allow execute" $d/bconsole
88 cp ${cwd}/bin/bconsole $d/acl-dir
89 cp ${cwd}/bin/bconsole $d/other
90 xattr -w bacula.test "rulez" $d/other 2>/dev/null 1>/dev/null
93 ls -lde -R acl > $cwd/tmp/org
94 xattr -p bacula.test $d/other > $cwd/tmp/attr.org
99 # See if we need to set ZFS or POSIX acls
101 df -F zfs $d > /dev/null 2>&1
103 /bin/chmod A+user:$uid:rx:allow $d/acl-dir
104 /bin/chmod A+user:root:wx:allow $d/acl-dir
105 /bin/chmod A+user:nobody:rwx:deny $d/acl-dir
106 /bin/chmod A+user:nobody:rwx:deny $d/bconsole
107 /bin/chmod A+group:nogroup:x:allow $d/bconsole
109 /bin/chmod A+user:$uid:r-x $d/acl-dir
110 /bin/chmod A+user:root:-wx $d/acl-dir
111 /bin/chmod A+user:nobody:--- $d/acl-dir
112 /bin/chmod A+user:nobody:--- $d/bconsole
113 /bin/chmod A+group:nogroup:--x $d/bconsole
115 cp ${cwd}/bin/bconsole $d/other
116 /bin/runat $d/other 'cat > bacula.test' << EOF
120 /bin/ls -ldv -R acl > $cwd/tmp/org
121 /bin/runat $d/other 'cat bacula.test' > $cwd/tmp/attr.org
126 change_jobname BackupClient1 $JobName
129 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
132 @$out ${cwd}/tmp/log1.out
133 label volume=TestVolume001 storage=File pool=File
134 setdebug level=400 trace=1 client
135 setdebug level=300 trace=1 director
136 setdebug level=300 trace=1 storage
143 @$out ${cwd}/tmp/log2.out
144 restore where=${cwd}/tmp/bacula-restores select all done
152 check_for_zombie_jobs storage=File
157 ( cd $cwd/tmp/bacula-restores/$cwd/build
158 getfacl -R acl > $cwd/tmp/new
159 getfattr -h -n user.bacula.test $d/other > $cwd/tmp/attr.new
163 ( cd $cwd/tmp/bacula-restores/$cwd/build
164 ls -lde -R acl > $cwd/tmp/new
165 xattr -p bacula.test $d/other > $cwd/tmp/attr.new
169 ( cd $cwd/tmp/bacula-restores/$cwd/build
170 /bin/ls -ldv -R acl > $cwd/tmp/new
171 /bin/runat $d/other 'cat bacula.test' > $cwd/tmp/attr.new
176 diff -u $cwd/tmp/org $cwd/tmp/new
177 if [ $? -ne 0 ]; then
181 diff $cwd/tmp/attr.org $cwd/tmp/attr.new
182 if [ $? -ne 0 ]; then
189 if [ x$REGRESS_DEBUG != x ]; then