]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
4885. [security] update-policy rules that otherwise ignore the name
authorMark Andrews <marka@isc.org>
Wed, 7 Feb 2018 02:34:02 +0000 (13:34 +1100)
committerMark Andrews <marka@isc.org>
Wed, 7 Feb 2018 02:51:05 +0000 (13:51 +1100)
                        field now require that it be set to "." to ensure
                        that any type list present is properly interpreted.
                        [RT #47126]

(cherry picked from commit ec771bbdc80223ab94eda2173f3b20fd3ecfad49)

29 files changed:
CHANGES
bin/named/zoneconf.c
bin/tests/system/checkconf/bad-update-policy1.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-update-policy2.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-update-policy3.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-update-policy4.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-update-policy5.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-update-policy6.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-update-policy7.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-update-policy8.conf [new file with mode: 0644]
bin/tests/system/checkconf/bad-update-policy9.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy1.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy10.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy11.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy12.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy2.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy3.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy4.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy5.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy6.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy7.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy8.conf [new file with mode: 0644]
bin/tests/system/checkconf/good-update-policy9.conf [new file with mode: 0644]
bin/tests/system/checkconf/tests.sh
doc/arm/Bv9ARM-book.xml
lib/bind9/check.c
lib/dns/include/dns/ssu.h
lib/dns/ssu.c
lib/dns/win32/libdns.def.in

diff --git a/CHANGES b/CHANGES
index f1b270d996a2f52852c833c4326deb14756ba5d8..5a9e42960e7472400cca3bbed33dc2997932f931 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,8 @@
+4885.  [security]      update-policy rules that otherwise ignore the name
+                       field now require that it be set to "." to ensure
+                       that any type list present is properly interpreted.
+                       [RT #47126]
+
 4882.  [bug]           Address potential memory leak in
                        dns_update_signaturesinc. [RT #47084]
 
index ecbae17b288acff097bf5d2310f626ca02330639..a0d17d6584c131cf4fb9485471679683a1722ef2 100644 (file)
@@ -224,7 +224,7 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone,
                const char *str;
                isc_boolean_t grant = ISC_FALSE;
                isc_boolean_t usezone = ISC_FALSE;
-               unsigned int mtype = DNS_SSUMATCHTYPE_NAME;
+               dns_ssumatchtype_t mtype = DNS_SSUMATCHTYPE_NAME;
                dns_fixedname_t fname, fident;
                isc_buffer_t b;
                dns_rdatatype_t *types;
@@ -239,37 +239,10 @@ configure_zone_ssutable(const cfg_obj_t *zconfig, dns_zone_t *zone,
                        INSIST(0);
 
                str = cfg_obj_asstring(matchtype);
-               if (strcasecmp(str, "name") == 0)
-                       mtype = DNS_SSUMATCHTYPE_NAME;
-               else if (strcasecmp(str, "subdomain") == 0)
-                       mtype = DNS_SSUMATCHTYPE_SUBDOMAIN;
-               else if (strcasecmp(str, "wildcard") == 0)
-                       mtype = DNS_SSUMATCHTYPE_WILDCARD;
-               else if (strcasecmp(str, "self") == 0)
-                       mtype = DNS_SSUMATCHTYPE_SELF;
-               else if (strcasecmp(str, "selfsub") == 0)
-                       mtype = DNS_SSUMATCHTYPE_SELFSUB;
-               else if (strcasecmp(str, "selfwild") == 0)
-                       mtype = DNS_SSUMATCHTYPE_SELFWILD;
-               else if (strcasecmp(str, "ms-self") == 0)
-                       mtype = DNS_SSUMATCHTYPE_SELFMS;
-               else if (strcasecmp(str, "krb5-self") == 0)
-                       mtype = DNS_SSUMATCHTYPE_SELFKRB5;
-               else if (strcasecmp(str, "ms-subdomain") == 0)
-                       mtype = DNS_SSUMATCHTYPE_SUBDOMAINMS;
-               else if (strcasecmp(str, "krb5-subdomain") == 0)
-                       mtype = DNS_SSUMATCHTYPE_SUBDOMAINKRB5;
-               else if (strcasecmp(str, "tcp-self") == 0)
-                       mtype = DNS_SSUMATCHTYPE_TCPSELF;
-               else if (strcasecmp(str, "6to4-self") == 0)
-                       mtype = DNS_SSUMATCHTYPE_6TO4SELF;
-               else if (strcasecmp(str, "zonesub") == 0) {
-                       mtype = DNS_SSUMATCHTYPE_SUBDOMAIN;
+               CHECK(dns_ssu_mtypefromstring(str, &mtype));
+               if (mtype == dns_ssumatchtype_subdomain) {
                        usezone = ISC_TRUE;
-               } else if (strcasecmp(str, "external") == 0)
-                       mtype = DNS_SSUMATCHTYPE_EXTERNAL;
-               else
-                       INSIST(0);
+               }
 
                dns_fixedname_init(&fident);
                str = cfg_obj_asstring(identity);
diff --git a/bin/tests/system/checkconf/bad-update-policy1.conf b/bin/tests/system/checkconf/bad-update-policy1.conf
new file mode 100644 (file)
index 0000000..91cc51d
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * self TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/bad-update-policy2.conf b/bin/tests/system/checkconf/bad-update-policy2.conf
new file mode 100644 (file)
index 0000000..ae39351
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * selfsub TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/bad-update-policy3.conf b/bin/tests/system/checkconf/bad-update-policy3.conf
new file mode 100644 (file)
index 0000000..792231d
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * selfwild TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/bad-update-policy4.conf b/bin/tests/system/checkconf/bad-update-policy4.conf
new file mode 100644 (file)
index 0000000..7175a43
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * ms-self TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/bad-update-policy5.conf b/bin/tests/system/checkconf/bad-update-policy5.conf
new file mode 100644 (file)
index 0000000..93bb95c
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * krb5-self TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/bad-update-policy6.conf b/bin/tests/system/checkconf/bad-update-policy6.conf
new file mode 100644 (file)
index 0000000..df7c9ca
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * ms-subdomain TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/bad-update-policy7.conf b/bin/tests/system/checkconf/bad-update-policy7.conf
new file mode 100644 (file)
index 0000000..c11555a
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * krb5-subdomain TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/bad-update-policy8.conf b/bin/tests/system/checkconf/bad-update-policy8.conf
new file mode 100644 (file)
index 0000000..1b04def
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * tcp-self TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/bad-update-policy9.conf b/bin/tests/system/checkconf/bad-update-policy9.conf
new file mode 100644 (file)
index 0000000..2286751
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * 6to4-self TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy1.conf b/bin/tests/system/checkconf/good-update-policy1.conf
new file mode 100644 (file)
index 0000000..7f0b205
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * self * TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy10.conf b/bin/tests/system/checkconf/good-update-policy10.conf
new file mode 100644 (file)
index 0000000..563abdf
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * krb5-subdomain . TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy11.conf b/bin/tests/system/checkconf/good-update-policy11.conf
new file mode 100644 (file)
index 0000000..a7baf3b
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * tcp-self . TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy12.conf b/bin/tests/system/checkconf/good-update-policy12.conf
new file mode 100644 (file)
index 0000000..898c256
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * 6to4-self . TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy2.conf b/bin/tests/system/checkconf/good-update-policy2.conf
new file mode 100644 (file)
index 0000000..81c25bd
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * self . TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy3.conf b/bin/tests/system/checkconf/good-update-policy3.conf
new file mode 100644 (file)
index 0000000..f7fe7f1
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * selfsub . TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy4.conf b/bin/tests/system/checkconf/good-update-policy4.conf
new file mode 100644 (file)
index 0000000..c404761
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * selfsub * TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy5.conf b/bin/tests/system/checkconf/good-update-policy5.conf
new file mode 100644 (file)
index 0000000..d1f2f0b
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * selfwild * TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy6.conf b/bin/tests/system/checkconf/good-update-policy6.conf
new file mode 100644 (file)
index 0000000..424f511
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * selfwild . TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy7.conf b/bin/tests/system/checkconf/good-update-policy7.conf
new file mode 100644 (file)
index 0000000..e2cf613
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * krb5-self . TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy8.conf b/bin/tests/system/checkconf/good-update-policy8.conf
new file mode 100644 (file)
index 0000000..ec8610b
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * ms-self . TXT;
+       };
+};
diff --git a/bin/tests/system/checkconf/good-update-policy9.conf b/bin/tests/system/checkconf/good-update-policy9.conf
new file mode 100644 (file)
index 0000000..9c37dbc
--- /dev/null
@@ -0,0 +1,7 @@
+zone "example.com" {
+       type master;
+       file "example.com.db";
+       update-policy {
+               grant * ms-subdomain . TXT;
+       };
+};
index a86585b3954f6cfba333a168672b2047d7476a9f..007a7c3d5a3e628dd1271af56dc9e4ced502da30 100644 (file)
@@ -50,14 +50,24 @@ status=`expr $status + $ret`
 
 for bad in bad*.conf
 do
-       n=`expr $n + 1`
-       echo "I: checking that named-checkconf detects error in $bad ($n)"
-       ret=0
-       $CHECKCONF $bad > checkconf.out 2>&1
-       if [ $? != 1 ]; then ret=1; fi
-       grep "^$bad:[0-9]*: " checkconf.out > /dev/null || ret=1
-       if [ $ret != 0 ]; then echo "I:failed"; fi
-       status=`expr $status + $ret`
+    n=`expr $n + 1`
+    echo "I: checking that named-checkconf detects error in $bad ($n)"
+    ret=0
+    $CHECKCONF $bad > checkconf.out 2>&1
+    if [ $? != 1 ]; then ret=1; fi
+    grep "^$bad:[0-9]*: " checkconf.out > /dev/null || ret=1
+    case $bad in
+    bad-update-policy[123].conf)
+       pat="identity and name fields are not the same"
+       grep "$pat" checkconf.out > /dev/null || ret=1
+       ;;
+    bad-update-policy*.conf)
+       pat="name field not set to placeholder value"
+       grep "$pat" checkconf.out > /dev/null || ret=1
+       ;;
+    esac
+    if [ $ret != 0 ]; then echo "I:failed"; fi
+    status=`expr $status + $ret`
 done
 
 for good in good-*.conf
index e368abf564ae80132d235359cec7e78bdc894b4d..c7018b574a71348f2b2d84de380930d92943f0e4 100644 (file)
@@ -11812,7 +11812,8 @@ example.com. NS ns2.example.net.
                        <replaceable>identity</replaceable> field.
                        The <replaceable>name</replaceable> field
                        is ignored, but should be the same as the
-                       <replaceable>identity</replaceable> field.
+                       <replaceable>identity</replaceable> field or
+                       "."
                        The <varname>self</varname> nametype is
                        most useful when allowing using one key per
                        name to update, where the key has the same
@@ -11861,7 +11862,7 @@ example.com. NS ns2.example.net.
                        and converts it machine.realm allowing the machine
                        to update machine.realm.  The REALM to be matched
                        is specified in the <replaceable>identity</replaceable>
-                       field.
+                       field.  The name field should be set to "."
                      </para>
                    </entry>
                  </row>
@@ -11893,7 +11894,7 @@ example.com. NS ns2.example.net.
                        and converts it machine.realm allowing the machine
                        to update machine.realm.  The REALM to be matched
                        is specified in the <replaceable>identity</replaceable>
-                       field.
+                       field. The name field should be set to "."
                      </para>
                    </entry>
                  </row>
@@ -11909,7 +11910,8 @@ example.com. NS ns2.example.net.
                        converts it to machine.realm allowing the machine
                        to update subdomains of machine.realm.  The REALM
                        to be matched is specified in the
-                       <replaceable>identity</replaceable> field.
+                       <replaceable>identity</replaceable> field. The
+                       name field should be set to "."
                      </para>
                    </entry>
                  </row>
@@ -11923,7 +11925,8 @@ example.com. NS ns2.example.net.
                        Allow updates that have been sent via TCP and
                        for which the standard mapping from the initiating
                        IP address into the IN-ADDR.ARPA and IP6.ARPA
-                       namespaces match the name to be updated.
+                       namespaces match the name to be updated.  The
+                       name field should be set to "."
                      </para>
                      <note>
                        It is theoretically possible to spoof these TCP
index 9c21fc8274ec7dcaf2bcda96a923bc5b958a0d8d..081c0246f9acf5d5c1d38f39a6533038aefba560 100644 (file)
@@ -41,6 +41,7 @@
 #include <dns/rdatatype.h>
 #include <dns/rrl.h>
 #include <dns/secalg.h>
+#include <dns/ssu.h>
 
 #include <dst/dst.h>
 
@@ -1317,9 +1318,9 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) {
        isc_result_t tresult;
        const cfg_listelt_t *element;
        const cfg_listelt_t *element2;
-       dns_fixedname_t fixed;
+       dns_fixedname_t fixed_id, fixed_name;
+       dns_name_t *id, *name;
        const char *str;
-       isc_buffer_t b;
 
        /* Check for "update-policy local;" */
        if (cfg_obj_isstring(policy) &&
@@ -1336,27 +1337,36 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) {
                const cfg_obj_t *matchtype = cfg_tuple_get(stmt, "matchtype");
                const cfg_obj_t *dname = cfg_tuple_get(stmt, "name");
                const cfg_obj_t *typelist = cfg_tuple_get(stmt, "types");
+               dns_ssumatchtype_t mtype;
+
+               dns_fixedname_init(&fixed_id);
+               dns_fixedname_init(&fixed_name);
+               id = dns_fixedname_name(&fixed_id);
+               name = dns_fixedname_name(&fixed_name);
+
+               tresult = dns_ssu_mtypefromstring(cfg_obj_asstring(matchtype),
+                                                 &mtype);
+               if (tresult != ISC_R_SUCCESS) {
+                       cfg_obj_log(identity, logctx, ISC_LOG_ERROR,
+                                   "has a bad match-type");
+               }
 
-               dns_fixedname_init(&fixed);
                str = cfg_obj_asstring(identity);
-               isc_buffer_constinit(&b, str, strlen(str));
-               isc_buffer_add(&b, strlen(str));
-               tresult = dns_name_fromtext(dns_fixedname_name(&fixed), &b,
-                                           dns_rootname, 0, NULL);
+               tresult = dns_name_fromstring(id, str, 1, NULL);
                if (tresult != ISC_R_SUCCESS) {
                        cfg_obj_log(identity, logctx, ISC_LOG_ERROR,
                                    "'%s' is not a valid name", str);
                        result = tresult;
                }
 
+               /*
+                * There is no name field for subzone.
+                */
                if (tresult == ISC_R_SUCCESS &&
-                   strcasecmp(cfg_obj_asstring(matchtype), "zonesub") != 0) {
-                       dns_fixedname_init(&fixed);
+                   mtype != dns_ssumatchtype_subdomain)
+               {
                        str = cfg_obj_asstring(dname);
-                       isc_buffer_constinit(&b, str, strlen(str));
-                       isc_buffer_add(&b, strlen(str));
-                       tresult = dns_name_fromtext(dns_fixedname_name(&fixed),
-                                                   &b, dns_rootname, 0, NULL);
+                       tresult = dns_name_fromstring(name, str, 0, NULL);
                        if (tresult != ISC_R_SUCCESS) {
                                cfg_obj_log(dname, logctx, ISC_LOG_ERROR,
                                            "'%s' is not a valid name", str);
@@ -1365,13 +1375,55 @@ check_update_policy(const cfg_obj_t *policy, isc_log_t *logctx) {
                }
 
                if (tresult == ISC_R_SUCCESS &&
-                   strcasecmp(cfg_obj_asstring(matchtype), "wildcard") == 0 &&
-                   !dns_name_iswildcard(dns_fixedname_name(&fixed))) {
+                   mtype == dns_ssumatchtype_wildcard &&
+                   !dns_name_iswildcard(name))
+               {
                        cfg_obj_log(identity, logctx, ISC_LOG_ERROR,
                                    "'%s' is not a wildcard", str);
                        result = ISC_R_FAILURE;
                }
 
+               /*
+                * For some match types, the name should be a placeholder
+                * value, either "." or the same as identity.
+                */
+               switch (mtype) {
+               case dns_ssumatchtype_self:
+               case dns_ssumatchtype_selfsub:
+               case dns_ssumatchtype_selfwild:
+                       if (tresult == ISC_R_SUCCESS &&
+                           (!dns_name_equal(id, name) &&
+                            !dns_name_equal(dns_rootname, name))) {
+                               cfg_obj_log(identity, logctx, ISC_LOG_ERROR,
+                                           "identity and name fields are not "
+                                           "the same");
+                               result = ISC_R_FAILURE;
+                       }
+                       break;
+               case dns_ssumatchtype_selfkrb5:
+               case dns_ssumatchtype_selfms:
+               case dns_ssumatchtype_subdomainms:
+               case dns_ssumatchtype_subdomainkrb5:
+               case dns_ssumatchtype_tcpself:
+               case dns_ssumatchtype_6to4self:
+                       if (tresult == ISC_R_SUCCESS &&
+                           !dns_name_equal(dns_rootname, name)) {
+                               cfg_obj_log(identity, logctx, ISC_LOG_ERROR,
+                                           "name field not set to "
+                                           "placeholder value '.'");
+                               result = ISC_R_FAILURE;
+                       }
+                       break;
+               case dns_ssumatchtype_name:
+               case dns_ssumatchtype_subdomain:
+               case dns_ssumatchtype_wildcard:
+               case dns_ssumatchtype_external:
+               case dns_ssumatchtype_local:
+                       break;
+               default:
+                       INSIST(0);
+               }
+
                for (element2 = cfg_list_first(typelist);
                     element2 != NULL;
                     element2 = cfg_list_next(element2))
index a3cfca76643ae5ae8caa813033f63c4659552394..20595e8772a95a3ba0ec9c3295ad5c1cbad2eff3 100644 (file)
 
 ISC_LANG_BEGINDECLS
 
-#define DNS_SSUMATCHTYPE_NAME          0
-#define DNS_SSUMATCHTYPE_SUBDOMAIN     1
-#define DNS_SSUMATCHTYPE_WILDCARD      2
-#define DNS_SSUMATCHTYPE_SELF          3
-#define DNS_SSUMATCHTYPE_SELFSUB       4
-#define DNS_SSUMATCHTYPE_SELFWILD      5
-#define DNS_SSUMATCHTYPE_SELFKRB5      6
-#define DNS_SSUMATCHTYPE_SELFMS                7
-#define DNS_SSUMATCHTYPE_SUBDOMAINMS   8
-#define DNS_SSUMATCHTYPE_SUBDOMAINKRB5 9
-#define DNS_SSUMATCHTYPE_TCPSELF       10
-#define DNS_SSUMATCHTYPE_6TO4SELF      11
-#define DNS_SSUMATCHTYPE_EXTERNAL      12
-#define DNS_SSUMATCHTYPE_LOCAL         13
-#define DNS_SSUMATCHTYPE_MAX           13  /* max value */
-
-#define DNS_SSUMATCHTYPE_DLZ           14  /* intentionally higher than _MAX */
+typedef enum {
+       dns_ssumatchtype_name = 0,
+       dns_ssumatchtype_subdomain = 1,
+       dns_ssumatchtype_wildcard = 2,
+       dns_ssumatchtype_self    = 3,
+       dns_ssumatchtype_selfsub = 4,
+       dns_ssumatchtype_selfwild = 5,
+       dns_ssumatchtype_selfkrb5 = 6,
+       dns_ssumatchtype_selfms  = 7,
+       dns_ssumatchtype_subdomainms = 8,
+       dns_ssumatchtype_subdomainkrb5 = 9,
+       dns_ssumatchtype_tcpself = 10,
+       dns_ssumatchtype_6to4self = 11,
+       dns_ssumatchtype_external = 12,
+       dns_ssumatchtype_local = 13,
+       dns_ssumatchtype_max = 13,      /* max value */
+
+       dns_ssumatchtype_dlz = 14       /* intentionally higher than _max */
+} dns_ssumatchtype_t;
+
+#define DNS_SSUMATCHTYPE_NAME          dns_ssumatchtype_name
+#define DNS_SSUMATCHTYPE_SUBDOMAIN     dns_ssumatchtype_subdomain
+#define DNS_SSUMATCHTYPE_WILDCARD      dns_ssumatchtype_wildcard
+#define DNS_SSUMATCHTYPE_SELF          dns_ssumatchtype_self
+#define DNS_SSUMATCHTYPE_SELFSUB       dns_ssumatchtype_selfsub
+#define DNS_SSUMATCHTYPE_SELFWILD      dns_ssumatchtype_selfwild
+#define DNS_SSUMATCHTYPE_SELFKRB5      dns_ssumatchtype_selfkrb5
+#define DNS_SSUMATCHTYPE_SELFMS                dns_ssumatchtype_selfms
+#define DNS_SSUMATCHTYPE_SUBDOMAINMS   dns_ssumatchtype_subdomainms
+#define DNS_SSUMATCHTYPE_SUBDOMAINKRB5 dns_ssumatchtype_subdomainkrb5
+#define DNS_SSUMATCHTYPE_TCPSELF       dns_ssumatchtype_tcpself
+#define DNS_SSUMATCHTYPE_6TO4SELF      dns_ssumatchtype_6to4self
+#define DNS_SSUMATCHTYPE_EXTERNAL      dns_ssumatchtype_external
+#define DNS_SSUMATCHTYPE_LOCAL         dns_ssumatchtype_local
+#define DNS_SSUMATCHTYPE_MAX           dns_ssumatchtype_max  /* max value */
+
+#define DNS_SSUMATCHTYPE_DLZ           dns_ssumatchtype_dlz  /* intentionally higher than _MAX */
 
 isc_result_t
 dns_ssutable_create(isc_mem_t *mctx, dns_ssutable_t **table);
@@ -213,15 +233,28 @@ isc_result_t      dns_ssutable_nextrule(dns_ssurule_t *rule,
  *\li  #ISC_R_NOMORE
  */
 
-
-/*%<
- * Check a policy rule via an external application
- */
 isc_boolean_t
 dns_ssu_external_match(dns_name_t *identity, dns_name_t *signer,
                       dns_name_t *name, isc_netaddr_t *tcpaddr,
                       dns_rdatatype_t type, const dst_key_t *key,
                       isc_mem_t *mctx);
+/*%<
+ * Check a policy rule via an external application
+ */
+
+isc_result_t
+dns_ssu_mtypefromstring(const char *str, dns_ssumatchtype_t *mtype);
+/*%<
+ * Set 'mtype' from 'str'
+ *
+ * Requires:
+ *\li          'str' is not NULL.
+ *\li          'mtype' is not NULL,
+ *
+ * Returns:
+ *\li  #ISC_R_SUCCESS
+ *\li  #ISC_R_NOTFOUND
+ */
 
 ISC_LANG_ENDDECLS
 
index 491ba4a08e2bdd36fe6a2d65e8ec6f107b00c20e..3dc079801a3b692edd483bc4ee837464126149ff 100644 (file)
@@ -648,3 +648,43 @@ dns_ssutable_createdlz(isc_mem_t *mctx, dns_ssutable_t **tablep,
        *tablep = table;
        return (ISC_R_SUCCESS);
 }
+
+isc_result_t
+dns_ssu_mtypefromstring(const char *str, dns_ssumatchtype_t *mtype) {
+
+       REQUIRE(str != NULL);
+       REQUIRE(mtype != NULL);
+
+       if (strcasecmp(str, "name") == 0) {
+               *mtype = dns_ssumatchtype_name;
+       } else if (strcasecmp(str, "subdomain") == 0) {
+               *mtype = dns_ssumatchtype_subdomain;
+       } else if (strcasecmp(str, "wildcard") == 0) {
+               *mtype = dns_ssumatchtype_wildcard;
+       } else if (strcasecmp(str, "self") == 0) {
+               *mtype = dns_ssumatchtype_self;
+       } else if (strcasecmp(str, "selfsub") == 0) {
+               *mtype = dns_ssumatchtype_selfsub;
+       } else if (strcasecmp(str, "selfwild") == 0) {
+               *mtype = dns_ssumatchtype_selfwild;
+       } else if (strcasecmp(str, "ms-self") == 0) {
+               *mtype = dns_ssumatchtype_selfms;
+       } else if (strcasecmp(str, "krb5-self") == 0) {
+               *mtype = dns_ssumatchtype_selfkrb5;
+       } else if (strcasecmp(str, "ms-subdomain") == 0) {
+               *mtype = dns_ssumatchtype_subdomainms;
+       } else if (strcasecmp(str, "krb5-subdomain") == 0) {
+               *mtype = dns_ssumatchtype_subdomainkrb5;
+       } else if (strcasecmp(str, "tcp-self") == 0) {
+               *mtype = dns_ssumatchtype_tcpself;
+       } else if (strcasecmp(str, "6to4-self") == 0) {
+               *mtype = dns_ssumatchtype_6to4self;
+       } else if (strcasecmp(str, "zonesub") == 0) {
+               *mtype = dns_ssumatchtype_subdomain;
+       } else if (strcasecmp(str, "external") == 0) {
+               *mtype = dns_ssumatchtype_external;
+       } else {
+               return (ISC_R_NOTFOUND);
+       }
+       return (ISC_R_SUCCESS);
+}
index 76f53ab314bfb9813f548cfb6c99aa55c98569be..7cd05d61f9f587c69a00c62a7fe85a05d85693c0 100644 (file)
@@ -826,6 +826,7 @@ dns_soa_setrefresh
 dns_soa_setretry
 dns_soa_setserial
 dns_ssu_external_match
+dns_ssu_mtypefromstring
 dns_ssutable_addrule
 dns_ssutable_attach
 dns_ssutable_checkrules