]> git.sur5r.net Git - bacula/bacula/blob - regress/tests/acl-xattr-test
Add acl script code for Mac
[bacula/bacula] / regress / tests / acl-xattr-test
1 #!/bin/sh
2 #
3 # Run a backup of the Bacula build directory with some acls
4 #   then restore it.
5 #
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
8 #
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
12 #
13 TestName="acl-xattr-test"
14 JobName=backup
15 . scripts/functions
16
17 require_linux
18
19 # Require getfacl to be installed
20 getfacl Makefile 2>&1 >/dev/null
21 if test  $? -ne 0; then
22   echo "$TestName skipped: getfacl not installed"
23   exit 0
24 fi
25
26 # Require attr to be installed
27 attr -l Makefile 2>&1 >/dev/null
28 if test $? -ne 0; then
29   echo "$TestName skipped: attr not installed"
30   exit 0
31 fi
32
33 scripts/cleanup
34 scripts/copy-confs
35
36 #
37 # Zap out any schedule in default conf file so that
38 #  it doesn't start during our test
39 #
40 outf="tmp/sed_tmp"
41 echo "s%  Schedule =%# Schedule =%g" > $outf
42 echo "s/Options {/Options { aclsupport=yes; xattrsupport = yes/" >> $outf
43 cp ${cwd}/bin/bacula-dir.conf  $cwd/tmp/1
44 sed -f ${outf} ${cwd}/tmp/1 >${cwd}/bin/bacula-dir.conf
45
46 d=${cwd}/build/acl
47
48 uid=`id -u`
49 rm -rf $d
50 mkdir $d
51 mkdir $d/testdir
52 cp ${cwd}/bin/bconsole $d
53
54 case `uname -s` in
55    Linux)
56       setfacl -m d:user:$uid:r-x $d/testdir
57       setfacl -m d:user:root:-wx $d/testdir
58       setfacl -m user:nobody:--- $d/testdir
59       setfacl -m user:nobody:--- $d/bconsole
60       setfacl -m group:nogroup:--x $d/bconsole
61       cp ${cwd}/bin/bconsole $d/testdir
62       cp ${cwd}/bin/bconsole $d/other
63       attr -s bacula.test -V rulez $d/other 2>/dev/null 1>/dev/null
64
65       ( cd $cwd/build
66         getfacl -R acl > $cwd/tmp/org
67         attr -g bacula.test $d/other > $cwd/tmp/attr.org
68       )
69       ;;
70    Darwin)
71       chmod +a "user:$uid allow read execute" $d/testdir
72       chmod +a "user:root allow write execute" $d/testdir
73       chmod +a "user:nobody deny read write execute" $d/testdir
74       chmod +a "user:nobody deny read write execute" $d/bconsole
75       chmod +a "group:nogroup allow execute" $d/bconsole
76       cp ${cwd}/bin/bconsole $d/testdir
77       cp ${cwd}/bin/bconsole $d/other
78       xattr -w  bacula.test "rulez" $d/other 2>/dev/null 1>/dev/null
79
80       ( cd $cwd/build
81         ls -lde -R acl > $cwd/tmp/org
82         xattr -p bacula.test $d/other > $cwd/tmp/attr.org
83       )
84       ;;
85 esac
86
87
88 change_jobname BackupClient1 $JobName
89 start_test
90
91 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
92 @$out /dev/null
93 messages
94 @$out ${cwd}/tmp/log1.out
95 label volume=TestVolume001 storage=File pool=Default
96 setdebug level=400 trace=1 client
97 setdebug level=300 trace=1 director
98 setdebug level=300 trace=1 storage
99 run job=$JobName yes
100 wait
101 messages
102 @# 
103 @# now do a restore
104 @#
105 @$out ${cwd}/tmp/log2.out  
106 restore where=${cwd}/tmp/bacula-restores select all done
107 yes
108 wait
109 messages
110 quit
111 END_OF_DATA
112
113 run_bacula
114 check_for_zombie_jobs storage=File
115 stop_bacula
116
117 ( cd $cwd/tmp/bacula-restores/$cwd/build
118   getfacl -R acl > $cwd/tmp/new
119   attr -g bacula.test $d/other > $cwd/tmp/attr.new
120 )
121
122 diff -u $cwd/tmp/org $cwd/tmp/new
123 if [ $? -ne 0 ]; then
124    rstat=1
125 fi
126
127 diff $cwd/tmp/attr.org $cwd/tmp/attr.new
128 if [ $? -ne 0 ]; then
129    rstat=1
130 fi
131
132 check_two_logs
133 check_restore_diff
134
135 if [ x$REGRESS_DEBUG != x ]; then
136   rm -rf $d
137 fi
138
139 end_test