[ldns-users] PATCH: changing and padding the SOA serial in ldns-read-zone
Paul Wouters
paul at xelerance.com
Fri Oct 14 04:07:04 UTC 2011
Hi,
We do some zone manipulation using ldns-read-zone, and one issue we keep
running into is that we want to re-write the serial number, but we don't
want to rewrite large zone files all the times when the serial number
needs to grow a digit. That way, we can use mmap() to quickly just update
the serial. (of course, we're talking unsigned zones here)
I tried to do it using the existing functions, but got quite confused
with all the ldns_rr_* related buffer functions, so I ended up just
using an ldns_buffer->_data call directly and some uglt str tokking.
I hope someone can take this patch and write proper code for it. Or even
better, add a function where we can just update the soa of an ldns_zone
struct (which I had hoped ldns_zone_set_soa() could do, but AFAIK that's
not the case)
Serial numbers with more then 10 digits will be truncated. Signed zones
are not touched. If -s (strip DNSSEC) is specified, it pads the serial
to 10 characters. If -S <serial> is specified, the serial is changed as
well.
[paul at thinkpad pri]$ cat example.com
example.com. IN SOA ns1.xelerance.net. hostmaster.xelerance.net. (
666 ; serial
18000 ; refresh
3600 ; retry
864000 ; expire
3600 ) ; minimum
IN NS ns0.xelerance.nl.
IN MX 10 tla.xelerance.com.
IN A 193.110.157.130
[paul at thinkpad pri]$ ldns-read-zone example.com
example.com. 3600 IN SOA ns1.xelerance.net. hostmaster.xelerance.net. 666 18000 3600 864000 3600
example.com. 3600 IN NS ns0.xelerance.nl.
example.com. 3600 IN MX 10 tla.xelerance.com.
example.com. 3600 IN A 193.110.157.130
[paul at thinkpad pri]$ ldns-read-zone -s example.com
example.com. 3600 IN SOA ns1.xelerance.net. hostmaster.xelerance.net. 666 18000 3600 864000 3600
example.com. 3600 IN A 193.110.157.130
example.com. 3600 IN MX 10 tla.xelerance.com.
example.com. 3600 IN NS ns0.xelerance.nl.
[paul at thinkpad pri]$ ldns-read-zone -s -S 20111014 example.com
example.com. 3600 IN SOA ns1.xelerance.net. hostmaster.xelerance.net. 20111014 18000 3600 864000 3600
example.com. 3600 IN A 193.110.157.130
example.com. 3600 IN MX 10 tla.xelerance.com.
example.com. 3600 IN NS ns0.xelerance.nl.
Paul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ldns-1.6.11-serial.patch
Type: text/x-diff
Size: 2343 bytes
Desc:
URL: <http://lists.nlnetlabs.nl/pipermail/ldns-users/attachments/20111014/065b17e9/attachment.bin>
More information about the ldns-users
mailing list