Blame SOURCES/dhcp-system_time_changed.patch

9295a4
diff --git a/client/dhclient.c b/client/dhclient.c
9295a4
index 1992467..364fd08 100644
9295a4
--- a/client/dhclient.c
9295a4
+++ b/client/dhclient.c
9295a4
@@ -4463,6 +4463,10 @@ isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
9295a4
 		  case server_awaken:
9295a4
 		    state_reboot (client);
9295a4
 		    break;
9295a4
+                  case server_time_changed:
9295a4
+                    if (client->active)
9295a4
+                      state_reboot (client);
9295a4
+                    break;
9295a4
 		}
9295a4
 	    }
9295a4
 	}
9295a4
diff --git a/common/dispatch.c b/common/dispatch.c
9295a4
index af8a5b5..c1d558f 100644
9295a4
--- a/common/dispatch.c
9295a4
+++ b/common/dispatch.c
9295a4
@@ -110,10 +110,20 @@ dispatch(void)
9295a4
 {
9295a4
 	isc_result_t status;
9295a4
 
9295a4
-	status = isc_app_ctxrun(dhcp_gbl_ctx.actx);
9295a4
-
9295a4
-	log_fatal ("Dispatch routine failed: %s -- exiting",
9295a4
-		   isc_result_totext (status));
9295a4
+        do{
9295a4
+          status = isc_app_ctxrun(dhcp_gbl_ctx.actx);
9295a4
+
9295a4
+          if (status == ISC_R_TIMESHIFTED){
9295a4
+            status = dhcp_set_control_state(server_time_changed,
9295a4
+                                            server_time_changed);
9295a4
+            status = ISC_R_RELOAD;
9295a4
+            log_info ("System time has been changed. Unable to use existing leases. Restarting");
9295a4
+            // do nothing, restart context
9295a4
+          };
9295a4
+        } while (status == ISC_R_RELOAD);
9295a4
+        
9295a4
+        log_fatal ("Dispatch routine failed: %s -- exiting",
9295a4
+                   isc_result_totext (status));
9295a4
 }
9295a4
 
9295a4
 void
9295a4
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
9295a4
index deea2a7..d60a03c 100644
9295a4
--- a/includes/dhcpd.h
9295a4
+++ b/includes/dhcpd.h
9295a4
@@ -479,7 +479,8 @@ typedef enum {
9295a4
 	server_running = 1,
9295a4
 	server_shutdown = 2,
9295a4
 	server_hibernate = 3,
9295a4
-	server_awaken = 4
9295a4
+	server_awaken = 4,
9295a4
+        server_time_changed = 5
9295a4
 } control_object_state_t;
9295a4
 
9295a4
 typedef struct {
9295a4
diff --git a/server/dhcpd.c b/server/dhcpd.c
9295a4
index 9617d75..9add7e4 100644
9295a4
--- a/server/dhcpd.c
9295a4
+++ b/server/dhcpd.c
9295a4
@@ -1392,6 +1392,10 @@ static isc_result_t dhcp_io_shutdown_countdown (void *vlp)
9295a4
 isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
9295a4
 				     control_object_state_t newstate)
9295a4
 {
9295a4
+        if (newstate == server_time_changed){
9295a4
+          log_error ("System time has been changed. Leases information unreliable!");
9295a4
+          return ISC_R_SUCCESS;
9295a4
+        }
9295a4
 	if (newstate == server_shutdown) {
9295a4
 		shutdown_time = cur_time;
9295a4
 		shutdown_state = shutdown_listeners;