From 5b1ac79562bd60494c9ec31723b27b0affe7fe5c Mon Sep 17 00:00:00 2001 From: kroy-the-rabbit Date: Thu, 28 May 2020 00:39:45 -0500 Subject: dhcp: T2465: T2483: fix DNS resolution (pdns restatt) --- src/services/vyos-hostsd | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/services') diff --git a/src/services/vyos-hostsd b/src/services/vyos-hostsd index 6017cea82..bf5d67cfa 100755 --- a/src/services/vyos-hostsd +++ b/src/services/vyos-hostsd @@ -28,6 +28,7 @@ import zmq import collections import jinja2 +from vyos.util import popen, process_named_running debug = True @@ -212,13 +213,17 @@ def handle_message(msg_json): op = get_option(msg, 'op') _type = get_option(msg, 'type') + changes = 0 + if op == 'delete': tag = get_option(msg, 'tag') if _type == 'name_servers': delete_name_servers(STATE, tag) + changes += 1 elif _type == 'hosts': delete_hosts(STATE, tag) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'add': @@ -226,8 +231,10 @@ def handle_message(msg_json): entries = get_option(msg, 'data') if _type == 'name_servers': add_name_servers(STATE, entries, tag) + changes += 1 elif _type == 'hosts': add_hosts(STATE, entries, tag) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'set': @@ -236,6 +243,7 @@ def handle_message(msg_json): data = get_option(msg, 'data') if _type == 'host_name': set_host_name(STATE, data) + changes += 1 else: raise ValueError("Unknown message type {0}".format(_type)) elif op == 'get': @@ -255,6 +263,12 @@ def handle_message(msg_json): with open(STATE_FILE, 'w') as f: json.dump(STATE, f) + if changes > 0: + if process_named_running("pdns_recursor"): + (ret,return_code) = popen("sudo rec_control --socket-dir=/run/powerdns reload-zones") + if return_code > 0: + logger.exception("PowerDNS rec_control failed to reload") + def exit_handler(sig, frame): """ Clean up the state when shutdown correctly """ logger.info("Cleaning up state") -- cgit v1.2.3