]> mj.ucw.cz Git - nsc-5.git/commitdiff
Relative names with dots are now allowed if the dots are escaped
authorMartin Mares <mj@ucw.cz>
Sat, 27 Jun 2020 16:23:35 +0000 (18:23 +0200)
committerMartin Mares <mj@ucw.cz>
Sat, 27 Jun 2020 16:23:35 +0000 (18:23 +0200)
README
TODO
cf.dist/example.com
m4/dnslib.m4
m4/nsc.m4

diff --git a/README b/README
index 529020e584b721a5fa554e18459697b955c3cb82..2733214a6a2264625185b085e6373d8579dd4ad4 100644 (file)
--- a/README
+++ b/README
@@ -194,9 +194,8 @@ output with your own records.
 
 All host or domain names are either names relative to the current domain
 with no dots inside or absolute names (in this case, NSC automatically
 
 All host or domain names are either names relative to the current domain
 with no dots inside or absolute names (in this case, NSC automatically
-ensures that the trailing dot is present in the resource records). Relative
-names with dots are not supported, but they are rare and you can always write
-them as absolute anyway.
+ensures that the trailing dot is present in the resource records). If you
+really need a relative name with dots, escape all dots as "\.".
 
 Your menu:
 
 
 Your menu:
 
diff --git a/TODO b/TODO
index 0845c7c6df236acf689cec5e183c0d6b1696dc81..ba839b3fd0c4de96542c295633a1657dfbe783bb 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,4 +1,3 @@
 freebsd: don't use `-f' in hostname
 
 - Update or delete nsc.lsm
 freebsd: don't use `-f' in hostname
 
 - Update or delete nsc.lsm
-- do we still need root.cache?
index b5e900c68df21af2f3ef4ba37cd97463f8ba3f0f..6a575517b8a9397538f67beb6df962d234671319 100644 (file)
@@ -26,10 +26,11 @@ RP(admin.example.com, text)
 H(ns1, 10.0.0.1)
 H(ns2, 10.1.0.1)
 H(mail, 10.0.0.2)
 H(ns1, 10.0.0.1)
 H(ns2, 10.1.0.1)
 H(mail, 10.0.0.2)
+H(name\.with\.dots, 10.0.0.3)
 
 ; A web server with several aliases and MX records
 
 
 ; A web server with several aliases and MX records
 
-H(www, 10.0.0.3)
+H(www, 10.0.0.4)
 ALIAS(fairytales, scifi, horror)
 MX(0 mail.example.com)
 
 ALIAS(fairytales, scifi, horror)
 MX(0 mail.example.com)
 
index 414aa65c9121d08b69fe50bc0ae958dbd9a88f4a..5997262bc58f1b2eb6c3e051a3adfdf5c4dbf298 100644 (file)
@@ -28,10 +28,11 @@ define(nsc_file_name, `translit($1,/,@)')
 define(nsc_revIPa, `ifelse($#, 1, `$1', `nsc_revIPa(shift($@)).$1')')
 define(nsc_revaddr, `nsc_revIPa(translit($1, `.', `,'))')
 
 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
 
 
 # Normalize IPv6 address
 
index cf7a81dcca1514f0d7a7f2074eca802b49e65c84..8a94bc29154f2217f26e16b09372ab044f115da5 100644 (file)
--- a/m4/nsc.m4
+++ b/m4/nsc.m4
@@ -28,9 +28,9 @@ define(`VERSION',TODAY_CODE`'format(`%02d', SUBVER_NUM))
 
 # Record names
 
 
 # Record names
 
-define(nsc_set_name, `define(`CURRENT_NAME', nsc_corr_dot($1))define(`PRINT_NAME', CURRENT_NAME)')
+define(nsc_set_name, `define(`CURRENT_NAME', nsc_name($1))define(`PRINT_NAME', CURRENT_NAME)')
 define(nsc_emit_name, `ifdef(`PRINT_NAME', `PRINT_NAME`'undefine(`PRINT_NAME')', `')')
 define(nsc_emit_name, `ifdef(`PRINT_NAME', `PRINT_NAME`'undefine(`PRINT_NAME')', `')')
-define(nsc_abs_name, `ifelse(CURRENT_NAME, translit(CURRENT_NAME,.,:), CURRENT_NAME.CURRENT_DOMAIN, CURRENT_NAME)')
+define(nsc_abs_name, `ifelse(regexp(CURRENT_NAME,\.$),-1,CURRENT_NAME.CURRENT_DOMAIN,CURRENT_NAME)')
 define(nsc_abs_name_nodot, `define(`nsc_tmp', nsc_abs_name)substr(nsc_tmp,0,decr(len(nsc_tmp)))')
 
 # SOA record
 define(nsc_abs_name_nodot, `define(`nsc_tmp', nsc_abs_name)substr(nsc_tmp,0,decr(len(nsc_tmp)))')
 
 # SOA record
@@ -38,7 +38,7 @@ define(nsc_abs_name_nodot, `define(`nsc_tmp', nsc_abs_name)substr(nsc_tmp,0,decr
 define(nsc_SOA, `
 ifelse(CURRENT_DOMAIN,@,`',$ORIGIN CURRENT_DOMAIN)
 $TTL   MINTTL
 define(nsc_SOA, `
 ifelse(CURRENT_DOMAIN,@,`',$ORIGIN CURRENT_DOMAIN)
 $TTL   MINTTL
-nsc_emit_name  `SOA'   nsc_corr_dot(NSNAME) MAINTNAME (
+nsc_emit_name  `SOA'   nsc_name(NSNAME) MAINTNAME (
                VERSION REFRESH RETRY EXPIRE MINTTL )')
 define(SOA, `ifdef(`CURRENT_DOMAIN',`ifdef(`REVERSE_MODE',,`nsc_fatal_error(`SOA record defined twice')')')dnl
 define(`CURRENT_DOMAIN',ifelse($1,@,@,$1.))dnl
                VERSION REFRESH RETRY EXPIRE MINTTL )')
 define(SOA, `ifdef(`CURRENT_DOMAIN',`ifdef(`REVERSE_MODE',,`nsc_fatal_error(`SOA record defined twice')')')dnl
 define(`CURRENT_DOMAIN',ifelse($1,@,@,$1.))dnl
@@ -105,13 +105,13 @@ define(GLUE, `DH($@)')
 
 # NS record
 
 
 # NS record
 
-define(nsc_NS, `nsc_emit_name  `NS'    nsc_corr_dot($1)
+define(nsc_NS, `nsc_emit_name  `NS'    nsc_name($1)
 ')
 define(NS, `nsc_iterate(`nsc_NS', $@)dnl')
 
 # MX record
 
 ')
 define(NS, `nsc_iterate(`nsc_NS', $@)dnl')
 
 # MX record
 
-define(nsc_MX, `nsc_emit_name  `MX'    nsc_corr_dot($1)
+define(nsc_MX, `nsc_emit_name  `MX'    nsc_name($1)
 ')
 define(MX, `nsc_iterate(`nsc_MX', $@)dnl')
 
 ')
 define(MX, `nsc_iterate(`nsc_MX', $@)dnl')
 
@@ -131,19 +131,19 @@ define(TXT, `nsc_emit_name        `TXT'   "$1"')
 
 # RP (responsible person) records
 
 
 # RP (responsible person) records
 
-define(RP, `nsc_emit_name      `RP'    nsc_corr_dot($1) nsc_corr_dot($2)')
+define(RP, `nsc_emit_name      `RP'    nsc_name($1) nsc_name($2)')
 
 # SRV records
 
 
 # SRV records
 
-define(SRV, `_`'$1`'._`'$2`'.CURRENT_NAME      `SRV'   $3 $4 $5 nsc_corr_dot($6)`'nsc_set_name(CURRENT_NAME)')
+define(SRV, `_`'$1`'._`'$2`'.CURRENT_NAME      `SRV'   $3 $4 $5 nsc_name($6)`'nsc_set_name(CURRENT_NAME)')
 
 # CNAME records
 
 
 # CNAME records
 
-define(CNAME, `$1      `CNAME' nsc_corr_dot($2)')
+define(CNAME, `$1      `CNAME' nsc_name($2)')
 
 # Explicit PTR records
 
 
 # Explicit PTR records
 
-define(PTR, `$1        `PTR'   nsc_corr_dot($2)')
+define(PTR, `$1        `PTR'   nsc_name($2)')
 
 # DS records (DNSSEC keys for subdomains)
 
 
 # DS records (DNSSEC keys for subdomains)