dnl ###
-dnl ### NSC 3.0 -- Library Functions For DNS Processing
-dnl ### (c) 1997--2003 Martin Mares <mj@ucw.cz>
+dnl ### NSC -- Library Functions For DNS Processing
+dnl ### (c) 1997--2019 Martin Mares <mj@ucw.cz>
dnl ###
divert(-1)
# NSC version
-define(`NSCVER', `NSC 2.99a')
+define(`NSCVER', `NSC 5.0')
# Current date and time
define(HOURS, `eval($1*3600)')
define(DAYS, `eval($1*86400)')
+# Since slashes can occur in zone names, we convert them to @'s
+
+define(nsc_file_name, `translit($1,/,@)')
+
# Reverse an IP address
define(nsc_revIPa, `ifelse($#, 1, `$1', `nsc_revIPa(shift($@)).$1')')
define(nsc_revaddr, `nsc_revIPa(translit($1, `.', `,'))')
-# Fix up dots in a name: if the name is not simple (i.e., it contains at least one dot),
-# ensure that it ends with a dot.
+# Fix up dots in a name: If the name is not simple (i.e., it contains at least one unescaped
+# dot), ensure that it ends with a dot. Then unescape all escaped dots (\.).
-define(nsc_corr_dot, `ifelse(substr($1,decr(len($1))),.,$1,$1`'ifelse(index($1,.),-1,,.))')
+define(nsc_name, `nsc_unescape_name(ifelse(substr($1,decr(len($1))),.,$1,$1`'ifelse(regexp($1,`[^\\]\.'),-1,,.)))')
+define(nsc_unescape_name,`patsubst(`$1',\\\.,.)')
# Normalize IPv6 address
define(nsc_if_v6, `ifelse(index($1,:),-1,`$3',`$2')')
-define(nsc_norm_v6, `nsc_norm_v6_z(dnl
-ifelse(regexp($1,`::.*::'),-1,`ifelse(index($1,::),-1,`nsc_norm_v6_nn($1)',`nsc_norm_v6_cc($1)')',`nsc_bad_v6($1)'))')
+define(nsc_norm_v6, `nsc_norm_v6_z(ifelse(regexp($1,`::.*::'),-1,`ifelse(index($1,::),-1,`nsc_norm_v6_nn($1)',`nsc_norm_v6_cc($1)')',`nsc_bad_v6($1)'))')
# If there is no ::, check the number of :'s
define(nsc_norm_v6_nn, `ifelse(nsc_extract_colons($1),:::::::,$1,`nsc_bad_v6($1)')')
# Replace :: by the right number of :'s to get 8 (possibly empty) components
define(REV, `nsc_if_v6($1,`nsc_revblock6($1).ip6.arpa',`nsc_revaddr($1).in-addr.arpa')')
+# DNSSEC wrapper
+
+define(`USE_DNSSEC')
+define(`DNSSEC', `define(`USE_DNSSEC',1)$1define(`USE_DNSSEC')')
+
# A for loop macro from m4 doc
define(`nsc_forloop',
define(`nsc_fatal_error', `errprint(`NSC error: $1
')m4exit(1)')
-# Default values of parameters and user configuration
-
-define(`NAMED_RESTART_CMD', `ndc reload')
+# Default values of parameters
-define(`BIND_OPTIONS', ` # Other options can be added here via macro BIND_OPTIONS')
+define(`NAMED_RESTART_CMD', `rndc reload')
-define(`ROOT', `/etc/named')
define(`CFDIR', `cf')
-define(`ZONEDIR', `zone')
-define(`BAKDIR', `bak')
define(`VERSDIR', `ver')
-define(`ROOTCACHE', `root.cache')
define(`REFRESH', HOURS(8))
define(`RETRY', HOURS(2))
',`'))
define(`MAINTNAME', `root'.`nsc_corr_dot(NSNAME)')
+define(`KEYGEN_OPTIONS', `-a RSASHA256 -b 1024')
+define(`SIGNZONE_OPTIONS', `-e +'DAYS(365))
+define(`DSFROMKEY_OPTIONS', `')
+
+# And finally we change comments to semicolons to be compatible with the zone files
+
+changecom(;)
+
+; User-defined parts of configuration
+
include(CFDIR/config)