]> err.no Git - dak/commitdiff
Change sudo otpion to match dak new-security-instal (-s, --sudo, automatically
authorAnthony Towns <aj@azure.humbug.org.au>
Fri, 21 Mar 2008 20:17:47 +0000 (20:17 +0000)
committerAnthony Towns <aj@azure.humbug.org.au>
Fri, 21 Mar 2008 20:17:47 +0000 (20:17 +0000)
implied for non-dak users)

dak/transitions.py

index 121edc2f4dd88b7277a3b7160b0e13151cbda8ad..d1d62cdf67ef773db6ccd471ef8e57a27bd52f6c 100755 (executable)
@@ -23,7 +23,7 @@
 
 ################################################################################
 
-import os, pg, sys, time, errno, fcntl, tempfile
+import os, pg, sys, time, errno, fcntl, tempfile, pwd
 import apt_pkg
 import daklib.database
 import daklib.utils
@@ -47,7 +47,7 @@ def init():
                  ('e',"edit","Edit-Transitions::Options::Edit"),
                  ('i',"import","Edit-Transitions::Options::Import", "HasArg"),
                  ('c',"check","Edit-Transitions::Options::Check"),
-                 ('S',"use-sudo","Edit-Transitions::Options::Sudo"),
+                 ('s',"sudo","Edit-Transitions::Options::Sudo"),
                  ('n',"no-action","Edit-Transitions::Options::No-Action")]
 
     for i in ["help", "no-action", "edit", "import", "check", "sudo"]:
@@ -58,6 +58,13 @@ def init():
 
     Options = Cnf.SubTree("Edit-Transitions::Options")
 
+    whoami = os.getuid()
+    whoamifull = pwd.getpwuid(whoami)
+    username = whoamifull[0]
+    if username != "dak":
+        print "Non-dak user: %s" % username
+        Options["sudo"] = "y"
+
     projectB = pg.connect(Cnf["DB::Name"], Cnf["DB::Host"], int(Cnf["DB::Port"]))
     daklib.database.init(Cnf, projectB)