summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Markwalder <tmark@isc.org>2020-08-03 10:41:17 -0400
committerThomas Markwalder <tmark@isc.org>2022-01-12 08:29:51 -0500
commit33e517615f8467a005de2ca2633f52bad323ec2b (patch)
tree686a979f3fb2ad1927b696ad397561bf2fdd4a2e
parent79110e525e0584d195327d31f4ee67e6a5e2fe7a (diff)
downloadisc-dhcp-33e517615f8467a005de2ca2633f52bad323ec2b.tar.gz
modified: RELNOTES modified: client/dhclient.c
-rw-r--r--RELNOTES4
-rw-r--r--client/dhclient.c19
2 files changed, 18 insertions, 5 deletions
diff --git a/RELNOTES b/RELNOTES
index 7ed1f37d..bbf81570 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -115,6 +115,10 @@ and the client Linux script sample was updated.
- Minor corrections to allow compilation under gcc 10.
[Gitlab #117]
+- Corrected logic in dhclient that causes it to decline DHCPv4 leases if the
+ client script exits abnormally (i.e. crashes).
+ [Gitlab #123]
+
Changes since 4.4.2b1 (Bug Fixes)
- Added a clarification on DHCPINFORMs and server authority to
diff --git a/client/dhclient.c b/client/dhclient.c
index 0a4fa312..e445a52d 100644
--- a/client/dhclient.c
+++ b/client/dhclient.c
@@ -1635,9 +1635,12 @@ void bind_lease (client)
script_write_params(client, "alias_", client->alias);
/* If the BOUND/RENEW code detects another machine using the
- offered address, it exits nonzero. We need to send a
- DHCPDECLINE and toss the lease. */
- if (script_go(client)) {
+ offered address, then per our man page it should exit with
+ a non-zero status, to which we send a DHCPDECLINE and toss
+ the lease. A return value of less than zero indicates
+ the script crashed (e.g. segfault) which script_go will log
+ but we will ignore here. */
+ if (script_go(client) > 0) {
make_decline(client, client->new);
send_decline(client);
destroy_client_lease(client->new);
@@ -4557,8 +4560,14 @@ int script_go(struct client_state *client)
}
dfree (envp, MDL);
gettimeofday(&cur_tv, NULL);
- return (WIFEXITED (wstatus) ?
- WEXITSTATUS (wstatus) : -WTERMSIG (wstatus));
+
+ if (!WIFEXITED(wstatus)) {
+ int sigval = WTERMSIG(wstatus);
+ log_error ("script_go script: %s was terminated by signal %d", scriptName, sigval);
+ return (-sigval);
+ }
+
+ return (WEXITSTATUS(wstatus));
}
void client_envadd (struct client_state *client,