58 lines
1.3 KiB
Plaintext
58 lines
1.3 KiB
Plaintext
--- dhcp-3.0b2pl18/client/dhclient.c.orig Thu Feb 15 23:17:05 2001
|
|
+++ dhcp-3.0b2pl18/client/dhclient.c Wed Mar 28 17:07:31 2001
|
|
@@ -46,6 +46,7 @@
|
|
|
|
#include "dhcpd.h"
|
|
#include "version.h"
|
|
+#include <signal.h>
|
|
|
|
TIME cur_time;
|
|
TIME default_lease_time = 43200; /* 12 hours... */
|
|
@@ -84,6 +85,7 @@
|
|
static void usage PROTO ((void));
|
|
|
|
void do_release(struct client_state *);
|
|
+void signalSetup();
|
|
|
|
int main (argc, argv, envp)
|
|
int argc;
|
|
@@ -247,6 +249,7 @@
|
|
} else
|
|
log_perror = 0;
|
|
|
|
+ signalSetup ();
|
|
/* If we're given a relay agent address to insert, for testing
|
|
purposes, figure out what it is. */
|
|
if (relay) {
|
|
@@ -2731,3 +2734,30 @@
|
|
{
|
|
return length;
|
|
}
|
|
+
|
|
+/* install a signal handler to restore resolv.conf when dhclient is being sent TERM */
|
|
+
|
|
+void sigHandler (int sig)
|
|
+{
|
|
+ if (sig == SIGTERM) {
|
|
+ log_info ("caught deadly SIGTERM");
|
|
+ if ( rename("/etc/resolv.conf.saved.by.dhclient", "/etc/resolv.conf") == 0 )
|
|
+ log_info ("restored resolv.conf ");
|
|
+ else
|
|
+ log_error ("could not restore resolv.conf: %m");
|
|
+ }
|
|
+ exit (sig);
|
|
+}
|
|
+
|
|
+void signalSetup()
|
|
+{
|
|
+ struct sigaction newaction;
|
|
+
|
|
+ newaction.sa_handler = sigHandler;
|
|
+ sigemptyset(&newaction.sa_mask);
|
|
+ newaction.sa_flags = 0;
|
|
+ sigaction (SIGTERM, &newaction, NULL);
|
|
+ /* log_info ("installed signal handler:"); */
|
|
+ /* log_info ("resolv.conf will be restored at termination"); */
|
|
+}
|
|
+
|