]> arthur.barton.de Git - bup.git/blob - t/root-status
28e2347357b6a0bc1a9ff7e595a3c9f869b10c04
[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 __future__ import absolute_import, print_function
9 from sys import stderr
10 import sys
11
12
13 if sys.platform.startswith('cygwin'):
14     if sys.getwindowsversion()[0] > 5:
15         # Sounds like the situation is much more complicated here
16         print("can't detect root status for OS version > 5; assuming not root",
17               file=stderr)
18         print('none')
19     import ctypes
20     if ctypes.cdll.shell32.IsUserAnAdmin():
21         print('root')
22     else:
23         print('none')
24 else:
25     import os
26     if os.environ.get('FAKEROOTKEY'):
27         print('fake')
28     else:
29         if os.geteuid() == 0:
30             print('root')
31         else:
32             print('none')