server-identifier option to use for the NAK.
[ISC-Bugs #25689]
+- The client now passes information about the options it requested
+ from the server to the script code via environment variables.
+ These variables are of the form requested_<option_name>=1 with
+ the option name being the same as used in the new_* and old_*
+ variables.
+
Changes since 4.2.3
! Add a check for a null pointer before calling the regexec function.
static void script_write_params6(struct client_state *client,
const char *prefix,
struct option_state *options);
+static void script_write_requested6(struct client_state *client);
static isc_boolean_t active_prefix(struct client_state *client);
static int check_timing6(struct client_state *client, u_int8_t msg_type,
dhc6_marshall_values("old_", client, old,
oldia, oldaddr);
dhc6_marshall_values("new_", client, lease, ia, addr);
+ script_write_requested6(client);
script_go(client);
}
dhc6_marshall_values("new_", client, lease, ia,
NULL);
+ script_write_requested6(client);
script_go(client);
}
old->bindings->addrs : NULL);
dhc6_marshall_values("new_", client, lease, NULL, NULL);
+ script_write_requested6(client);
script_go(client);
}
script_init(client, "DEPREF6", NULL);
dhc6_marshall_values("cur_", client, lease,
ia, addr);
+ script_write_requested6(client);
script_go(client);
addr->flags |= DHC6_ADDR_DEPREFFED;
script_init(client, "EXPIRE6", NULL);
dhc6_marshall_values("old_", client, lease,
ia, addr);
+ script_write_requested6(client);
script_go(client);
addr->flags |= DHC6_ADDR_EXPIRED;
if (client->active_lease != NULL)
script_write_params6(client, "old_",
client->active_lease->options);
+ script_write_requested6(client);
script_go(client);
return;
}
script_init(client, reason, NULL);
dhc6_marshall_values("old_", client,
client->active_lease, ia, addr);
+ script_write_requested6(client);
script_go(client);
#if defined (NSUPDATE)
script_write_params6(client, "old_",
client->old_lease->options);
script_write_params6(client, "new_", client->active_lease->options);
+ script_write_requested6(client);
script_go(client);
go_daemon();
}
}
+/*
+ * A clone of the DHCPv4 routine.
+ * Write out the environment variables for the objects that the
+ * client requested. If the object was requested the variable will be:
+ * requested_<option_name>=1
+ * If it wasn't requested there won't be a variable.
+ */
+static void script_write_requested6(client)
+ struct client_state *client;
+{
+ int i;
+ struct option **req;
+ char name[256];
+ req = client->config->requested_options;
+
+ if (req == NULL)
+ return;
+
+ for (i = 0 ; req[i] != NULL ; i++) {
+ if ((req[i]->universe == &dhcpv6_universe) &&
+ dhcp_option_ev_name (name, sizeof(name), req[i])) {
+ client_envadd(client, "requested_", name, "%d", 1);
+ }
+ }
+}
+
/*
* Check if there is something not fully defined in the active lease.
*/
.\" dhclient-script.8
.\"
+.\" Copyright (c) 2012 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 2004-2005 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
described in \fBdhcp-options\fR, except that dashes (\'-\') are replaced
by underscores (\'_\') in order to make valid shell variables, and the
variable names start with new_. So for example, the new subnet mask
-would be passed in $new_subnet_mask.
+would be passed in $new_subnet_mask. The options that the client
+explicitly requested via a PRL or ORO option are passed with the same
+option name as above but prepended with requested_ and with a value of 1,
+or example requested_subnet_mask=1. No such variable is defined for
+options not requested by the client or options that don't require a
+request option, such as the ip address (*_ip_address) or expiration
+time (*_expiry).
.PP
Before actually configuring the address, dhclient-script should
somehow ARP for it and exit with a nonzero status if it receives a
in this case.
.SH RENEW
When a binding has been renewed, the script is called as in BOUND,
-except that in addition to all the variables starting with $new_,
-there is another set of variables starting with $old_. Persistent
-settings that may have changed need to be deleted - for example, if a
-local route to the bound address is being configured, the old local
-route should be deleted. If the default route has changed, the old default
-route should be deleted. If the static routes have changed, the old
-ones should be deleted. Otherwise, processing can be done as with
+except that in addition to all the variables starting with $new_, and
+$requested_ there is another set of variables starting with $old_.
+Persistent settings that may have changed need to be deleted - for
+example, if a local route to the bound address is being configured,
+the old local route should be deleted. If the default route has changed,
+the old default route should be deleted. If the static routes have changed,
+the old ones should be deleted. Otherwise, processing can be done as with
BOUND.
.SH REBIND
The DHCP client has rebound to a new DHCP server. This can be handled
if (client -> active && client -> state != S_REBOOTING)
script_write_params (client, "old_", client -> active);
script_write_params (client, "new_", client -> new);
+ script_write_requested(client);
if (client -> alias)
script_write_params (client, "alias_", client -> alias);
if (client->active) {
script_init(client, "STOP", client->active->medium);
script_write_params(client, "old_", client->active);
+ script_write_requested(client);
if (client->alias)
script_write_params(client, "alias_", client->alias);
script_go(client);
*/
script_init(client, "EXPIRE", NULL);
script_write_params(client, "old_", client->active);
+ script_write_requested(client);
if (client->alias)
script_write_params(client, "alias_", client->alias);
script_go(client);
script_init (client, "TIMEOUT",
client -> active -> medium);
script_write_params (client, "new_", client -> active);
+ script_write_requested(client);
if (client -> alias)
script_write_params (client, "alias_",
client -> alias);
/* Run the client script with the new parameters. */
script_init (client, "EXPIRE", (struct string_list *)0);
script_write_params (client, "old_", client -> active);
+ script_write_requested(client);
if (client -> alias)
script_write_params (client, "alias_",
client -> alias);
client_envadd (client, prefix, "expiry", "%d", (int)(lease -> expiry));
}
+/*
+ * Write out the environment variables for the objects that the
+ * client requested. If the object was requested the variable will be:
+ * requested_<option_name>=1
+ * If it wasn't requested there won't be a variable.
+ */
+void script_write_requested(client)
+ struct client_state *client;
+{
+ int i;
+ struct option **req;
+ char name[256];
+ req = client->config->requested_options;
+
+ if (req == NULL)
+ return;
+
+ for (i = 0 ; req[i] != NULL ; i++) {
+ if ((req[i]->universe == &dhcp_universe) &&
+ dhcp_option_ev_name(name, sizeof(name), req[i])) {
+ client_envadd(client, "requested_", name, "%d", 1);
+ }
+ }
+}
+
int script_go (client)
struct client_state *client;
{
script_write_params (client, "alias_",
client -> alias);
script_write_params (client, "old_", client -> active);
+ script_write_requested(client);
script_go (client);
}
struct binding_scope **, struct universe *, void *);
void script_write_params (struct client_state *, const char *,
struct client_lease *);
+void script_write_requested (struct client_state *);
int script_go (struct client_state *);
void client_envadd (struct client_state *,
const char *, const char *, const char *, ...)