]> git.sur5r.net Git - bacula/bacula/blobdiff - regress/tests/acl-xattr-test
Merge branch 'master' into basejobv3
[bacula/bacula] / regress / tests / acl-xattr-test
index c0c6f46aa03fbe05fd9d95054251a3950a37ece5..3a28ab2a2ac15a15e0df8106afe740f66432ba6f 100755 (executable)
@@ -14,21 +14,34 @@ TestName="acl-xattr-test"
 JobName=backup
 . scripts/functions
 
-require_linux
-
-# Require getfacl to be installed
-getfacl Makefile 2>&1 >/dev/null
-if test  $? -ne 0; then
-  echo "$TestName skipped: getfacl not installed"
-  exit 0
-fi
-
-# Require attr to be installed
-attr -l Makefile 2>&1 >/dev/null
-if test $? -ne 0; then
-  echo "$TestName skipped: attr not installed"
-  exit 0
-fi
+#
+# See if the right software is installed.
+#
+case `uname -s` in
+   Linux)
+      # Require getfacl to be installed
+      getfacl Makefile 2>&1 >/dev/null
+      if test  $? -ne 0; then
+        echo "$TestName skipped: getfacl not installed"
+        exit 0
+      fi
+
+      # Require attr to be installed
+      attr -l Makefile 2>&1 >/dev/null
+      if test $? -ne 0; then
+        echo "$TestName skipped: attr not installed"
+        exit 0
+      fi
+      ;;
+   Darwin)
+      ;;
+   SunOS)
+      ;;
+   *)
+      echo "Unsupported OS"
+      exit 0
+      ;;
+esac
 
 scripts/cleanup
 scripts/copy-confs
@@ -47,31 +60,78 @@ d=${cwd}/build/acl
 
 uid=`id -u`
 rm -rf $d
-mkdir $d
-mkdir $d/testdir
+mkdir -p $d
+mkdir -p $d/acl-dir
 cp ${cwd}/bin/bconsole $d
-setfacl -m d:user:$uid:r-x $d/testdir
-setfacl -m d:user:root:-wx $d/testdir
-setfacl -m user:nobody:--- $d/testdir
-setfacl -m user:nobody:--- $d/bconsole
-setfacl -m group:nogroup:--x $d/bconsole
-cp ${cwd}/bin/bconsole $d/testdir
-cp ${cwd}/bin/bconsole $d/other
-attr -s bacula.test -V rulez $d/other 2>/dev/null 1>/dev/null
-
-( cd $cwd/build
-  getfacl -R acl > $cwd/tmp/org
-  attr -g bacula.test $d/other > $cwd/tmp/attr.org
-)
+
+case `uname -s` in
+   Linux)
+      setfacl -m d:user:$uid:r-x $d/acl-dir
+      setfacl -m d:user:root:-wx $d/acl-dir
+      setfacl -m user:nobody:--- $d/acl-dir
+      setfacl -m user:nobody:--- $d/bconsole
+      setfacl -m group:nogroup:--x $d/bconsole
+      cp ${cwd}/bin/bconsole $d/acl-dir
+      cp ${cwd}/bin/bconsole $d/other
+      attr -s bacula.test -V rulez $d/other 2>/dev/null 1>/dev/null
+
+      ( cd $cwd/build
+        getfacl -R acl > $cwd/tmp/org
+        attr -g bacula.test $d/other > $cwd/tmp/attr.org
+      )
+      ;;
+   Darwin)
+      chmod +a "user:$uid allow read execute" $d/acl-dir
+      chmod +a "user:root allow write execute" $d/acl-dir
+      chmod +a "user:nobody deny read write execute" $d/acl-dir
+      chmod +a "user:nobody deny read write execute" $d/bconsole
+      chmod +a "group:nogroup allow execute" $d/bconsole
+      cp ${cwd}/bin/bconsole $d/acl-dir
+      cp ${cwd}/bin/bconsole $d/other
+      xattr -w  bacula.test "rulez" $d/other 2>/dev/null 1>/dev/null
+
+      ( cd $cwd/build
+        ls -lde -R acl > $cwd/tmp/org
+        xattr -p bacula.test $d/other > $cwd/tmp/attr.org
+      )
+      ;;
+   SunOS)
+      #
+      # See if we need to set ZFS or POSIX acls
+      #
+      df -F zfs $d > /dev/null 2>&1
+      if [ $? = 0 ]; then
+         /bin/chmod A+user:$uid:rx:allow $d/acl-dir
+         /bin/chmod A+user:root:wx:allow $d/acl-dir
+         /bin/chmod A+user:nobody:rwx:deny $d/acl-dir
+         /bin/chmod A+user:nobody:rwx:deny $d/bconsole
+         /bin/chmod A+group:nogroup:x:allow $d/bconsole
+      else
+         /bin/chmod A+user:$uid:r-x $d/acl-dir
+         /bin/chmod A+user:root:-wx $d/acl-dir
+         /bin/chmod A+user:nobody:--- $d/acl-dir
+         /bin/chmod A+user:nobody:--- $d/bconsole
+         /bin/chmod A+group:nogroup:--x $d/bconsole
+      fi
+      cp ${cwd}/bin/bconsole $d/other
+      /bin/runat $d/other 'cat > bacula.test' << EOF
+rulez
+EOF
+      ( cd $cwd/build
+        /bin/ls -ldv -R acl > $cwd/tmp/org
+        /bin/runat $d/other 'cat bacula.test' > $cwd/tmp/attr.org
+      )
+      ;;
+esac
 
 change_jobname BackupClient1 $JobName
 start_test
 
 cat <<END_OF_DATA >${cwd}/tmp/bconcmds
-@output /dev/null
+@$out /dev/null
 messages
 @$out ${cwd}/tmp/log1.out
-label volume=TestVolume001 storage=File pool=Default
+label volume=TestVolume001 storage=File pool=File
 setdebug level=400 trace=1 client
 setdebug level=300 trace=1 director
 setdebug level=300 trace=1 storage
@@ -86,7 +146,6 @@ restore where=${cwd}/tmp/bacula-restores select all done
 yes
 wait
 messages
-@$out
 quit
 END_OF_DATA
 
@@ -94,10 +153,26 @@ run_bacula
 check_for_zombie_jobs storage=File
 stop_bacula
 
-( cd $cwd/tmp/bacula-restores/$cwd/build
-  getfacl -R acl > $cwd/tmp/new
-  attr -g bacula.test $d/other > $cwd/tmp/attr.new
-)
+case `uname -s` in
+   Linux)
+      ( cd $cwd/tmp/bacula-restores/$cwd/build
+        getfacl -R acl > $cwd/tmp/new
+        attr -g bacula.test $d/other > $cwd/tmp/attr.new
+      )
+      ;;
+   Darwin)
+      ( cd $cwd/tmp/bacula-restores/$cwd/build
+        ls -lde -R acl > $cwd/tmp/new
+        xattr -p bacula.test $d/other > $cwd/tmp/attr.new
+      )
+      ;;
+   SunOS)
+      ( cd $cwd/tmp/bacula-restores/$cwd/build
+        /bin/ls -ldv -R acl > $cwd/tmp/new
+        /bin/runat $d/other 'cat bacula.test' > $cwd/tmp/attr.new
+      )
+      ;;
+esac
 
 diff -u $cwd/tmp/org $cwd/tmp/new
 if [ $? -ne 0 ]; then