]> git.ipfire.org Git - pakfire.git/commitdiff
Check if pakfire is run by the root user.
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Feb 2011 23:44:37 +0000 (00:44 +0100)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 25 Feb 2011 23:44:37 +0000 (00:44 +0100)
pakfire/__init__.py
pakfire/cli.py

index 11e0f37232445303079c11e4623c97d72534dce5..ced0aae8e21346478ba61b3374e8d5af1c69447f 100644 (file)
@@ -26,6 +26,9 @@ __version__ = 0.1
 class Pakfire(object):
        def __init__(self, path="/tmp/pakfire", builder=False, configs=[],
                        disable_repos=None):
+               # Check if we are operating as the root user.
+               self.check_root_user()
+
                # The path where we are operating in
                self.path = path
 
@@ -73,6 +76,10 @@ class Pakfire(object):
                # always work with valid data.
                self.repos.update_indexes()
 
+       def check_root_user(self):
+               if not os.getuid() == 0 or not os.getgid() == 0:
+                       raise Exception, "You must run pakfire as the root user."
+
        def check_build_mode(self):
                """
                        Check if we are running in build mode.
index 5bbe08a8c3afb3a08efbff6511072a3dbcef6263..40bd3e9b048ae94053a70be20148ec6dc5a7a9c2 100644 (file)
@@ -30,8 +30,6 @@ def ask_user(question):
 
 
 class Cli(object):
-       # XXX check if we are running as the root user
-
        def __init__(self):
                self.parser = argparse.ArgumentParser(
                        description = _("Pakfire command line interface."),