]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
[master] Implement and use new option format type 'k'
authorThomas Markwalder <tmark@isc.org>
Tue, 17 Dec 2019 18:59:24 +0000 (13:59 -0500)
committerThomas Markwalder <tmark@isc.org>
Tue, 17 Dec 2019 18:59:24 +0000 (13:59 -0500)
    Merges in #68.

RELNOTES
common/options.c
common/parse.c
common/tables.c
configure
configure.ac
configure.ac+lt
configure.ac-base
configure.ac-lt
server/ldap.c
server/stables.c

index d0b6eb3b82ce76be1b26f09601abf2fde4853846..97edb02470da0ae16c715ef1d4f2a7103c735613 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -225,6 +225,13 @@ by Eric Young (eay@cryptsoft.com).
   values (e.g. next-server).
   [Gitlab #28]
 
+- The option format for the server option omapi-key was changed to a
+  format type 'k' (key name); while server options ldap-port and
+  ldap-init-retry were changed to 'L' (unsigned 32-bit integer). These
+  three options were inadvertantly broken when the 'd' format content
+  was changed to comply with RFC 1035 wire format (see Gitlab #2).
+  [Gitlab #68]
+
                Changes since 4.4.0 (New Features)
 - none
                Changes since 4.4.0 (Bug Fixes)
index 4e1fe99eaae14b73b48072bf6d00d1a5656c655d..a7ed84c697d533a326aca899b14536b296b339db 100644 (file)
@@ -1631,6 +1631,7 @@ format_has_text(format)
        while (*p != '\0') {
                switch (*p++) {
                    case 't':
+                   case 'k':
                        return 1;
 
                        /* These symbols are arbitrary, not fixed or
@@ -1762,6 +1763,7 @@ format_min_length(format, oc)
                    case 'A': /* Array of all that precedes. */
                    case 'a': /* Array of preceding symbol. */
                    case 'Z': /* nothing. */
+                   case 'k': /* key name */
                        return min_len;
 
                    case 'c': /* Compress flag for D atom. */
@@ -1903,7 +1905,9 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes)
                        }
                        hunksize += k;
                        break;
+                       
                      case 't':
+                     case 'k':
                        fmtbuf[l + 1] = 0;
                        numhunk = -2;
                        break;
@@ -2047,6 +2051,7 @@ const char *pretty_print_option (option, data, len, emit_commas, emit_quotes)
                for (; j < numelem; j++) {
                        switch (fmtbuf [j]) {
                              case 't':
+                             case 'k':
                                /* endbuf-1 leaves room for NULL. */
                                k = pretty_text(&op, endbuf - 1, &dp,
                                                data + len, emit_quotes);
index 8619f852d17e32f6ba6ba8244353593e54a860ef..386a6321dc988925d9e5022464a4f43653e6393f 100644 (file)
@@ -5058,7 +5058,33 @@ int parse_option_token (rv, cfile, fmt, expr, uniform, lookups)
                        POST(freeval);
                }
                break;
-               
+
+             case 'k': /* key name */ 
+               token = peek_token (&val, &len, cfile);
+               if (token == STRING) {
+                       token = next_token (&val, &len, cfile);
+               } else {
+                       val = parse_host_name(cfile);
+                       if (!val) {
+                               parse_warn(cfile, "not a valid key name.");
+                               skip_to_semi(cfile);
+                               return 0;
+                       }
+                       freeval = ISC_TRUE;
+               }
+
+               if (!make_const_data (&t, (const unsigned char *)val,
+                                     strlen(val), 1, 1, MDL)) {
+                       log_fatal ("No memory key name");
+               }
+
+               if (freeval == ISC_TRUE) {
+                       dfree((char *)val, MDL);
+                       freeval = ISC_FALSE;
+               }
+
+               break;
+
              case 'N':
                f = (*fmt) + 1;
                g = strchr (*fmt, '.');
index c1aa21450459bf5e50ce943ace919b0b835b038e..6952bc0fb9b79926b5979978c5d62f7aeb6a0234 100644 (file)
@@ -84,10 +84,14 @@ HASH_FUNCTIONS (option_code, const unsigned *, struct option,
        the name of the set of enumeration values to parse or emit,
        followed by a '.'.   The width of the data is specified in the
        named enumeration.   Named enumerations are tracked in parse.c.
-   d - Domain name (i.e., FOO or FOO.BAR).
-   D - Domain list (i.e., example.com eng.example.com)
+   d - Domain name (e.g., FOO or FOO.BAR) no quotes,
+       on-wire format is RFC 1035.
+   D - Domain list (e.g., "example.com eng.example.com") quoted, 
+       on-wire format is RFC 1035.
    c - When following a 'D' atom, enables compression pointers.
    Z - Zero-length option
+   k - Key name, unquoted string (e.g. mykey.com or some-text or abc123)
+       parsed with parse_host_name().
 */
 
 struct universe dhcp_universe;
index 3e2af118e12ac5c471da6cd41cd98d9c1e10ee0a..fb60de60944aaa3f7592125461e2dd72583b09b5 100755 (executable)
--- a/configure
+++ b/configure
@@ -5591,7 +5591,7 @@ fi
 # Testing section
 
 # Bind Makefile needs to know ATF is not included.
- if 0; then
+ if test "foo" = "barr"; then
   BIND_ATF_TRUE=
   BIND_ATF_FALSE='#'
 else
index c401d393708afbc175bfb06258f72f0b4136c581..c5d88f702296c111eddc1c05914e6ea96ce16b87 100644 (file)
@@ -250,7 +250,7 @@ fi
 # Testing section
 
 # Bind Makefile needs to know ATF is not included.
-AM_CONDITIONAL(BIND_ATF, 0)
+AM_CONDITIONAL(BIND_ATF, test "foo" = "barr")
 
 DISTCHECK_ATF_CONFIGURE_FLAG=
 atf_path="no"
index 44e2517dbb844a03803e13dc08a28989a7a2f948..2dc3231e00bac703cff7ca49bcfaaa96c78588e1 100644 (file)
@@ -251,7 +251,7 @@ fi
 # Testing section
 
 # Bind Makefile needs to know ATF is not included.
-AM_CONDITIONAL(BIND_ATF, 0)
+AM_CONDITIONAL(BIND_ATF, test "foo" = "barr")
 
 DISTCHECK_ATF_CONFIGURE_FLAG=
 atf_path="no"
index bcc3546ae41c915398ecbbfdc461a223f04a55e1..864c1cdb1b9e490fc3bb1fbf12d38f55387bff5f 100644 (file)
@@ -256,7 +256,7 @@ fi
 # Testing section
 
 # Bind Makefile needs to know ATF is not included.
-AM_CONDITIONAL(BIND_ATF, 0)
+AM_CONDITIONAL(BIND_ATF, test "foo" = "barr")
 
 DISTCHECK_ATF_CONFIGURE_FLAG=
 atf_path="no"
index c401d393708afbc175bfb06258f72f0b4136c581..c5d88f702296c111eddc1c05914e6ea96ce16b87 100644 (file)
@@ -250,7 +250,7 @@ fi
 # Testing section
 
 # Bind Makefile needs to know ATF is not included.
-AM_CONDITIONAL(BIND_ATF, 0)
+AM_CONDITIONAL(BIND_ATF, test "foo" = "barr")
 
 DISTCHECK_ATF_CONFIGURE_FLAG=
 atf_path="no"
index 46b13d00e02503ae2cb65eff7eac2ae7ed9c79e4..8e80d5b52f16b810aaa6f3e289f23eb272ae75c3 100644 (file)
@@ -1137,7 +1137,7 @@ _do_lookup_dhcp_int_option (struct option_state *options, int option_name)
 {
   struct option_cache *oc;
   struct data_string db;
-  int ret;
+  int ret = 0;
 
   memset (&db, 0, sizeof (db));
   oc = lookup_option (&server_universe, options, option_name);
@@ -1147,13 +1147,14 @@ _do_lookup_dhcp_int_option (struct option_state *options, int option_name)
                              (struct client_state *) NULL, options,
                              (struct option_state *) NULL,
                              &global_scope, oc, MDL) &&
-      db.data != NULL && *db.data != '\0')
+      db.data != NULL)
     {
-      ret = strtol ((const char *) db.data, NULL, 10);
+      if (db.len == 4) {
+         ret = getULong(db.data);
+      } 
+
       data_string_forget (&db, MDL);
     }
-  else
-    ret = 0;
 
   return (ret);
 }
index d0d9fc364056ccc046681a19f720b40aeb0b38b5..43408c550c46c552f117885f5e96bdd7e1e3c0b9 100644 (file)
@@ -211,7 +211,7 @@ static struct option server_options[] = {
        { "limited-broadcast-address", "I",     &server_universe,  33, 1 },
        { "remote-port", "S",                   &server_universe,  34, 1 },
        { "local-address", "I",                 &server_universe,  35, 1 },
-       { "omapi-key", "d",                     &server_universe,  36, 1 },
+       { "omapi-key", "k",                     &server_universe,  36, 1 },
        { "stash-agent-options", "f",           &server_universe,  37, 1 },
        { "ddns-ttl", "T",                      &server_universe,  38, 1 },
        { "ddns-update-style", "Nddns-styles.", &server_universe,  39, 1 },
@@ -241,7 +241,7 @@ static struct option server_options[] = {
 #endif
 #if defined(LDAP_CONFIGURATION)
        { "ldap-server", "t",                   &server_universe,  60, 1 },
-       { "ldap-port", "d",                     &server_universe,  61, 1 },
+       { "ldap-port", "L",                     &server_universe,  61, 1 },
        { "ldap-username", "t",                 &server_universe,  62, 1 },
        { "ldap-password", "t",                 &server_universe,  63, 1 },
        { "ldap-base-dn", "t",                  &server_universe,  64, 1 },
@@ -259,7 +259,7 @@ static struct option server_options[] = {
        { "ldap-tls-crlcheck", "Nldap-tls-crlcheck.",   &server_universe,  75, 1 },
        { "ldap-tls-ciphers", "t",              &server_universe,  76, 1 },
        { "ldap-tls-randfile", "t",             &server_universe,  77, 1 },
-       { "ldap-init-retry", "d",               &server_universe,  SV_LDAP_INIT_RETRY, 1 },
+       { "ldap-init-retry", "L",               &server_universe,  SV_LDAP_INIT_RETRY, 1 },
 #endif /* LDAP_USE_SSL */
 #if defined(LDAP_USE_GSSAPI)
        { "ldap-gssapi-keytab", "t",        &server_universe,  SV_LDAP_GSSAPI_KEYTAB, 1},