Browse Source

[213] Return library path workaround for xfrin

Michal 'vorner' Vaner 13 years ago
parent
commit
8f876a2379

+ 33 - 2
src/bin/bind10/bind10_src.py.in

@@ -341,7 +341,7 @@ class BoB:
             self.component_config['b10-xfrout'] = { 'kind': 'dispensable',
                                                     'address': 'Xfrout' }
             self.component_config['b10-xfrin'] = { 'kind': 'dispensable',
-                                                   'address': 'Xfrin' }
+                                                   'special': 'xfrin' }
             self.component_config['b10-zonemgr'] = { 'kind': 'dispensable',
                                                      'address': 'Zonemgr' }
             self.__propagate_component_config(self.component_config)
@@ -690,6 +690,37 @@ class BoB:
         return self.start_process("b10-cmdctl", args, self.c_channel_env,
                                   self.cmdctl_port)
 
+    def start_xfrin(self):
+        # XXX: a quick-hack workaround.  xfrin will implicitly use dynamically
+        # loadable data source modules, which will be installed in $(libdir).
+        # On some OSes (including MacOS X and *BSDs) the main process (python)
+        # cannot find the modules unless they are located in a common shared
+        # object path or a path in the (DY)LD_LIBRARY_PATH.  We should seek
+        # a cleaner solution, but for a short term workaround we specify the
+        # path here, unconditionally, and without even bothering which
+        # environment variable should be used.
+        #
+        # We reuse the ADD_LIBEXEC_PATH variable to see whether we need to
+        # do this, as the conditions that make this workaround needed are
+        # the same as for the libexec path addition
+        # TODO: Once #1292 is finished, remove this method and the special
+        # component, use it as normal component.
+        c_channel_env = dict(self.c_channel_env)
+        if ADD_LIBEXEC_PATH:
+            cur_path = os.getenv('DYLD_LIBRARY_PATH')
+            cur_path = '' if cur_path is None else ':' + cur_path
+            c_channel_env['DYLD_LIBRARY_PATH'] = "@@LIBDIR@@" + cur_path
+
+            cur_path = os.getenv('LD_LIBRARY_PATH')
+            cur_path = '' if cur_path is None else ':' + cur_path
+            c_channel_env['LD_LIBRARY_PATH'] = "@@LIBDIR@@" + cur_path
+        # Set up the command arguments.
+        args = ['b10-xfrin']
+        if self.verbose:
+            args += ['-v']
+
+        return self.start_process("b10-xfrin", args, c_channel_env)
+
     def start_all_processes(self):
         """
             Starts up all the processes.  Any exception generated during the
@@ -735,7 +766,7 @@ class BoB:
             component_config['b10-xfrout'] = { 'kind': 'dispensable',
                                                'address': 'Xfrout' }
             component_config['b10-xfrin'] = { 'kind': 'dispensable',
-                                              'address': 'Xfrin' }
+                                              'special': 'xfrin' }
             component_config['b10-zonemgr'] = { 'kind': 'dispensable',
                                               'address': 'Zonemgr' }
             self.__propagate_component_config(component_config)

+ 8 - 1
src/lib/python/isc/bind10/special_component.py

@@ -81,6 +81,11 @@ class CmdCtl(Component):
         Component.__init__(self, process, boss, kind, 'Cmdctl')
         self._start_func = boss.start_cmdctl
 
+class XfrIn(Component):
+    def __init__(self, process, boss, kind, address=None, params=None):
+        Component.__init__(self, process, boss, kind, 'Xfrin')
+        self._start_func = boss.start_xfrin
+
 def get_specials():
     """
     List of specially started components. Each one should be the class than can
@@ -94,5 +99,7 @@ def get_specials():
         # They should not have any parameters anyway
         'auth': Auth,
         'resolver': Resolver,
-        'cmdctl': CmdCtl
+        'cmdctl': CmdCtl,
+        # FIXME: Temporary workaround before #1292 is done
+        'xfrin': XfrIn
     }

+ 5 - 1
src/lib/python/isc/bind10/tests/component_test.py

@@ -86,6 +86,9 @@ class BossUtils:
     def start_cmdctl(self):
         pass
 
+    def start_xfrin(self):
+        pass
+
 class ComponentTests(BossUtils, unittest.TestCase):
     """
     Tests for the bind10.component.Component class
@@ -420,7 +423,8 @@ class ComponentTests(BossUtils, unittest.TestCase):
                                isc.bind10.special_component.CfgMgr,
                                isc.bind10.special_component.Auth,
                                isc.bind10.special_component.Resolver,
-                               isc.bind10.special_component.CmdCtl]:
+                               isc.bind10.special_component.CmdCtl,
+                               isc.bind10.special_component.XfrIn]:
             component = component_type('none', self, 'needed')
             self.assertIsNone(component.pid())