summaryrefslogtreecommitdiff
path: root/src/leap/eip/config.py
diff options
context:
space:
mode:
authorkali <kali@leap.se>2012-09-06 04:20:23 +0900
committerkali <kali@leap.se>2012-09-06 04:20:23 +0900
commitbb5d092b6f57321a12f0d7575e221b0cc68f063d (patch)
treef8edf58ebdef82a0229739f62fb0d9fbcb633a2a /src/leap/eip/config.py
parent75f4128f5ed515c4df57275bf1479ccdf741c83f (diff)
parentfc8a54a40645412e9c738723e54159bfda40cfde (diff)
Merge branch 'feature/temp-socket-path' into develop
Closes #505: make management socket to listen on temporal files, different for each run
Diffstat (limited to 'src/leap/eip/config.py')
-rw-r--r--src/leap/eip/config.py23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/leap/eip/config.py b/src/leap/eip/config.py
index f4b979ce..833519ee 100644
--- a/src/leap/eip/config.py
+++ b/src/leap/eip/config.py
@@ -1,6 +1,7 @@
import logging
import os
import platform
+import tempfile
from leap.util.fileutil import (which, check_and_fix_urw_only)
@@ -39,7 +40,15 @@ class EIPServiceConfig(baseconfig.JSONLeapConfig):
slug = property(_get_slug, _set_slug)
-def build_ovpn_options(daemon=False):
+def get_socket_path():
+ socket_path = os.path.join(
+ tempfile.mkdtemp(prefix="leap-tmp"),
+ 'openvpn.socket')
+ logger.debug('socket path: %s', socket_path)
+ return socket_path
+
+
+def build_ovpn_options(daemon=False, socket_path=None):
"""
build a list of options
to be passed in the
@@ -98,10 +107,11 @@ def build_ovpn_options(daemon=False):
if ourplatform in ("Linux", "Mac"):
opts.append('--management')
- # XXX get a different sock each time ...
- # XXX #505
- opts.append('/tmp/.eip.sock')
+ if socket_path is None:
+ socket_path = get_socket_path()
+ opts.append(socket_path)
opts.append('unix')
+
if ourplatform == "Windows":
opts.append('--management')
opts.append('localhost')
@@ -125,7 +135,8 @@ def build_ovpn_options(daemon=False):
return opts
-def build_ovpn_command(debug=False, do_pkexec_check=True, vpnbin=None):
+def build_ovpn_command(debug=False, do_pkexec_check=True, vpnbin=None,
+ socket_path=None):
"""
build a string with the
complete openvpn invocation
@@ -171,7 +182,7 @@ def build_ovpn_command(debug=False, do_pkexec_check=True, vpnbin=None):
command.append(vpn_command)
daemon_mode = not debug
- for opt in build_ovpn_options(daemon=daemon_mode):
+ for opt in build_ovpn_options(daemon=daemon_mode, socket_path=socket_path):
command.append(opt)
# XXX check len and raise proper error