dhclient - Add ignore keyword to conf file.
authorAntonio Huete Jimenez <tuxillo@quantumachine.net>
Fri, 1 Aug 2014 18:09:13 +0000 (20:09 +0200)
committerAntonio Huete Jimenez <tuxillo@quantumachine.net>
Sat, 9 Aug 2014 16:29:08 +0000 (18:29 +0200)
- Allows to ignore unwanted info from the server without
  necessarily speciyfing a supersede value.

Taken-from: OpenBSD

sbin/dhclient/clparse.c
sbin/dhclient/conflex.c
sbin/dhclient/dhclient.c
sbin/dhclient/dhclient.conf.5
sbin/dhclient/dhcpd.h
sbin/dhclient/dhctoken.h

index 5ebcd9d..229fb4a 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: src/sbin/dhclient/clparse.c,v 1.38 2011/12/10 17:15:27 krw Exp $      */
+/*     $OpenBSD: src/sbin/dhclient/clparse.c,v 1.39 2012/08/22 00:14:42 tedu Exp $     */
 
 /* Parser for dhclient config and lease files... */
 
@@ -170,6 +170,11 @@ parse_client_statement(FILE *cfile)
                if (code != -1)
                        config->default_actions[code] = ACTION_SUPERSEDE;
                return;
+       case TOK_IGNORE:
+               code = parse_option_decl(cfile, &config->defaults[0]);
+               if (code != -1)
+                       config->default_actions[code] = ACTION_IGNORE;
+               return;
        case TOK_APPEND:
                code = parse_option_decl(cfile, &config->defaults[0]);
                if (code != -1)
index fc988e3..6505091 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: src/sbin/dhclient/conflex.c,v 1.14 2011/12/10 17:36:40 krw Exp $      */
+/*     $OpenBSD: src/sbin/dhclient/conflex.c,v 1.15 2012/08/22 00:14:42 tedu Exp $     */
 
 /* Lexical scanner for dhclient config file... */
 
@@ -340,6 +340,7 @@ static const struct keywords {
        { "filename",                           TOK_FILENAME },
        { "fixed-address",                      TOK_FIXED_ADDR },
        { "hardware",                           TOK_HARDWARE },
+       { "ignore",                             TOK_IGNORE },
        { "initial-interval",                   TOK_INITIAL_INTERVAL },
        { "interface",                          TOK_INTERFACE },
        { "lease",                              TOK_LEASE },
index 8748ef3..d362807 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: src/sbin/dhclient/dhclient.c,v 1.150 2012/08/21 00:29:32 krw Exp $    */
+/*     $OpenBSD: src/sbin/dhclient/dhclient.c,v 1.151 2012/08/22 00:14:42 tedu Exp $   */
 
 /*
  * Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -1512,6 +1512,9 @@ priv_script_write_params(char *prefix, struct client_lease *lease)
                if (config->defaults[i].len) {
                        if (lease->options[i].len) {
                                switch (config->default_actions[i]) {
+                               case ACTION_IGNORE:
+                                       /* handled below */
+                                       break;
                                case ACTION_DEFAULT:
                                        dp = lease->options[i].data;
                                        len = lease->options[i].len;
@@ -1567,6 +1570,9 @@ supersede:
                } else {
                        len = 0;
                }
+               if (len && config->default_actions[i] == ACTION_IGNORE) {
+                       len = 0;
+               }
                if (len) {
                        char name[256];
 
index aa12e68..07ed44c 100644 (file)
@@ -1,4 +1,4 @@
-.\" $OpenBSD: src/sbin/dhclient/dhclient.conf.5,v 1.21 2011/04/09 19:53:00 krw Exp $
+.\"    $OpenBSD: src/sbin/dhclient/dhclient.conf.5,v 1.22 2012/08/22 00:14:42 tedu Exp $
 .\"
 .\" Copyright (c) 1997 The Internet Software Consortium.
 .\" All rights reserved.
@@ -36,7 +36,7 @@
 .\" see ``http://www.isc.org/isc''.  To learn more about Vixie
 .\" Enterprises, see ``http://www.vix.com''.
 .\"
-.Dd July 23, 2013
+.Dd August 1, 2014
 .Dt DHCLIENT.CONF 5
 .Os
 .Sh NAME
@@ -238,6 +238,14 @@ Use
 for the given
 .Ar option ,
 regardless of the value supplied by the server.
+.It Xo
+.Ic ignore No { Op Ar option declaration
+.Oo , Ar ... option declaration Oc }
+.Xc
+If for some set of options the client should always ignore the
+value supplied by the server, these values can be defined in the
+.Ic ignore
+statement.
 .It Ic prepend Ar option option-value ;
 Use
 .Ar option-value
index 0471002..c95793f 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: src/sbin/dhclient/dhcpd.h,v 1.77 2012/08/18 00:23:30 krw Exp $        */
+/*     $OpenBSD: src/sbin/dhclient/dhcpd.h,v 1.78 2012/08/22 00:14:42 tedu Exp $       */
 
 /*
  * Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -129,6 +129,7 @@ struct client_config {
        struct option_data      defaults[256];
        enum {
                ACTION_DEFAULT,
+               ACTION_IGNORE,
                ACTION_SUPERSEDE,
                ACTION_PREPEND,
                ACTION_APPEND
index 83db598..51772b0 100644 (file)
@@ -1,5 +1,4 @@
-/*     $OpenBSD: dhctoken.h,v 1.5 2006/05/15 08:10:57 fkr Exp $        */
-/*     $DragonFly: src/sbin/dhclient/dhctoken.h,v 1.1 2008/08/30 16:07:58 hasso Exp $  */
+/*     $OpenBSD: src/sbin/dhclient/dhctoken.h,v 1.6 2012/08/22 00:14:42 tedu Exp $     */
 
 /* Tokens for config file lexer and parser. */
 
@@ -80,6 +79,7 @@
 #define TOK_REJECT             292
 #define TOK_FDDI               293
 #define TOK_LINK_TIMEOUT       294
+#define TOK_IGNORE             295
 
 #define is_identifier(x)       ((x) >= TOK_FIRST_TOKEN &&      \
                                 (x) != TOK_STRING &&   \