If we're not root and the "fakeroot" command is available, use it
authorWayne Davison <wayned@samba.org>
Fri, 18 Mar 2005 02:07:25 +0000 (02:07 +0000)
committerWayne Davison <wayned@samba.org>
Fri, 18 Mar 2005 02:07:25 +0000 (02:07 +0000)
to re-run the script while pretending to be root.

testsuite/chown.test
testsuite/devices.test

index 755ffdf84730695ffc02181295c3e66f895232bb..8f3a3e089b38a7028537bf9706a16abddaebd580 100644 (file)
 
 set -x
 
+case `id -u` in
+'') ;; # If "id" failed, try to continue...
+0)  ;;
+*)  if [ -f /usr/bin/fakeroot ]; then
+       exec /usr/bin/fakeroot /bin/sh "$0"
+    fi
+    ;;
+esac
+
 # Build some hardlinks
 
 mkdir "$fromdir"
index 3e8f4077589b4012645f68841e09fb5f0ddd3929..4401572e4254b99fdff42470dc428fd70bdbe1e1 100644 (file)
 
 case `id -u` in
 '') ;; # If "id" failed, try to continue...
-0) ;;
-*) test_skipped "Rsync won't copy devices unless we're root" ;;
+0)  ;;
+*)  if [ -f /usr/bin/fakeroot ]; then
+       exec /usr/bin/fakeroot /bin/sh "$0"
+    fi
+    test_skipped "Rsync won't copy devices unless we're root"
+    ;;
 esac
 
 # TODO: Need to test whether hardlinks are possible on this OS/filesystem