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

RELNOTES
common/options.c
common/parse.c
common/tables.c
server/stables.c

index b1392b5f56b0c70337eb239a7def0e2a9389b16d..c1303d37696cd888b1b7b2a5f9711ed465ea6ab4 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -90,6 +90,12 @@ dhcp-users@lists.isc.org.
 - Corrected a number of reference counter and zero-length buffer leaks.
   [Gitlab #57]
 
+- 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
+  [Gitlab #68]
+
                        Changes since 4.1-ESV-R15
 
 - Corrected dhclient command line parsing for --dad-wait-time that causes
index b9a525c050c117fff92a804df1c04c87bd7ff7d2..42bfb721da19adc21efb4636002e0f9751106055 100644 (file)
@@ -1607,6 +1607,7 @@ format_has_text(format)
        while (*p != '\0') {
                switch (*p++) {
                    case 't':
+                   case 'k':
                        return 1;
 
                        /* These symbols are arbitrary, not fixed or
@@ -1738,6 +1739,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. */
@@ -1880,6 +1882,7 @@ 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;
@@ -2023,6 +2026,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 eabf3ed278e00200293891a61953f9dac785e35d..e78223c2ef8275e053814c2738257ac21f939258 100644 (file)
@@ -5293,7 +5293,32 @@ 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 559793eda5d344b9279b655425d90c37bcb816ad..80dd22984073d1c19e14cb8ac01fb8a394aa69a2 100644 (file)
@@ -85,10 +85,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 d2bea4427452efb8f93950cc1458daf623935456..d58b604f264e72928b8809c5ce8e8dd8c598632e 100644 (file)
@@ -210,7 +210,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 },