From: Joerg Jaspert Date: Sat, 15 Aug 2009 14:57:58 +0000 (+0200) Subject: username foo X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=3241e702ff5018d66448088195ffb93acb5f45ae;p=dak.git username foo add a little function in daklib/utils.py to return the unix username, make nsi and transitions use this Signed-off-by: Joerg Jaspert --- diff --git a/dak/new_security_install.py b/dak/new_security_install.py index f6a7354b..549fe5b5 100755 --- a/dak/new_security_install.py +++ b/dak/new_security_install.py @@ -60,9 +60,7 @@ def init(): Options = Cnf.SubTree("Security-Install::Options") - whoami = os.getuid() - whoamifull = pwd.getpwuid(whoami) - username = whoamifull[0] + username = utils.getusername() if username != "dak": print "Non-dak user: %s" % username Options["Sudo"] = "y" diff --git a/dak/transitions.py b/dak/transitions.py index 2c7d3d83..a214337e 100755 --- a/dak/transitions.py +++ b/dak/transitions.py @@ -85,9 +85,7 @@ def init(): if Options["help"]: usage() - whoami = os.getuid() - whoamifull = pwd.getpwuid(whoami) - username = whoamifull[0] + username = utils.getusername() if username != "dak": print "Non-dak user: %s" % username Options["sudo"] = "y" diff --git a/daklib/utils.py b/daklib/utils.py index 951270b5..073b8133 100755 --- a/daklib/utils.py +++ b/daklib/utils.py @@ -820,6 +820,9 @@ def warn(msg): def whoami (): return pwd.getpwuid(os.getuid())[4].split(',')[0].replace('.', '') +def getusername (): + return pwd.getpwuid(os.getuid())[0] + ################################################################################ def size_type (c):