Gentoo Archives: gentoo-catalyst

From: Mike Frysinger <vapier@g.o>
To: gentoo-catalyst@l.g.o
Subject: [gentoo-catalyst] [PATCH 3/4] main: delay root check until before we run
Date: Tue, 06 Oct 2015 16:46:35
Message-Id: 1444149989-1258-3-git-send-email-vapier@gentoo.org
In Reply to: [gentoo-catalyst] [PATCH 1/4] catalyst: clean up unused module imports by Mike Frysinger
1 This way we can run things like --help and verify argument/config parsing
2 all as non-root. Only actual building requires root.
3 ---
4 catalyst/main.py | 12 +++++-------
5 1 file changed, 5 insertions(+), 7 deletions(-)
6
7 diff --git a/catalyst/main.py b/catalyst/main.py
8 index 4e83414..604c6ab 100644
9 --- a/catalyst/main.py
10 +++ b/catalyst/main.py
11 @@ -168,13 +168,6 @@ def build_target(addlargs):
12
13
14 def main():
15 -
16 - if os.getuid() != 0:
17 - version()
18 - # catalyst cannot be run as a normal user due to chroots, mounts, etc
19 - print "!!! catalyst: This script requires root privileges to operate"
20 - sys.exit(2)
21 -
22 # we need some options in order to work correctly
23 if len(sys.argv) < 2:
24 usage()
25 @@ -342,6 +335,11 @@ def main():
26 if "target" not in addlargs:
27 raise CatalystError("Required value \"target\" not specified.")
28
29 + if os.getuid() != 0:
30 + # catalyst cannot be run as a normal user due to chroots, mounts, etc
31 + print "!!! catalyst: This script requires root privileges to operate"
32 + sys.exit(2)
33 +
34 # everything is setup, so the build is a go
35 try:
36 success = build_target(addlargs)
37 --
38 2.5.2