From 3241e702ff5018d66448088195ffb93acb5f45ae Mon Sep 17 00:00:00 2001 From: Joerg Jaspert Date: Sat, 15 Aug 2009 16:57:58 +0200 Subject: [PATCH] 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 --- dak/new_security_install.py | 4 +--- dak/transitions.py | 4 +--- daklib/utils.py | 3 +++ 3 files changed, 5 insertions(+), 6 deletions(-) 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): -- 2.39.5