From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id E20A613888F for ; Tue, 6 Oct 2015 16:46:35 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5720B21C03A; Tue, 6 Oct 2015 16:46:33 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D654C21C001 for ; Tue, 6 Oct 2015 16:46:32 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.gentoo.org (Postfix) with ESMTP id 0CF63340A5C for ; Tue, 6 Oct 2015 16:46:31 +0000 (UTC) From: Mike Frysinger 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 Message-Id: <1444149989-1258-3-git-send-email-vapier@gentoo.org> X-Mailer: git-send-email 2.5.2 In-Reply-To: <1444149989-1258-1-git-send-email-vapier@gentoo.org> References: <1444149989-1258-1-git-send-email-vapier@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-catalyst@lists.gentoo.org Reply-to: gentoo-catalyst@lists.gentoo.org X-Archives-Salt: 741073cc-2b6a-4248-b2c9-75734120c5c9 X-Archives-Hash: 94354e540cf5242dec3c92958597a1a7 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