Wrong processing of multiple $INCLUDE directives
Let there be a zone file named tul.cz.zone
:
$TTL 24h
$ORIGIN tul.cz.
@ IN SOA bubo.tul.cz. satrapa.bubo.tul.cz. (
201905290
3600
1800
2419200
86400
)
IN NS bubo.tul.cz.
IN NS tul.cesnet.cz.
IN MX 0 bubo.tul.cz.
IN MX 50 tul.cesnet.cz.
$INCLUDE "adm.tul.cz.zone";
$INCLUDE "is.tul.cz.zone";
web IN A 147.230.16.27
www IN CNAME web.tul.cz.
This file includes two zonelets, is.tul.cz.zone
:
$ORIGIN is.tul.cz.
c200ms IN A 147.230.89.208
and adm.tul.cz.zone
:
$ORIGIN adm.tul.cz.
G-MaR IN A 147.230.13.18
If the zonelets are included in the order shown above, Knot refuses to load the zone:
# kzonecheck tul.cz.zone -v
error: [tul.cz.] zone loader, fatal error in zone, file 'tul.cz.zone', line 20 (file open error)
error: [tul.cz.] zone loader, failed to load zone, file 'tul.cz.zone', 1 errors
Failed to run semantic checks (failed)
Strace shows there's something fishy with the file name:
# strace kzonecheck tul.cz.zone
…
open("/etc/knot/adm.tul.cz.zone", O_RDONLY) = 4
…
open("/etc/knot/is.tul.cz.zonee", O_RDONLY) = -1 ENOENT (No such file or directory)
…
Please note the double e
in the second filename (which is one character shorter). Changing the order of the includes so the shorter file name comes first works around the issue.