summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2014-01-21 05:17:46 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2014-01-21 05:17:46 +0000
commitc9f724356d8d08d2d00de2209642da64b6952de1 (patch)
treee0f4916e90e8686f0e4c2a0bc6246babb55b1eb1
parentdf0e2ce6b7f70d42f65df649d3cc09e90719bf18 (diff)
Allow dhclient.conf to specify 'fixed-address', 'next-server',
'filename' and 'server-name'. dhclient.conf can now override anything in an offer or saved lease when creating the effective lease.
-rw-r--r--sbin/dhclient/clparse.c21
-rw-r--r--sbin/dhclient/dhclient.c17
-rw-r--r--sbin/dhclient/dhcpd.h6
3 files changed, 41 insertions, 3 deletions
diff --git a/sbin/dhclient/clparse.c b/sbin/dhclient/clparse.c
index 3869d3820ac..bed5ddc4d99 100644
--- a/sbin/dhclient/clparse.c
+++ b/sbin/dhclient/clparse.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: clparse.c,v 1.81 2014/01/21 03:07:50 krw Exp $ */
+/* $OpenBSD: clparse.c,v 1.82 2014/01/21 05:17:45 krw Exp $ */
/* Parser for dhclient config and lease files. */
@@ -161,6 +161,7 @@ void
parse_client_statement(FILE *cfile)
{
u_int8_t optlist[256];
+ char *string;
int code, count, token;
token = next_token(NULL, cfile);
@@ -251,6 +252,24 @@ parse_client_statement(FILE *cfile)
case TOK_REJECT:
parse_reject_statement(cfile);
break;
+ case TOK_FILENAME:
+ string = parse_string(cfile);
+ if (config->filename)
+ free(config->filename);
+ config->filename = string;
+ break;
+ case TOK_SERVER_NAME:
+ string = parse_string(cfile);
+ if (config->server_name)
+ free(config->server_name);
+ config->server_name = string;
+ break;
+ case TOK_FIXED_ADDR:
+ parse_ip_addr(cfile, &config->address);
+ break;
+ case TOK_NEXT_SERVER:
+ parse_ip_addr(cfile, &config->next_server);
+ break;
default:
parse_warn("expecting a statement.");
if (token != ';')
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c
index 6e5cb1db3d6..b725fba9880 100644
--- a/sbin/dhclient/dhclient.c
+++ b/sbin/dhclient/dhclient.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhclient.c,v 1.286 2014/01/21 03:07:50 krw Exp $ */
+/* $OpenBSD: dhclient.c,v 1.287 2014/01/21 05:17:45 krw Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -2178,6 +2178,21 @@ apply_defaults(struct client_lease *lease)
if (newlease == NULL)
error("Unable to clone lease");
+ if (config->filename) {
+ if (lease->filename)
+ free(lease->filename);
+ lease->filename = strdup(config->filename);
+ }
+ if (config->server_name) {
+ if (lease->server_name)
+ free(lease->server_name);
+ lease->server_name = strdup(config->server_name);
+ }
+ if (config->address.s_addr != INADDR_ANY)
+ lease->address.s_addr = config->address.s_addr;
+ if (config->next_server.s_addr != INADDR_ANY)
+ lease->next_server.s_addr = config->next_server.s_addr;
+
for (i = 0; i < 256; i++) {
for (j = 0; j < config->ignored_option_count; j++) {
if (config->ignored_options[j] == i) {
diff --git a/sbin/dhclient/dhcpd.h b/sbin/dhclient/dhcpd.h
index 51dd254a024..08ef9b279da 100644
--- a/sbin/dhclient/dhcpd.h
+++ b/sbin/dhclient/dhcpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: dhcpd.h,v 1.134 2014/01/21 03:07:50 krw Exp $ */
+/* $OpenBSD: dhcpd.h,v 1.135 2014/01/21 05:17:45 krw Exp $ */
/*
* Copyright (c) 2004 Henning Brauer <henning@openbsd.org>
@@ -126,6 +126,8 @@ struct client_config {
ACTION_APPEND
} default_actions[256];
+ struct in_addr address;
+ struct in_addr next_server;
struct option_data send_options[256];
u_int8_t required_options[256];
u_int8_t requested_options[256];
@@ -144,6 +146,8 @@ struct client_config {
bootp_policy;
TAILQ_HEAD(, reject_elem) reject_list;
char *resolv_tail;
+ char *filename;
+ char *server_name;
};
struct client_state {