summaryrefslogtreecommitdiff
path: root/portato.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2009-03-19 21:10:37 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2009-03-19 21:10:37 +0100
commitabde20daebee82abb754835d6f7c309f7aea3819 (patch)
tree0e9f36dec4c9656df67b373713b4a30a7e1c2f36 /portato.py
parent79586b7b6a02d0f88246574c943f9a01f4dd89b6 (diff)
downloadportato-abde20daebee82abb754835d6f7c309f7aea3819.tar.gz
portato-abde20daebee82abb754835d6f7c309f7aea3819.tar.bz2
portato-abde20daebee82abb754835d6f7c309f7aea3819.zip
Add support for ktsuss as su frontend
Diffstat (limited to 'portato.py')
-rwxr-xr-xportato.py46
1 files changed, 28 insertions, 18 deletions
diff --git a/portato.py b/portato.py
index 800698a..bdf3ddb 100755
--- a/portato.py
+++ b/portato.py
@@ -20,8 +20,9 @@ import atexit
from optparse import OptionParser, SUPPRESS_HELP
from portato import get_listener, log, start
-from portato.helper import debug, info
-from portato.constants import VERSION, SU_COMMAND
+from portato.su import detect_su_command
+from portato.helper import debug, info, error
+from portato.constants import VERSION
def main ():
start() # the first thing to do :)
@@ -74,23 +75,32 @@ def main ():
lt.setDaemon(False)
lt.start()
- # set DBUS_SESSION_BUS_ADDRESS to "" to make dbus work as root ;)
- env = os.environ.copy()
- env.update(DBUS_SESSION_BUS_ADDRESS="")
- cmd = SU_COMMAND.split()
-
- sp = subprocess.Popen(cmd+["%s --no-fork --shm %ld %ld %ld" % (sys.argv[0], mem.key, sig.key, rw.key)], env = env)
-
- # wait for process to finish
try:
- sp.wait()
- debug("Subprocess finished")
- except KeyboardInterrupt:
- debug("Got KeyboardInterrupt.")
-
- if lt.isAlive():
- debug("Listener is still running. Close it.")
- get_listener().close()
+ # set DBUS_SESSION_BUS_ADDRESS to "" to make dbus work as root ;)
+ env = os.environ.copy()
+ env.update(DBUS_SESSION_BUS_ADDRESS="")
+
+ su = detect_su_command()
+ if su:
+ debug("Using '%s' as su command.", su.bin)
+ cmd = su.cmd("%s --no-fork --shm %ld %ld %ld" % (sys.argv[0], mem.key, sig.key, rw.key))
+
+ sp = subprocess.Popen(cmd, env = env)
+
+ # wait for process to finish
+ try:
+ sp.wait()
+ debug("Subprocess finished")
+ except KeyboardInterrupt:
+ debug("Got KeyboardInterrupt.")
+
+ else:
+ error(_("No valid su command detected. Aborting."))
+
+ finally:
+ if lt.isAlive():
+ debug("Listener is still running. Close it.")
+ get_listener().close()
if __name__ == "__main__":
main()