From: Andrew Bartlett Date: Tue, 6 Dec 2011 22:57:07 +0000 (+1100) Subject: s4-dnsupdate: Do not attempt to add the PDC names if we are not a PDC X-Git-Url: http://git.samba.org/?a=commitdiff_plain;h=650bd5e718a603b3cbcd503db6fe4150d2cf8369;p=mat%2Fsamba.git s4-dnsupdate: Do not attempt to add the PDC names if we are not a PDC --- diff --git a/source4/scripting/bin/samba_dnsupdate b/source4/scripting/bin/samba_dnsupdate index aa307eeed4..86af6d859f 100755 --- a/source4/scripting/bin/samba_dnsupdate +++ b/source4/scripting/bin/samba_dnsupdate @@ -155,6 +155,10 @@ class dnsobj(object): ################################################ # parse a DNS line from def parse_dns_line(line, sub_vars): + if line.startswith("SRV _ldap._tcp.pdc._msdcs.") and not samdb.am_pdc(): + if opts.verbose: + print "Skipping PDC entry (%s) as we are not a PDC" % line + return None subline = samba.substitute_var(line, sub_vars) d = dnsobj(subline) return d @@ -249,13 +253,10 @@ def check_dns_name(d): ########################################### # get the list of substitution vars -def get_subst_vars(): +def get_subst_vars(samdb): global lp, am_rodc vars = {} - samdb = SamDB(url=lp.samdb_url(), session_info=system_session(), - lp=lp) - vars['DNSDOMAIN'] = samdb.domain_dns_name() vars['DNSFOREST'] = samdb.forest_dns_name() vars['HOSTNAME'] = samdb.host_dns_name() @@ -425,8 +426,11 @@ os.environ['KRB5_CONFIG'] = krb5conf file = open(dns_update_list, "r") +samdb = SamDB(url=lp.samdb_url(), session_info=system_session(), + lp=lp) + # get the substitution dictionary -sub_vars = get_subst_vars() +sub_vars = get_subst_vars(samdb) # build up a list of update commands to pass to nsupdate update_list = [] @@ -440,6 +444,8 @@ for line in file: if line == '' or line[0] == "#": continue d = parse_dns_line(line, sub_vars) + if d is None: + continue if d.type == 'A' and len(IP4s) == 0: continue if d.type == 'AAAA' and len(IP6s) == 0: