summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKali Kaneko <kali@leap.se>2017-12-19 22:29:15 +0100
committerKali Kaneko <kali@leap.se>2017-12-20 15:36:41 +0100
commitfdf66fccc0b1c2f169bfd72166add45ea3959488 (patch)
tree02198350d5428a8a63e0981a7648ea6ec707622a /src
parent133cd008f451ea997f1093490ca1ec097a17ae1b (diff)
[bug] add lock in command dispatcher
Diffstat (limited to 'src')
-rwxr-xr-xsrc/leap/bitmask/vpn/helpers/osx/bitmask-helper12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/leap/bitmask/vpn/helpers/osx/bitmask-helper b/src/leap/bitmask/vpn/helpers/osx/bitmask-helper
index 53b3ed2a..7c8a80e8 100755
--- a/src/leap/bitmask/vpn/helpers/osx/bitmask-helper
+++ b/src/leap/bitmask/vpn/helpers/osx/bitmask-helper
@@ -60,7 +60,7 @@ from functools import partial
import daemon
import re
-VERSION = "1"
+VERSION = "2"
SCRIPT = "bitmask-helper"
NAMESERVER = "10.42.0.1"
BITMASK_ANCHOR = "com.apple/250.BitmaskFirewall"
@@ -125,6 +125,9 @@ UID = os.getuid()
SERVER_ADDRESS = '/var/run/bitmask-helper.socket'
+cmd_lock = threading.Lock()
+
+
#
# COMMAND DISPATCH
#
@@ -189,16 +192,14 @@ def handle_command(sock):
}
cmd_call = cmd_dict.get(command, None)
- # syslog.syslog(syslog.LOG_WARNING, 'call: %s' % (str(cmd_call)))
+ cmd_lock.acquire()
+
try:
if cmd_call:
- # syslog.syslog(
- # syslog.LOG_WARNING, 'GOT "%s"' % (command))
cmd, args = cmd_call
if args:
cmd = partial(cmd, *args)
- # TODO Use a MUTEX in here
result = cmd()
syslog.syslog(syslog.LOG_WARNING, "%s result: %s" % (
command, str(result)))
@@ -217,6 +218,7 @@ def handle_command(sock):
syslog.syslog(
syslog.LOG_WARNING, "error executing function %r" % (exc))
finally:
+ cmd_lock.release()
sock.close()
#