|
@@ -314,63 +314,14 @@ class BoB:
|
|
|
# If this is initial update, don't do anything now, leave it to startup
|
|
|
if not self.runnable:
|
|
|
return
|
|
|
- # Now we declare few functions used only internally here. Besides the
|
|
|
- # benefit of not polluting the name space, they are closures, so we
|
|
|
- # don't need to pass some variables
|
|
|
- def start_stop(name, started, start, stop):
|
|
|
- if not'start_' + name in new_config:
|
|
|
- return
|
|
|
- if new_config['start_' + name]:
|
|
|
- if not started:
|
|
|
- if self.uid is not None:
|
|
|
- logger.info(BIND10_START_AS_NON_ROOT, name)
|
|
|
- start()
|
|
|
- else:
|
|
|
- stop()
|
|
|
- # These four functions are passed to start_stop (smells like functional
|
|
|
- # programming little bit)
|
|
|
- def resolver_on():
|
|
|
- self.component_config['b10-resolver'] = { 'kind': 'needed',
|
|
|
- 'special': 'resolver' }
|
|
|
- self.__propagate_component_config(self.component_config)
|
|
|
- self.started_resolver_family = True
|
|
|
- def resolver_off():
|
|
|
- if 'b10-resolver' in self.component_config:
|
|
|
- del self.component_config['b10-resolver']
|
|
|
- self.__propagate_component_config(self.component_config)
|
|
|
- self.started_resolver_family = False
|
|
|
- def auth_on():
|
|
|
- self.component_config['b10-auth'] = { 'kind': 'needed',
|
|
|
- 'special': 'auth' }
|
|
|
- self.component_config['b10-xfrout'] = { 'kind': 'dispensable',
|
|
|
- 'address': 'Xfrout' }
|
|
|
- self.component_config['b10-xfrin'] = { 'kind': 'dispensable',
|
|
|
- 'special': 'xfrin' }
|
|
|
- self.component_config['b10-zonemgr'] = { 'kind': 'dispensable',
|
|
|
- 'address': 'Zonemgr' }
|
|
|
- self.__propagate_component_config(self.component_config)
|
|
|
- self.started_auth_family = True
|
|
|
- def auth_off():
|
|
|
- if 'b10-zonemgr' in self.component_config:
|
|
|
- del self.component_config['b10-zonemgr']
|
|
|
- if 'b10-xfrin' in self.component_config:
|
|
|
- del self.component_config['b10-xfrin']
|
|
|
- if 'b10-xfrout' in self.component_config:
|
|
|
- del self.component_config['b10-xfrout']
|
|
|
- if 'b10-auth' in self.component_config:
|
|
|
- del self.component_config['b10-auth']
|
|
|
- self.__propagate_component_config(self.component_config)
|
|
|
- self.started_auth_family = False
|
|
|
-
|
|
|
- # The real code of the config handler function follows here
|
|
|
logger.debug(DBG_COMMANDS, BIND10_RECEIVED_NEW_CONFIGURATION,
|
|
|
new_config)
|
|
|
- start_stop('resolver', self.started_resolver_family, resolver_on,
|
|
|
- resolver_off)
|
|
|
- start_stop('auth', self.started_auth_family, auth_on, auth_off)
|
|
|
-
|
|
|
- answer = isc.config.ccsession.create_answer(0)
|
|
|
- return answer
|
|
|
+ try:
|
|
|
+ if 'components' in new_config:
|
|
|
+ self.__propagate_component_config(new_config['components'])
|
|
|
+ return isc.config.ccsession.create_answer(0)
|
|
|
+ except Exception as e:
|
|
|
+ return isc.config.ccsession.create_answer(1, str(e))
|
|
|
|
|
|
def get_processes(self):
|
|
|
pids = list(self.processes.keys())
|
|
@@ -445,20 +396,12 @@ class BoB:
|
|
|
"""
|
|
|
Reads the parameters associated with the BoB module itself.
|
|
|
|
|
|
- At present these are the components to start although arguably this
|
|
|
- information should be in the configuration for the appropriate
|
|
|
- module itself. (However, this would cause difficulty in the case of
|
|
|
- xfrin/xfrout and zone manager as we don't need to start those if we
|
|
|
- are not running the authoritative server.)
|
|
|
+ This means the list of components we should start now.
|
|
|
"""
|
|
|
logger.info(BIND10_READING_BOSS_CONFIGURATION)
|
|
|
|
|
|
config_data = self.ccs.get_full_config()
|
|
|
- self.cfg_start_auth = config_data.get("start_auth")
|
|
|
- self.cfg_start_resolver = config_data.get("start_resolver")
|
|
|
-
|
|
|
- logger.info(BIND10_CONFIGURATION_START_AUTH, self.cfg_start_auth)
|
|
|
- logger.info(BIND10_CONFIGURATION_START_RESOLVER, self.cfg_start_resolver)
|
|
|
+ self.__propagate_component_config(config_data['components'])
|
|
|
|
|
|
def log_starting(self, process, port = None, address = None):
|
|
|
"""
|
|
@@ -738,54 +681,7 @@ class BoB:
|
|
|
# configuration may override the "-v" switch set on the command line.
|
|
|
self.read_bind10_config()
|
|
|
|
|
|
- # Continue starting the processes. The authoritative server (if
|
|
|
- # selected):
|
|
|
- component_config = {}
|
|
|
- if self.cfg_start_auth:
|
|
|
- component_config['b10-auth'] = { 'kind': 'needed',
|
|
|
- 'special': 'auth' }
|
|
|
- self.__propagate_component_config(component_config)
|
|
|
-
|
|
|
- # ... and resolver (if selected):
|
|
|
- if self.cfg_start_resolver:
|
|
|
- component_config['b10-resolver'] = { 'kind': 'needed',
|
|
|
- 'special': 'resolver' }
|
|
|
- self.started_resolver_family = True
|
|
|
- self.__propagate_component_config(component_config)
|
|
|
-
|
|
|
- # Everything after the main components can run as non-root.
|
|
|
- # TODO: this is only temporary - once the privileged socket creator is
|
|
|
- # fully working, nothing else will run as root.
|
|
|
- if self.uid is not None:
|
|
|
- posix.setuid(self.uid)
|
|
|
-
|
|
|
- # xfrin/xfrout and the zone manager are only meaningful if the
|
|
|
- # authoritative server has been started.
|
|
|
- if self.cfg_start_auth:
|
|
|
- component_config['b10-xfrout'] = { 'kind': 'dispensable',
|
|
|
- 'address': 'Xfrout' }
|
|
|
- component_config['b10-xfrin'] = { 'kind': 'dispensable',
|
|
|
- 'special': 'xfrin' }
|
|
|
- component_config['b10-zonemgr'] = { 'kind': 'dispensable',
|
|
|
- 'address': 'Zonemgr' }
|
|
|
- self.__propagate_component_config(component_config)
|
|
|
- self.started_auth_family = True
|
|
|
-
|
|
|
- # ... and finally start the remaining processes
|
|
|
- component_config['b10-stats'] = { 'kind': 'dispensable',
|
|
|
- 'address': 'Stats' }
|
|
|
- component_config['b10-stats-httpd'] = { 'kind': 'dispensable',
|
|
|
- 'address': 'StatsHttpd' }
|
|
|
- component_config['b10-cmdctl'] = { 'kind': 'needed',
|
|
|
- 'special': 'cmdctl' }
|
|
|
-
|
|
|
- if self.cfg_start_dhcp6:
|
|
|
- component_config['b10-dhcp6'] = { 'kind': 'dispensable',
|
|
|
- 'address': 'DHCP6' }
|
|
|
-
|
|
|
- self.__propagate_component_config(component_config)
|
|
|
-
|
|
|
- self.component_config = component_config
|
|
|
+ # TODO: Return the dropping of privileges
|
|
|
|
|
|
def startup(self):
|
|
|
"""
|