Commit 4a484575 authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[trac615] XfrOut can use different socket

parent 782a56fb
......@@ -706,6 +706,7 @@ AC_OUTPUT([doc/version.ent
src/bin/xfrout/xfrout.py
src/bin/xfrout/xfrout.spec.pre
src/bin/xfrout/tests/xfrout_test
src/bin/xfrout/tests/xfrout_test.py
src/bin/xfrout/run_b10-xfrout.sh
src/bin/resolver/resolver.spec.pre
src/bin/resolver/spec_config.h.pre
......
......@@ -21,6 +21,7 @@ import os
from isc.cc.session import *
from pydnspp import *
from xfrout import *
import xfrout
# our fake socket, where we can read and insert messages
class MySocket():
......@@ -433,5 +434,36 @@ class TestUnixSockServer(unittest.TestCase):
sys.stdout = old_stdout
os.rmdir(dir_name)
class TestInitialization(unittest.TestCase):
def setEnv(self, name, value):
if value is None:
if name in os.environ:
del os.environ[name]
else:
os.environ[name] = value
def setUp(self):
self._oldSocket = os.getenv("BIND10_XFROUT_SOCKET_FILE")
self._oldFromBuild = os.getenv("B10_FROM_BUILD")
def tearDown(self):
self.setEnv("B10_FROM_BUILD", self._oldFromBuild)
self.setEnv("BIND10_XFROUT_SOCKET_FILE", self._oldSocket)
# Make sure even the computed values are back
xfrout.init_paths()
def testNoEnv(self):
self.setEnv("B10_FROM_BUILD", None)
self.setEnv("BIND10_XFROUT_SOCKET_FILE", None)
xfrout.init_paths()
self.assertEqual(xfrout.UNIX_SOCKET_FILE,
"@@LOCALSTATEDIR@@/auth_xfrout_conn")
def testProvidedSocket(self):
self.setEnv("B10_FROM_BUILD", None)
self.setEnv("BIND10_XFROUT_SOCKET_FILE", "The/Socket/File")
xfrout.init_paths()
self.assertEqual(xfrout.UNIX_SOCKET_FILE, "The/Socket/File")
if __name__== "__main__":
unittest.main()
......@@ -46,20 +46,29 @@ except ImportError as e:
isc.util.process.rename()
if "B10_FROM_BUILD" in os.environ:
SPECFILE_PATH = os.environ["B10_FROM_BUILD"] + "/src/bin/xfrout"
AUTH_SPECFILE_PATH = os.environ["B10_FROM_BUILD"] + "/src/bin/auth"
if "B10_FROM_SOURCE_LOCALSTATEDIR" in os.environ:
UNIX_SOCKET_FILE = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"] + \
"/auth_xfrout_conn"
def init_paths():
global SPECFILE_PATH
global AUTH_SPECFILE_PATH
global UNIX_SOCKET_FILE
if "B10_FROM_BUILD" in os.environ:
SPECFILE_PATH = os.environ["B10_FROM_BUILD"] + "/src/bin/xfrout"
AUTH_SPECFILE_PATH = os.environ["B10_FROM_BUILD"] + "/src/bin/auth"
if "B10_FROM_SOURCE_LOCALSTATEDIR" in os.environ:
UNIX_SOCKET_FILE = os.environ["B10_FROM_SOURCE_LOCALSTATEDIR"] + \
"/auth_xfrout_conn"
else:
UNIX_SOCKET_FILE = os.environ["B10_FROM_BUILD"] + "/auth_xfrout_conn"
else:
UNIX_SOCKET_FILE = os.environ["B10_FROM_BUILD"] + "/auth_xfrout_conn"
else:
PREFIX = "@prefix@"
DATAROOTDIR = "@datarootdir@"
SPECFILE_PATH = "@datadir@/@PACKAGE@".replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX)
AUTH_SPECFILE_PATH = SPECFILE_PATH
UNIX_SOCKET_FILE = "@@LOCALSTATEDIR@@/auth_xfrout_conn"
PREFIX = "@prefix@"
DATAROOTDIR = "@datarootdir@"
SPECFILE_PATH = "@datadir@/@PACKAGE@".replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX)
AUTH_SPECFILE_PATH = SPECFILE_PATH
if "BIND10_XFROUT_SOCKET_FILE" in os.environ:
UNIX_SOCKET_FILE = os.environ["BIND10_XFROUT_SOCKET_FILE"]
else:
UNIX_SOCKET_FILE = "@@LOCALSTATEDIR@@/auth_xfrout_conn"
init_paths()
SPECFILE_LOCATION = SPECFILE_PATH + "/xfrout.spec"
AUTH_SPECFILE_LOCATION = AUTH_SPECFILE_PATH + os.sep + "auth.spec"
......
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