summaryrefslogtreecommitdiff
path: root/portato.py
diff options
context:
space:
mode:
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()
.com/PuerkitoBio/goquery/compare/v1.6.0...v1.6.1) Signed-off-by: dependabot[bot] <support@github.com> 2021-01-09Bump github.com/google/uuid from 1.1.2 to 1.1.4dependabot[bot]2-3/+3 Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.1.2 to 1.1.4. - [Release notes](https://github.com/google/uuid/releases) - [Commits](https://github.com/google/uuid/compare/v1.1.2...v1.1.4) Signed-off-by: dependabot[bot] <support@github.com> 2021-01-09Bump github.com/emersion/go-message from 0.14.0 to 0.14.1 (#42)dependabot[bot]2-3/+3 Bumps [github.com/emersion/go-message](https://github.com/emersion/go-message) from 0.14.0 to 0.14.1. - [Release notes](https://github.com/emersion/go-message/releases) - [Commits](https://github.com/emersion/go-message/compare/v0.14.0...v0.14.1) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 2020-11-28Bump github.com/emersion/go-message from 0.13.0 to 0.14.0 (#38)dependabot[bot]2-3/+9 Bumps [github.com/emersion/go-message](https://github.com/emersion/go-message) from 0.13.0 to 0.14.0. - [Release notes](https://github.com/emersion/go-message/releases) - [Commits](https://github.com/emersion/go-message/compare/v0.13.0...v0.14.0) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 2020-11-28Bump github.com/google/go-cmp from 0.5.2 to 0.5.4 (#37)dependabot[bot]2-3/+3 Bumps [github.com/google/go-cmp](https://github.com/google/go-cmp) from 0.5.2 to 0.5.4. - [Release notes](https://github.com/google/go-cmp/releases) - [Commits](https://github.com/google/go-cmp/compare/v0.5.2...v0.5.4) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> 2020-11-23Fix release.ymlv0.5.2René 'Necoro' Neumann1-3/+10 2020-11-23Prepare v0.5.2René 'Necoro' Neumann3-3/+8 2020-11-20Bump github.com/gabriel-vasile/mimetype from 1.1.1 to 1.1.2dependabot[bot]2-3/+3 Bumps [github.com/gabriel-vasile/mimetype](https://github.com/gabriel-vasile/mimetype) from 1.1.1 to 1.1.2. - [Release notes](https://github.com/gabriel-vasile/mimetype/releases) - [Changelog](https://github.com/gabriel-vasile/mimetype/blob/master/CHANGELOG.md) - [Commits](https://github.com/gabriel-vasile/mimetype/compare/v1.1.1...v1.1.2) Signed-off-by: dependabot[bot] <support@github.com> 2020-11-04Clean dependabot.ymlRené 'Necoro' Neumann1-4/+0