[dak/master] 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 <joerg@debian.org>
---
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 f6a7354..549fe5b 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 2c7d3d8..a214337 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 951270b..073b813 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):
--
1.5.6.5
Reply to: