public inbox for gentoo-catalyst@lists.gentoo.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: gentoo-catalyst@lists.gentoo.org
Subject: [gentoo-catalyst] [PATCH 3/4] main: delay root check until before we run
Date: Tue,  6 Oct 2015 12:46:28 -0400	[thread overview]
Message-ID: <1444149989-1258-3-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1444149989-1258-1-git-send-email-vapier@gentoo.org>

This way we can run things like --help and verify argument/config parsing
all as non-root.  Only actual building requires root.
---
 catalyst/main.py | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/catalyst/main.py b/catalyst/main.py
index 4e83414..604c6ab 100644
--- a/catalyst/main.py
+++ b/catalyst/main.py
@@ -168,13 +168,6 @@ def build_target(addlargs):
 
 
 def main():
-
-	if os.getuid() != 0:
-		version()
-		# catalyst cannot be run as a normal user due to chroots, mounts, etc
-		print "!!! catalyst: This script requires root privileges to operate"
-		sys.exit(2)
-
 	# we need some options in order to work correctly
 	if len(sys.argv) < 2:
 		usage()
@@ -342,6 +335,11 @@ def main():
 	if "target" not in addlargs:
 		raise CatalystError("Required value \"target\" not specified.")
 
+	if os.getuid() != 0:
+		# catalyst cannot be run as a normal user due to chroots, mounts, etc
+		print "!!! catalyst: This script requires root privileges to operate"
+		sys.exit(2)
+
 	# everything is setup, so the build is a go
 	try:
 		success = build_target(addlargs)
-- 
2.5.2



  parent reply	other threads:[~2015-10-06 16:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-06 16:46 [gentoo-catalyst] [PATCH 1/4] catalyst: clean up unused module imports Mike Frysinger
2015-10-06 16:46 ` [gentoo-catalyst] [PATCH 2/4] lint: drop use of apply() Mike Frysinger
2015-10-06 16:46 ` Mike Frysinger [this message]
2015-10-06 16:46 ` [gentoo-catalyst] [PATCH 4/4] main: switch to argparse Mike Frysinger
2015-10-06 16:54   ` Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1444149989-1258-3-git-send-email-vapier@gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gentoo-catalyst@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox