]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
- Versions 3.0.x syntax with multiple name->code option definitions is now
authorDavid Hankins <dhankins@isc.org>
Thu, 16 Jul 2009 18:02:28 +0000 (18:02 +0000)
committerDavid Hankins <dhankins@isc.org>
Thu, 16 Jul 2009 18:02:28 +0000 (18:02 +0000)
  supported.  Note that, similarly to 3.0.x, for by-code lookups only the
  last option definition is used.  [ISC-Bugs #17613]

RELNOTES
client/clparse.c
common/parse.c
server/confpars.c

index 6c349cff94132c80bdaede63bb5225132754f9d3..ed566e3467fcc73a91407e75503809ffc44eb167 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -200,6 +200,10 @@ work on other platforms. Please report any problems and suggested fixes to
   one of either of those).  This resolves a bug where dual stack clients
   would not be able to regain their names after either expiration event.
 
+- Versions 3.0.x syntax with multiple name->code option definitions is now
+  supported.  Note that, similarly to 3.0.x, for by-code lookups only the
+  last option definition is used.
+
                        Changes since 4.1.0a1
 
 - Corrected list of failover state values in dhcpd man page.
index 2cab5f93d0ebc2c6908e28ec5a85b1144213333b..0e951bcc7a2cf8a74794c8f1f9de7bd25059b923 100644 (file)
@@ -502,6 +502,7 @@ void parse_client_statement (cfile, ip, config)
                        return;
                }
 
+               known = 0;
                status = parse_option_name(cfile, 1, &known, &option);
                if (status != ISC_R_SUCCESS || option == NULL)
                        return;
@@ -521,6 +522,18 @@ void parse_client_statement (cfile, ip, config)
                        option_dereference(&option, MDL);
                        return;
                }
+
+               /*
+                * If the option was known, remove it from the code and name
+                * hash tables before redefining it.
+                */
+               if (known) {
+                       option_name_hash_delete(option->universe->name_hash,
+                                               option->name, 0, MDL);
+                       option_code_hash_delete(option->universe->code_hash,
+                                               &option->code, 0, MDL);
+               }
+
                parse_option_code_definition(cfile, option);
                option_dereference(&option, MDL);
                return;
index feaec7df2cdde679af0c684a999cf2bef4571503..55f5cffb5203f53d74172dd1ab375e48885e2ba9 100644 (file)
@@ -1757,9 +1757,18 @@ int parse_option_code_definition (cfile, option)
        oldopt = NULL;
        option_code_hash_lookup(&oldopt, option->universe->code_hash,
                                &option->code, 0, MDL);
-       if (oldopt) {
+       if (oldopt != NULL) {
+               /*
+                * XXX: This illegalizes a configuration syntax that was
+                * valid in 3.0.x, where multiple name->code mappings are
+                * given, but only one code->name mapping survives.  It is
+                * unclear what can or should be done at this point, but it
+                * seems best to retain 3.0.x behaviour for upgrades to go
+                * smoothly.
+                *
                option_name_hash_delete(option->universe->name_hash,
                                        oldopt->name, 0, MDL);
+                */
                option_code_hash_delete(option->universe->code_hash,
                                        &oldopt->code, 0, MDL);
 
index 2ccd897218f311e79559bfe77b56b368b86f21c8..63280ac239402f0a1bb8474cdc96e4a3018e3fe0 100644 (file)
@@ -724,6 +724,20 @@ int parse_statement (cfile, group, type, host_decl, declaration)
                                        break;
                                }
                                next_token (&val, (unsigned *)0, cfile);
+
+                               /*
+                                * If the option was known, remove it from the
+                                * code and name hashes before redefining it.
+                                */
+                               if (known) {
+                                       option_name_hash_delete(
+                                               option->universe->name_hash,
+                                                       option->name, 0, MDL);
+                                       option_code_hash_delete(
+                                               option->universe->code_hash,
+                                                       &option->code, 0, MDL);
+                               }
+
                                parse_option_code_definition(cfile, option);
                                option_dereference(&option, MDL);
                                return declaration;