# Assumes shell is Bash.
-actually-root()
-{
- test "$(whoami)" == root -a -z "$FAKEROOTKEY"
-}
-
force-delete()
{
# Try *hard* to delete $@. Among other things, some systems have
--- /dev/null
+#!/usr/bin/env python
+
+import sys
+
+if sys.platform.startswith('cygwin'):
+ import ctypes
+ if ctypes.cdll.shell32.IsUserAnAdmin():
+ print 'root'
+ else:
+ print 'none'
+else:
+ import os
+ if os.environ.get('FAKEROOTKEY'):
+ print 'fake'
+ else:
+ if os.geteuid() == 0:
+ print 'root'
+ else:
+ print 'none'
set -ex -o pipefail
-if ! actually-root; then
+if t/root-status != root; then
echo 'Not root: skipping --check-device tests.'
exit 0 # FIXME: add WVSKIP.
fi
universal-cleanup()
{
- if ! actually-root; then return 0; fi
+ if t/root-status != root; then return 0; fi
cd "$TOP"
umount "$TOP/bupmeta.tmp/testfs" || true
umount "$TOP/bupmeta.tmp/testfs-limited" || true
# Test ownership restoration (when not root or fakeroot).
(
- if test "$(whoami)" == root; then
+ if t/root-status != none; then
exit 0
fi
# Test ownership restoration (when root or fakeroot).
(
- if test "$(whoami)" != root; then
+ if t/root-status == none; then
exit 0
fi
# Root-only tests that require an FS with all the trimmings: ACLs,
# Linux attr, Linux xattr, etc.
-if actually-root; then
+if t/root-status == root; then
(
set -e
# Some cleanup handled in universal-cleanup() above.