mirror of
https://github.com/samba-team/samba.git
synced 2025-01-11 05:18:09 +03:00
samba_dnsupdate: Implement RPC <ZONE> prefix in dns_update_list
This allows us to update the stub records as well as the zone itself. Based on a proposed syntax by metze. Andrew Bartlett Signed-off-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
This commit is contained in:
parent
b1ab37ec5b
commit
8f1659e540
@ -182,6 +182,12 @@ class dnsobj(object):
|
||||
self.existing_port = None
|
||||
self.existing_weight = None
|
||||
self.existing_cname_target = None
|
||||
self.rpc = False
|
||||
self.zone = None
|
||||
if list[0] == "RPC":
|
||||
self.rpc = True
|
||||
self.zone = list[1]
|
||||
list = list[2:]
|
||||
self.type = list[0]
|
||||
self.name = list[1]
|
||||
self.nameservers = []
|
||||
@ -469,7 +475,7 @@ def call_nsupdate(d, op="add"):
|
||||
os.environ["SOCKET_WRAPPER_MTU"] = "0"
|
||||
|
||||
|
||||
def call_samba_tool(d, op="add"):
|
||||
def call_samba_tool(d, op="add", zone=None):
|
||||
"""call samba-tool dns to update an entry."""
|
||||
|
||||
assert(op in ["add", "delete"])
|
||||
@ -483,6 +489,7 @@ def call_samba_tool(d, op="add"):
|
||||
print "Calling samba-tool dns for %s (%s)" % (d, op)
|
||||
|
||||
normalised_name = d.name.rstrip('.') + '.'
|
||||
if zone is None:
|
||||
if normalised_name == (sub_vars['DNSDOMAIN'] + '.'):
|
||||
short_name = '@'
|
||||
zone = sub_vars['DNSDOMAIN']
|
||||
@ -502,6 +509,9 @@ def call_samba_tool(d, op="add"):
|
||||
zone = sub_vars['DNSDOMAIN']
|
||||
len_zone = len(zone)+2
|
||||
short_name = normalised_name[:-len_zone]
|
||||
else:
|
||||
len_zone = len(zone)+2
|
||||
short_name = normalised_name[:-len_zone]
|
||||
|
||||
if d.type == "A":
|
||||
args = [rpc_server_ip, zone, short_name, "A", d.ip]
|
||||
@ -777,8 +787,10 @@ if len(delete_list) != 0 or len(update_list) != 0 and not opts.nocreds:
|
||||
|
||||
# ask nsupdate to delete entries as needed
|
||||
for d in delete_list:
|
||||
if not use_nsupdate and use_samba_tool:
|
||||
call_samba_tool(d, op="delete")
|
||||
if d.rpc or (not use_nsupdate and use_samba_tool):
|
||||
if opts.verbose:
|
||||
print "update (samba-tool): %s" % d
|
||||
call_samba_tool(d, op="delete", zone=d.zone)
|
||||
|
||||
elif am_rodc:
|
||||
if d.name.lower() == domain.lower():
|
||||
@ -800,8 +812,10 @@ for d in delete_list:
|
||||
|
||||
# ask nsupdate to add entries as needed
|
||||
for d in update_list:
|
||||
if not use_nsupdate and use_samba_tool:
|
||||
call_samba_tool(d)
|
||||
if d.rpc or (not use_nsupdate and use_samba_tool):
|
||||
if opts.verbose:
|
||||
print "update (samba-tool): %s" % d
|
||||
call_samba_tool(d, zone=d.zone)
|
||||
|
||||
elif am_rodc:
|
||||
if d.name.lower() == domain.lower():
|
||||
|
@ -6,6 +6,10 @@ ${IF_RWDNS_DOMAIN}NS ${DNSDOMAIN} ${H
|
||||
${IF_RWDNS_FOREST}NS ${DNSFOREST} ${HOSTNAME}
|
||||
${IF_RWDNS_FOREST}NS _msdcs.${DNSFOREST} ${HOSTNAME}
|
||||
|
||||
# Stub entries in the parent zone
|
||||
${IF_RWDNS_DOMAIN}RPC ${DNSFOREST} NS ${DNSDOMAIN} ${HOSTNAME}
|
||||
${IF_RWDNS_FOREST}RPC ${DNSFOREST} NS _msdcs.${DNSFOREST} ${HOSTNAME}
|
||||
|
||||
# RW domain controller
|
||||
${IF_RWDC}A ${DNSDOMAIN} $IP
|
||||
${IF_RWDC}AAAA ${DNSDOMAIN} $IP
|
||||
|
Loading…
Reference in New Issue
Block a user