mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-01 06:45:27 +00:00
[master] Some small client changes
18933 - add an extra server by name call 26735 - when requested via a command line option have client exit afer 1 failure per the docs 33098 - expose next-server option to dhclient script
This commit is contained in:
15
RELNOTES
15
RELNOTES
@@ -108,6 +108,21 @@ by Eric Young (eay@cryptsoft.com).
|
||||
[ISC-Bugs #16970]
|
||||
[ISC-Bugs #17258]
|
||||
|
||||
- Some minor cleanups in the client code
|
||||
In addition to checking for dhcpc check for bootpc in the services list
|
||||
[ISC-Bugs #18933]
|
||||
Correct the client code to only try to get a lease once when the
|
||||
given the "-1" argument.
|
||||
Thanks to Jiri Popelka at Red Hat for the bug and fix.
|
||||
[ISC-Bugs #26735]
|
||||
When asked for the version don't send the output to syslog.
|
||||
[ISC-Bugs #29772]
|
||||
Add the next server information to the environment variables for
|
||||
use by the client script. In order to avoid changing the client
|
||||
lease file the next server information isn't written to it.
|
||||
Thanks to Tomas Hozza at Red Hat for the suggestion and a prototype fix.
|
||||
[ISC-Bugs #33098]
|
||||
|
||||
Changes since 4.3.0rc1
|
||||
|
||||
- None
|
||||
|
@@ -311,7 +311,13 @@ main(int argc, char **argv) {
|
||||
} else if (!strcmp(argv[i], "-v")) {
|
||||
quiet = 0;
|
||||
} else if (!strcmp(argv[i], "--version")) {
|
||||
log_info("isc-dhclient-%s", PACKAGE_VERSION);
|
||||
const char vstring[] = "isc-dhclient-";
|
||||
IGNORE_RET(write(STDERR_FILENO, vstring,
|
||||
strlen(vstring)));
|
||||
IGNORE_RET(write(STDERR_FILENO,
|
||||
PACKAGE_VERSION,
|
||||
strlen(PACKAGE_VERSION)));
|
||||
IGNORE_RET(write(STDERR_FILENO, "\n", 1));
|
||||
exit(0);
|
||||
} else if (argv[i][0] == '-') {
|
||||
usage();
|
||||
@@ -1214,12 +1220,10 @@ void bind_lease (client)
|
||||
client->new->medium = client->medium;
|
||||
|
||||
/* Run the client script with the new parameters. */
|
||||
script_init (client, (client -> state == S_REQUESTING
|
||||
? "BOUND"
|
||||
: (client -> state == S_RENEWING
|
||||
? "RENEW"
|
||||
: (client -> state == S_REBOOTING
|
||||
? "REBOOT" : "REBIND"))),
|
||||
script_init(client, (client->state == S_REQUESTING ? "BOUND" :
|
||||
(client->state == S_RENEWING ? "RENEW" :
|
||||
(client->state == S_REBOOTING ? "REBOOT" :
|
||||
"REBIND"))),
|
||||
client->new->medium);
|
||||
if (client->active && client->state != S_REBOOTING)
|
||||
script_write_params(client, "old_", client->active);
|
||||
@@ -1235,10 +1239,17 @@ void bind_lease (client)
|
||||
make_decline(client, client->new);
|
||||
send_decline(client);
|
||||
destroy_client_lease(client->new);
|
||||
client -> new = (struct client_lease *)0;
|
||||
client->new = NULL;
|
||||
if (onetry) {
|
||||
if (!quiet)
|
||||
log_info("Unable to obtain a lease on first "
|
||||
"try (declined). Exiting.");
|
||||
exit(2);
|
||||
} else {
|
||||
state_init(client);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Write out the new lease if it has been long enough. */
|
||||
if (!client->last_write ||
|
||||
@@ -1249,7 +1260,7 @@ void bind_lease (client)
|
||||
if (client->active)
|
||||
destroy_client_lease(client->active);
|
||||
client->active = client->new;
|
||||
client -> new = (struct client_lease *)0;
|
||||
client->new = NULL;
|
||||
|
||||
/* Set up a timeout to start the renewal process. */
|
||||
tv.tv_sec = client->active->renewal;
|
||||
@@ -1648,10 +1659,10 @@ struct client_lease *packet_to_lease (packet, client)
|
||||
|
||||
if (!lease) {
|
||||
log_error("packet_to_lease: no memory to record lease.\n");
|
||||
return (struct client_lease *)0;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
memset (lease, 0, sizeof *lease);
|
||||
memset(lease, 0, sizeof(*lease));
|
||||
|
||||
/* Copy the lease options. */
|
||||
option_state_reference(&lease->options, packet->options, MDL);
|
||||
@@ -1660,7 +1671,11 @@ struct client_lease *packet_to_lease (packet, client)
|
||||
memcpy(lease->address.iabuf, &packet->raw->yiaddr,
|
||||
lease->address.len);
|
||||
|
||||
memset (&data, 0, sizeof data);
|
||||
lease->next_srv_addr.len = sizeof(packet->raw->siaddr);
|
||||
memcpy(lease->next_srv_addr.iabuf, &packet->raw->siaddr,
|
||||
lease->next_srv_addr.len);
|
||||
|
||||
memset(&data, 0, sizeof(data));
|
||||
|
||||
if (client -> config -> vendor_space_name) {
|
||||
i = DHO_VENDOR_ENCAPSULATED_OPTIONS;
|
||||
@@ -3312,6 +3327,13 @@ void script_write_params (client, prefix, lease)
|
||||
client_envadd (client,
|
||||
prefix, "ip_address", "%s", piaddr (lease -> address));
|
||||
|
||||
/* If we've set the next server address in the lease structure
|
||||
put it into an environment variable for the script */
|
||||
if (lease->next_srv_addr.len != 0) {
|
||||
client_envadd(client, prefix, "next_server", "%s",
|
||||
piaddr(lease->next_srv_addr));
|
||||
}
|
||||
|
||||
/* For the benefit of Linux (and operating systems which may
|
||||
have similar needs), compute the network address based on
|
||||
the supplied ip address and netmask, if provided. Also
|
||||
@@ -4357,7 +4379,9 @@ dhcpv4_client_assignments(void)
|
||||
local_port = htons(67);
|
||||
} else {
|
||||
ent = getservbyname("dhcpc", "udp");
|
||||
if (!ent)
|
||||
if (ent == NULL)
|
||||
ent = getservbyname("bootpc", "udp");
|
||||
if (ent == NULL)
|
||||
local_port = htons(68);
|
||||
else
|
||||
local_port = ent->s_port;
|
||||
|
@@ -1026,6 +1026,7 @@ struct client_lease {
|
||||
unsigned int is_bootp: 1; /* If set, lease was acquired with BOOTP. */
|
||||
|
||||
struct option_state *options; /* Options supplied with lease. */
|
||||
struct iaddr next_srv_addr; /* Address of the next server to use */
|
||||
};
|
||||
|
||||
/* DHCPv6 lease structures */
|
||||
|
Reference in New Issue
Block a user