xfrout.py.in 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. #!@PYTHON@
  2. # Copyright (C) 2010 Internet Systems Consortium.
  3. # Copyright (C) 2010 CZ NIC
  4. #
  5. # Permission to use, copy, modify, and distribute this software for any
  6. # purpose with or without fee is hereby granted, provided that the above
  7. # copyright notice and this permission notice appear in all copies.
  8. #
  9. # THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SYSTEMS CONSORTIUM
  10. # DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
  11. # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
  12. # INTERNET SYSTEMS CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT,
  13. # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
  14. # FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
  15. # NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
  16. # WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  17. import sys; sys.path.append ('@@PYTHONPATH@@')
  18. import isc
  19. import isc.cc
  20. import threading
  21. import struct
  22. import signal
  23. from isc.datasrc import sqlite3_ds
  24. from socketserver import *
  25. import os
  26. from isc.config.ccsession import *
  27. from isc.log.log import *
  28. from isc.cc import SessionError, SessionTimeout
  29. from isc.notify import notify_out
  30. import isc.util.process
  31. import socket
  32. import select
  33. import errno
  34. from optparse import OptionParser, OptionValueError
  35. from isc.util import socketserver_mixin
  36. try:
  37. from libxfr_python import *
  38. from pydnspp import *
  39. except ImportError as e:
  40. # C++ loadable module may not be installed; even so the xfrout process
  41. # must keep running, so we warn about it and move forward.
  42. sys.stderr.write('[b10-xfrout] failed to import DNS or XFR module: %s\n' % str(e))
  43. isc.util.process.rename()
  44. if "B10_FROM_BUILD" in os.environ:
  45. SPECFILE_PATH = os.environ["B10_FROM_BUILD"] + "/src/bin/xfrout"
  46. AUTH_SPECFILE_PATH = os.environ["B10_FROM_BUILD"] + "/src/bin/auth"
  47. UNIX_SOCKET_FILE= os.environ["B10_FROM_BUILD"] + "/auth_xfrout_conn"
  48. else:
  49. PREFIX = "@prefix@"
  50. DATAROOTDIR = "@datarootdir@"
  51. SPECFILE_PATH = "@datadir@/@PACKAGE@".replace("${datarootdir}", DATAROOTDIR).replace("${prefix}", PREFIX)
  52. AUTH_SPECFILE_PATH = SPECFILE_PATH
  53. UNIX_SOCKET_FILE = "@@LOCALSTATEDIR@@/auth_xfrout_conn"
  54. SPECFILE_LOCATION = SPECFILE_PATH + "/xfrout.spec"
  55. AUTH_SPECFILE_LOCATION = AUTH_SPECFILE_PATH + os.sep + "auth.spec"
  56. MAX_TRANSFERS_OUT = 10
  57. VERBOSE_MODE = False
  58. XFROUT_MAX_MESSAGE_SIZE = 65535
  59. def get_rrset_len(rrset):
  60. """Returns the wire length of the given RRset"""
  61. bytes = bytearray()
  62. rrset.to_wire(bytes)
  63. return len(bytes)
  64. class XfroutSession():
  65. def __init__(self, sock_fd, request_data, server, log):
  66. # The initializer for the superclass may call functions
  67. # that need _log to be set, so we set it first
  68. self._sock_fd = sock_fd
  69. self._request_data = request_data
  70. self._server = server
  71. self._log = log
  72. self.handle()
  73. def handle(self):
  74. ''' Handle a xfrout query, send xfrout response '''
  75. try:
  76. self.dns_xfrout_start(self._sock_fd, self._request_data)
  77. #TODO, avoid catching all exceptions
  78. except Exception as e:
  79. self._log.log_message("error", str(e))
  80. os.close(self._sock_fd)
  81. def _parse_query_message(self, mdata):
  82. ''' parse query message to [socket,message]'''
  83. #TODO, need to add parseHeader() in case the message header is invalid
  84. try:
  85. msg = Message(Message.PARSE)
  86. Message.from_wire(msg, mdata)
  87. except Exception as err:
  88. self._log.log_message("error", str(err))
  89. return Rcode.FORMERR(), None
  90. return Rcode.NOERROR(), msg
  91. def _get_query_zone_name(self, msg):
  92. question = msg.get_question()[0]
  93. return question.get_name().to_text()
  94. def _send_data(self, sock_fd, data):
  95. size = len(data)
  96. total_count = 0
  97. while total_count < size:
  98. count = os.write(sock_fd, data[total_count:])
  99. total_count += count
  100. def _send_message(self, sock_fd, msg):
  101. render = MessageRenderer()
  102. # As defined in RFC5936 section3.4, perform case-preserving name
  103. # compression for AXFR message.
  104. render.set_compress_mode(MessageRenderer.CASE_SENSITIVE)
  105. render.set_length_limit(XFROUT_MAX_MESSAGE_SIZE)
  106. msg.to_wire(render)
  107. header_len = struct.pack('H', socket.htons(render.get_length()))
  108. self._send_data(sock_fd, header_len)
  109. self._send_data(sock_fd, render.get_data())
  110. def _reply_query_with_error_rcode(self, msg, sock_fd, rcode_):
  111. msg.make_response()
  112. msg.set_rcode(rcode_)
  113. self._send_message(sock_fd, msg)
  114. def _reply_query_with_format_error(self, msg, sock_fd):
  115. '''query message format isn't legal.'''
  116. if not msg:
  117. return # query message is invalid. send nothing back.
  118. msg.make_response()
  119. msg.set_rcode(Rcode.FORMERR())
  120. self._send_message(sock_fd, msg)
  121. def _zone_has_soa(self, zone):
  122. '''Judge if the zone has an SOA record.'''
  123. # In some sense, the SOA defines a zone.
  124. # If the current name server has authority for the
  125. # specific zone, we need to judge if the zone has an SOA record;
  126. # if not, we consider the zone has incomplete data, so xfrout can't
  127. # serve for it.
  128. if sqlite3_ds.get_zone_soa(zone, self._server.get_db_file()):
  129. return True
  130. return False
  131. def _zone_exist(self, zonename):
  132. '''Judge if the zone is configured by config manager.'''
  133. # Currently, if we find the zone in datasource successfully, we
  134. # consider the zone is configured, and the current name server has
  135. # authority for the specific zone.
  136. # TODO: should get zone's configuration from cfgmgr or other place
  137. # in future.
  138. return sqlite3_ds.zone_exist(zonename, self._server.get_db_file())
  139. def _check_xfrout_available(self, zone_name):
  140. '''Check if xfr request can be responsed.
  141. TODO, Get zone's configuration from cfgmgr or some other place
  142. eg. check allow_transfer setting,
  143. '''
  144. # If the current name server does not have authority for the
  145. # zone, xfrout can't serve for it, return rcode NOTAUTH.
  146. if not self._zone_exist(zone_name):
  147. return Rcode.NOTAUTH()
  148. # If we are an authoritative name server for the zone, but fail
  149. # to find the zone's SOA record in datasource, xfrout can't
  150. # provide zone transfer for it.
  151. if not self._zone_has_soa(zone_name):
  152. return Rcode.SERVFAIL()
  153. #TODO, check allow_transfer
  154. if not self._server.increase_transfers_counter():
  155. return Rcode.REFUSED()
  156. return Rcode.NOERROR()
  157. def dns_xfrout_start(self, sock_fd, msg_query):
  158. rcode_, msg = self._parse_query_message(msg_query)
  159. #TODO. create query message and parse header
  160. if rcode_ != Rcode.NOERROR():
  161. return self._reply_query_with_format_error(msg, sock_fd)
  162. zone_name = self._get_query_zone_name(msg)
  163. rcode_ = self._check_xfrout_available(zone_name)
  164. if rcode_ != Rcode.NOERROR():
  165. self._log.log_message("info", "transfer of '%s/IN' failed: %s",
  166. zone_name, rcode_.to_text())
  167. return self. _reply_query_with_error_rcode(msg, sock_fd, rcode_)
  168. try:
  169. self._log.log_message("info", "transfer of '%s/IN': AXFR started" % zone_name)
  170. self._reply_xfrout_query(msg, sock_fd, zone_name)
  171. self._log.log_message("info", "transfer of '%s/IN': AXFR end" % zone_name)
  172. except Exception as err:
  173. self._log.log_message("error", str(err))
  174. self._server.decrease_transfers_counter()
  175. return
  176. def _clear_message(self, msg):
  177. qid = msg.get_qid()
  178. opcode = msg.get_opcode()
  179. rcode = msg.get_rcode()
  180. msg.clear(Message.RENDER)
  181. msg.set_qid(qid)
  182. msg.set_opcode(opcode)
  183. msg.set_rcode(rcode)
  184. msg.set_header_flag(Message.HEADERFLAG_AA)
  185. msg.set_header_flag(Message.HEADERFLAG_QR)
  186. return msg
  187. def _create_rrset_from_db_record(self, record):
  188. '''Create one rrset from one record of datasource, if the schema of record is changed,
  189. This function should be updated first.
  190. '''
  191. rrtype_ = RRType(record[5])
  192. rdata_ = Rdata(rrtype_, RRClass("IN"), " ".join(record[7:]))
  193. rrset_ = RRset(Name(record[2]), RRClass("IN"), rrtype_, RRTTL( int(record[4])))
  194. rrset_.add_rdata(rdata_)
  195. return rrset_
  196. def _send_message_with_last_soa(self, msg, sock_fd, rrset_soa, message_upper_len):
  197. '''Add the SOA record to the end of message. If it can't be
  198. added, a new message should be created to send out the last soa .
  199. '''
  200. rrset_len = get_rrset_len(rrset_soa)
  201. if message_upper_len + rrset_len < XFROUT_MAX_MESSAGE_SIZE:
  202. msg.add_rrset(Message.SECTION_ANSWER, rrset_soa)
  203. else:
  204. self._send_message(sock_fd, msg)
  205. msg = self._clear_message(msg)
  206. msg.add_rrset(Message.SECTION_ANSWER, rrset_soa)
  207. self._send_message(sock_fd, msg)
  208. def _reply_xfrout_query(self, msg, sock_fd, zone_name):
  209. #TODO, there should be a better way to insert rrset.
  210. msg.make_response()
  211. msg.set_header_flag(Message.HEADERFLAG_AA)
  212. soa_record = sqlite3_ds.get_zone_soa(zone_name, self._server.get_db_file())
  213. rrset_soa = self._create_rrset_from_db_record(soa_record)
  214. msg.add_rrset(Message.SECTION_ANSWER, rrset_soa)
  215. message_upper_len = get_rrset_len(rrset_soa)
  216. for rr_data in sqlite3_ds.get_zone_datas(zone_name, self._server.get_db_file()):
  217. if self._server._shutdown_event.is_set(): # Check if xfrout is shutdown
  218. self._log.log_message("info", "xfrout process is being shutdown")
  219. return
  220. # TODO: RRType.SOA() ?
  221. if RRType(rr_data[5]) == RRType("SOA"): #ignore soa record
  222. continue
  223. rrset_ = self._create_rrset_from_db_record(rr_data)
  224. # We calculate the maximum size of the RRset (i.e. the
  225. # size without compression) and use that to see if we
  226. # may have reached the limit
  227. rrset_len = get_rrset_len(rrset_)
  228. if message_upper_len + rrset_len < XFROUT_MAX_MESSAGE_SIZE:
  229. msg.add_rrset(Message.SECTION_ANSWER, rrset_)
  230. message_upper_len += rrset_len
  231. continue
  232. self._send_message(sock_fd, msg)
  233. msg = self._clear_message(msg)
  234. msg.add_rrset(Message.SECTION_ANSWER, rrset_) # Add the rrset to the new message
  235. message_upper_len = rrset_len
  236. self._send_message_with_last_soa(msg, sock_fd, rrset_soa, message_upper_len)
  237. class UnixSockServer(socketserver_mixin.NoPollMixIn, ThreadingUnixStreamServer):
  238. '''The unix domain socket server which accept xfr query sent from auth server.'''
  239. def __init__(self, sock_file, handle_class, shutdown_event, config_data, cc, log):
  240. self._remove_unused_sock_file(sock_file)
  241. self._sock_file = sock_file
  242. socketserver_mixin.NoPollMixIn.__init__(self)
  243. ThreadingUnixStreamServer.__init__(self, sock_file, handle_class)
  244. self._lock = threading.Lock()
  245. self._transfers_counter = 0
  246. self._shutdown_event = shutdown_event
  247. self._write_sock, self._read_sock = socket.socketpair()
  248. self._log = log
  249. self.update_config_data(config_data)
  250. self._cc = cc
  251. def _receive_query_message(self, sock):
  252. ''' receive request message from sock'''
  253. # receive data length
  254. data_len = sock.recv(2)
  255. if not data_len:
  256. return None
  257. msg_len = struct.unpack('!H', data_len)[0]
  258. # receive data
  259. recv_size = 0
  260. msgdata = b''
  261. while recv_size < msg_len:
  262. data = sock.recv(msg_len - recv_size)
  263. if not data:
  264. return None
  265. recv_size += len(data)
  266. msgdata += data
  267. return msgdata
  268. def handle_request(self):
  269. ''' Enable server handle a request until shutdown or auth is closed.'''
  270. try:
  271. request, client_address = self.get_request()
  272. except socket.error:
  273. self._log.log_message("error", "Failed to fetch request")
  274. return
  275. # Check self._shutdown_event to ensure the real shutdown comes.
  276. # Linux could trigger a spurious readable event on the _read_sock
  277. # due to a bug, so we need perform a double check.
  278. while not self._shutdown_event.is_set(): # Check if xfrout is shutdown
  279. try:
  280. (rlist, wlist, xlist) = select.select([self._read_sock, request], [], [])
  281. except select.error as e:
  282. if e.args[0] == errno.EINTR:
  283. (rlist, wlist, xlist) = ([], [], [])
  284. continue
  285. else:
  286. self._log.log_message("error", "Error with select(): %s" %e)
  287. break
  288. # self.server._shutdown_event will be set by now, if it is not a false
  289. # alarm
  290. if self._read_sock in rlist:
  291. continue
  292. try:
  293. self.process_request(request)
  294. except:
  295. self._log.log_message("error", "Exception happened during processing of %s"
  296. % str(client_address))
  297. break
  298. def _handle_request_noblock(self):
  299. """Override the function _handle_request_noblock(), it creates a new
  300. thread to handle requests for each auth"""
  301. td = threading.Thread(target=self.handle_request)
  302. td.setDaemon(True)
  303. td.start()
  304. def process_request(self, request):
  305. """Receive socket fd and query message from auth, then
  306. start a new thread to process the request."""
  307. sock_fd = recv_fd(request.fileno())
  308. if sock_fd < 0:
  309. # This may happen when one xfrout process try to connect to
  310. # xfrout unix socket server, to check whether there is another
  311. # xfrout running.
  312. if sock_fd == XFR_FD_RECEIVE_FAIL:
  313. self._log.log_message("error", "Failed to receive the file descriptor for XFR connection")
  314. return
  315. # receive request msg
  316. request_data = self._receive_query_message(request)
  317. if not request_data:
  318. return
  319. t = threading.Thread(target = self.finish_request,
  320. args = (sock_fd, request_data))
  321. if self.daemon_threads:
  322. t.daemon = True
  323. t.start()
  324. def finish_request(self, sock_fd, request_data):
  325. '''Finish one request by instantiating RequestHandlerClass.'''
  326. self.RequestHandlerClass(sock_fd, request_data, self, self._log)
  327. def _remove_unused_sock_file(self, sock_file):
  328. '''Try to remove the socket file. If the file is being used
  329. by one running xfrout process, exit from python.
  330. If it's not a socket file or nobody is listening
  331. , it will be removed. If it can't be removed, exit from python. '''
  332. if self._sock_file_in_use(sock_file):
  333. self._log.log_message("error", "Fail to start xfrout process, unix socket file '%s'"
  334. " is being used by another xfrout process\n" % sock_file)
  335. sys.exit(0)
  336. else:
  337. if not os.path.exists(sock_file):
  338. return
  339. try:
  340. os.unlink(sock_file)
  341. except OSError as err:
  342. self._log.log_message("error", "[b10-xfrout] Fail to remove file %s: %s\n" % (sock_file, err))
  343. sys.exit(0)
  344. def _sock_file_in_use(self, sock_file):
  345. '''Check whether the socket file 'sock_file' exists and
  346. is being used by one running xfrout process. If it is,
  347. return True, or else return False. '''
  348. try:
  349. sock = socket.socket(socket.AF_UNIX)
  350. sock.connect(sock_file)
  351. except socket.error as err:
  352. return False
  353. else:
  354. return True
  355. def shutdown(self):
  356. self._write_sock.send(b"shutdown") #terminate the xfrout session thread
  357. super().shutdown() # call the shutdown() of class socketserver_mixin.NoPollMixIn
  358. try:
  359. os.unlink(self._sock_file)
  360. except Exception as e:
  361. self._log.log_message('error', str(e))
  362. def update_config_data(self, new_config):
  363. '''Apply the new config setting of xfrout module. '''
  364. self._log.log_message('info', 'update config data start.')
  365. self._lock.acquire()
  366. self._max_transfers_out = new_config.get('transfers_out')
  367. self._log.log_message('info', 'max transfer out : %d', self._max_transfers_out)
  368. self._lock.release()
  369. self._log.log_message('info', 'update config data complete.')
  370. def get_db_file(self):
  371. file, is_default = self._cc.get_remote_config_value("Auth", "database_file")
  372. # this too should be unnecessary, but currently the
  373. # 'from build' override isn't stored in the config
  374. # (and we don't have indirect python access to datasources yet)
  375. if is_default and "B10_FROM_BUILD" in os.environ:
  376. file = os.environ["B10_FROM_BUILD"] + os.sep + "bind10_zones.sqlite3"
  377. return file
  378. def increase_transfers_counter(self):
  379. '''Return False, if counter + 1 > max_transfers_out, or else
  380. return True
  381. '''
  382. ret = False
  383. self._lock.acquire()
  384. if self._transfers_counter < self._max_transfers_out:
  385. self._transfers_counter += 1
  386. ret = True
  387. self._lock.release()
  388. return ret
  389. def decrease_transfers_counter(self):
  390. self._lock.acquire()
  391. self._transfers_counter -= 1
  392. self._lock.release()
  393. class XfroutServer:
  394. def __init__(self):
  395. self._unix_socket_server = None
  396. self._log = None
  397. self._listen_sock_file = UNIX_SOCKET_FILE
  398. self._shutdown_event = threading.Event()
  399. self._cc = isc.config.ModuleCCSession(SPECFILE_LOCATION, self.config_handler, self.command_handler)
  400. self._config_data = self._cc.get_full_config()
  401. self._cc.start()
  402. self._cc.add_remote_config(AUTH_SPECFILE_LOCATION);
  403. self._log = isc.log.NSLogger(self._config_data.get('log_name'), self._config_data.get('log_file'),
  404. self._config_data.get('log_severity'), self._config_data.get('log_versions'),
  405. self._config_data.get('log_max_bytes'), True)
  406. self._start_xfr_query_listener()
  407. self._start_notifier()
  408. def _start_xfr_query_listener(self):
  409. '''Start a new thread to accept xfr query. '''
  410. self._unix_socket_server = UnixSockServer(self._listen_sock_file, XfroutSession,
  411. self._shutdown_event, self._config_data,
  412. self._cc, self._log);
  413. listener = threading.Thread(target=self._unix_socket_server.serve_forever)
  414. listener.start()
  415. def _start_notifier(self):
  416. datasrc = self._unix_socket_server.get_db_file()
  417. self._notifier = notify_out.NotifyOut(datasrc, self._log)
  418. self._notifier.dispatcher()
  419. def send_notify(self, zone_name, zone_class):
  420. self._notifier.send_notify(zone_name, zone_class)
  421. def config_handler(self, new_config):
  422. '''Update config data. TODO. Do error check'''
  423. answer = create_answer(0)
  424. for key in new_config:
  425. if key not in self._config_data:
  426. answer = create_answer(1, "Unknown config data: " + str(key))
  427. continue
  428. self._config_data[key] = new_config[key]
  429. if self._log:
  430. self._log.update_config(new_config)
  431. if self._unix_socket_server:
  432. self._unix_socket_server.update_config_data(self._config_data)
  433. return answer
  434. def shutdown(self):
  435. ''' shutdown the xfrout process. The thread which is doing zone transfer-out should be
  436. terminated.
  437. '''
  438. global xfrout_server
  439. xfrout_server = None #Avoid shutdown is called twice
  440. self._shutdown_event.set()
  441. self._notifier.shutdown()
  442. if self._unix_socket_server:
  443. self._unix_socket_server.shutdown()
  444. # Wait for all threads to terminate
  445. main_thread = threading.currentThread()
  446. for th in threading.enumerate():
  447. if th is main_thread:
  448. continue
  449. th.join()
  450. def command_handler(self, cmd, args):
  451. if cmd == "shutdown":
  452. self._log.log_message("info", "Received shutdown command.")
  453. self.shutdown()
  454. answer = create_answer(0)
  455. elif cmd == notify_out.ZONE_NEW_DATA_READY_CMD:
  456. zone_name = args.get('zone_name')
  457. zone_class = args.get('zone_class')
  458. if zone_name and zone_class:
  459. self._log.log_message("info", "zone '%s/%s': receive notify others command" \
  460. % (zone_name, zone_class))
  461. self.send_notify(zone_name, zone_class)
  462. answer = create_answer(0)
  463. else:
  464. answer = create_answer(1, "Bad command parameter:" + str(args))
  465. else:
  466. answer = create_answer(1, "Unknown command:" + str(cmd))
  467. return answer
  468. def run(self):
  469. '''Get and process all commands sent from cfgmgr or other modules. '''
  470. while not self._shutdown_event.is_set():
  471. self._cc.check_command(False)
  472. xfrout_server = None
  473. def signal_handler(signal, frame):
  474. if xfrout_server:
  475. xfrout_server.shutdown()
  476. sys.exit(0)
  477. def set_signal_handler():
  478. signal.signal(signal.SIGTERM, signal_handler)
  479. signal.signal(signal.SIGINT, signal_handler)
  480. def set_cmd_options(parser):
  481. parser.add_option("-v", "--verbose", dest="verbose", action="store_true",
  482. help="display more about what is going on")
  483. if '__main__' == __name__:
  484. try:
  485. parser = OptionParser()
  486. set_cmd_options(parser)
  487. (options, args) = parser.parse_args()
  488. VERBOSE_MODE = options.verbose
  489. set_signal_handler()
  490. xfrout_server = XfroutServer()
  491. xfrout_server.run()
  492. except KeyboardInterrupt:
  493. sys.stderr.write("[b10-xfrout] exit xfrout process\n")
  494. except SessionError as e:
  495. sys.stderr.write("[b10-xfrout] Error creating xfrout, "
  496. "is the command channel daemon running?\n")
  497. except SessionTimeout as e:
  498. sys.stderr.write("[b10-xfrout] Error creating xfrout, "
  499. "is the configuration manager running?\n")
  500. except ModuleCCSessionError as e:
  501. sys.stderr.write("[b10-xfrout] exit xfrout process:%s\n" % str(e))
  502. if xfrout_server:
  503. xfrout_server.shutdown()