]> arthur.barton.de Git - bup.git/blob - t/root-status
4f21599f83aaacb98c83b8ccbb1d0b9989d2d0fb
[bup.git] / t / root-status
1 #!/bin/sh
2 """": # -*-python-*-
3 bup_python="$(dirname "$0")/../cmd/bup-python" || exit $?
4 exec "$bup_python" "$0" ${1+"$@"}
5 """
6 # end of bup preamble
7
8 from sys import stderr
9 import sys
10
11
12 if sys.platform.startswith('cygwin'):
13     if sys.getwindowsversion()[0] > 5:
14         # Sounds like the situation is much more complicated here
15         print >> stderr, "can't detect root status for OS version > 5; assuming not root"
16         print 'none'
17     import ctypes
18     if ctypes.cdll.shell32.IsUserAnAdmin():
19         print 'root'
20     else:
21         print 'none'
22 else:
23     import os
24     if os.environ.get('FAKEROOTKEY'):
25         print 'fake'
26     else:
27         if os.geteuid() == 0:
28             print 'root'
29         else:
30             print 'none'