Commit b09a618f authored by Guillaume Hervier's avatar Guillaume Hervier Committed by Rafael Monnerat

slapgrid_managers[portredir]: Search socat in PATH when running

/reviewed-on nexedi/slapos.core!48
parent 1ac787e9
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
import json import json
import logging import logging
import netaddr import netaddr
import os.path import os
from .interface import IManager from .interface import IManager
from itertools import ifilter from itertools import ifilter
...@@ -15,6 +15,13 @@ def _format_ip_addr(ip_addr): ...@@ -15,6 +15,13 @@ def _format_ip_addr(ip_addr):
return '[{}]'.format(ip_addr) return '[{}]'.format(ip_addr)
return str(ip_addr) return str(ip_addr)
def which(exename):
for path in os.environ["PATH"].split(os.pathsep):
full_path = os.path.join(path, exename)
if os.path.exists(full_path):
return full_path
return None
class Manager(object): class Manager(object):
interface.implements(IManager) interface.implements(IManager)
...@@ -120,7 +127,7 @@ class Manager(object): ...@@ -120,7 +127,7 @@ class Manager(object):
logger.warning('Bad source address provided', exc_info=True) logger.warning('Bad source address provided', exc_info=True)
continue continue
command = ['socat'] command = [which('socat')]
socat_source_version = source_addr.version if source_addr is not None else 4 socat_source_version = source_addr.version if source_addr is not None else 4
socat_source_type = '{rtype}{version}-LISTEN'.format(rtype=redir_type.upper(), version=socat_source_version) socat_source_type = '{rtype}{version}-LISTEN'.format(rtype=redir_type.upper(), version=socat_source_version)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment