diff options
author | vieira <vieira@yubo.be> | 2016-10-27 23:37:48 +0000 |
---|---|---|
committer | Brian May <brian@linuxpenguins.xyz> | 2016-10-30 10:58:03 +1100 |
commit | 6d5d0d766f85eea41654dc0ec6130640c09078f4 (patch) | |
tree | 5a8d81bcdf17360fbcdf0d1300d1b7f5079dc03f /sshuttle/sdnotify.py | |
parent | 08fb3be7a0ae5ec927d10f90f34c7955bbd73186 (diff) |
Tests and documentation for systemd integration
Some tests and documentation for the systemd notification feature.
Also fixes some corner case issues detected while writing the tests.
Diffstat (limited to 'sshuttle/sdnotify.py')
-rw-r--r-- | sshuttle/sdnotify.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/sshuttle/sdnotify.py b/sshuttle/sdnotify.py index 665d953..ac478f4 100644 --- a/sshuttle/sdnotify.py +++ b/sshuttle/sdnotify.py @@ -1,6 +1,6 @@ import socket import os -from sshuttle.helpers import debug1, debug2, debug3 +from sshuttle.helpers import debug1 def _notify(message): addr = os.environ.get("NOTIFY_SOCKET", None) @@ -12,17 +12,18 @@ def _notify(message): try: sock = socket.socket(socket.AF_UNIX, socket.SOCK_DGRAM) - except socket.error as e: - debug1("Error creating socket to notify to systemd: %s\n" % e) + except (OSError, IOError) as e: + debug1("Error creating socket to notify systemd: %s\n" % e) + return False - if not (sock and message): + if not message: return False assert isinstance(message, bytes) try: return (sock.sendto(message, addr) > 0) - except socket.error as e: + except (OSError, IOError) as e: debug1("Error notifying systemd: %s\n" % e) return False |