When an SRV record is created via nsupdate in S4, the Samba4 DNS object finally ends up with two dnsRecord values, which differ only in * dwTtlSeconds * dwSerial * dwTimeStamp 1. When an SRV record is created via nsupdate in S4 it has a certain ttl (900) 2. When syncronized to UDM, UDM assigns a differrent ttl by default (10800) 3. When syncronizes back the S4 Connector writes the Samba4 default (1200) 4. Since 900 and 1200 are encoded in the dnsRecord structure, the S4-Connector thinks they are differnt and adds the ttl 1200 record. In the end the SRV record in Samba4 has two dnsRecord values which only differ by their ttl. This patch is a first attempt to avoid this, but there are two other fields which need to be considered: dwSerial and dwTimeStamp Index: modules/univention/s4connector/s4/dns.py =================================================================== --- modules/univention/s4connector/s4/dns.py (Revision 62936) +++ modules/univention/s4connector/s4/dns.py (Arbeitskopie) @@ -574,6 +574,7 @@ return c def __pack_sRVrecord(object, dnsRecords): + ttl = object['attributes'].get('dNSTTL', [None])[0] for srvRecord in object['attributes'].get('sRVRecord', []): srvRecord=univention.s4connector.s4.compatible_modstring(srvRecord) srv=srvRecord.split(' ') @@ -581,11 +582,15 @@ weight=int(srv[1]) port=int(srv[2]) target=__remove_dot(srv[3]) - s=SRVRecord(target, port, priority, weight) + if ttl: + s=SRVRecord(target, port, priority, weight, ttl=int(ttl)) + else: + s=SRVRecord(target, port, priority, weight) dnsRecords.append(ndr_pack(s)) def __unpack_sRVrecord(object): srv=[] + ttl=0 dnsRecords=object['attributes'].get('dnsRecord', []) for dnsRecord in dnsRecords: dnsRecord=dnsRecord.encode('latin1') @@ -592,7 +597,9 @@ ndrRecord=ndr_unpack(dnsp.DnssrvRpcRecord, dnsRecord) if ndrRecord.wType == dnsp.DNS_TYPE_SRV: srv.append([str(ndrRecord.data.wPriority), str(ndrRecord.data.wWeight), str(ndrRecord.data.wPort), __append_dot(ndrRecord.data.nameTarget)]) - return srv + if ndrRecord.dwTtlSeconds: + ttl=max(ttl, ndrRecord.dwTtlSeconds) + return (srv, ttl) def __pack_ptrRecord(object, dnsRecords): for ptr in object['attributes'].get('pTRRecord', []): @@ -1031,7 +1038,8 @@ relativeDomainName = object['attributes']['relativeDomainName'][0] # unpack the host record - srv=__unpack_sRVrecord(object) + srv, ttl=__unpack_sRVrecord(object) + ud.debug(ud.LDAP, ud.INFO, 'ucs_srv_record_create: DEBUG got ttl: %s' % ttl) # ucr set connector/s4/mapping/dns/srv_record/_ldap._tcp.test.local/location='100 0 389 foobar.test.local. 100 0 389 foobar2.test.local.' ucr_locations = s4connector.configRegistry.get('connector/s4/mapping/dns/srv_record/%s.%s/location' % (relativeDomainName.lower(),zoneName.lower())) @@ -1055,6 +1063,8 @@ newRecord['location'].sort() if srv != newRecord['location']: newRecord['location']=srv + if ttl: + newRecord['zonettl']=[ str(ttl) ] newRecord.modify() else: ud.debug(ud.LDAP, ud.INFO, 'ucs_srv_record_create: do not modify host record') @@ -1080,6 +1090,8 @@ ud.debug(ud.LDAP, ud.INFO, msg) newRecord['name']=parts newRecord['location']=srv + if ttl: + newRecord['zonettl']=[ str(ttl) ] newRecord.create()