]> git.pld-linux.org Git - packages/dhcp.git/blob - dhcp-detect-time-changes.patch
updated -client runtime deps
[packages/dhcp.git] / dhcp-detect-time-changes.patch
1 From a2fb8759ab48c88e3f8df94ae6e156c357d932a2 Mon Sep 17 00:00:00 2001
2 From: Pavel Zhukov <pzhukov@redhat.com>
3 Date: Tue, 22 Oct 2019 16:23:01 +0200
4 Subject: [PATCH 24/28] Detect system time changes
5
6 ---
7  client/dhclient.c |  6 ++++++
8  common/dispatch.c | 11 ++++++++++-
9  includes/dhcpd.h  |  3 ++-
10  server/dhcpd.c    |  6 ++++++
11  4 files changed, 24 insertions(+), 2 deletions(-)
12
13 diff --git a/client/dhclient.c b/client/dhclient.c
14 index 60836b4..fd18813 100644
15 --- a/client/dhclient.c
16 +++ b/client/dhclient.c
17 @@ -5665,6 +5665,12 @@ isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
18                   case server_awaken:
19                     state_reboot (client);
20                     break;
21 +
22 +                  case server_time_changed:
23 +                    if (client->active){
24 +                      state_reboot (client);
25 +                    }
26 +                    break;
27                 }
28             }
29         }
30 diff --git a/common/dispatch.c b/common/dispatch.c
31 index 9741ff5..11c1787 100644
32 --- a/common/dispatch.c
33 +++ b/common/dispatch.c
34 @@ -118,7 +118,6 @@ dispatch(void)
35                  * signal. It will return ISC_R_RELOAD in that
36                  * case. That is a normal behavior.
37                  */
38 -
39                 if (status == ISC_R_RELOAD) {
40                         /*
41                          * dhcp_set_control_state() will do the job.
42 @@ -129,6 +128,16 @@ dispatch(void)
43                         if (status == ISC_R_SUCCESS)
44                                 status = ISC_R_RELOAD;
45                 }
46 +
47 +                
48 +                if (status == ISC_R_TIMESHIFTED){
49 +                  status = dhcp_set_control_state(server_time_changed,
50 +                                                  server_time_changed);
51 +                  status = ISC_R_RELOAD;
52 +                  log_info ("System time has been changed. Unable to use existing leases. Restarting");
53 +                  // do nothing, restart context
54 +                };
55 +
56         } while (status == ISC_R_RELOAD);
57  
58         log_fatal ("Dispatch routine failed: %s -- exiting",
59 diff --git a/includes/dhcpd.h b/includes/dhcpd.h
60 index fabad01..9663508 100644
61 --- a/includes/dhcpd.h
62 +++ b/includes/dhcpd.h
63 @@ -524,7 +524,8 @@ typedef enum {
64         server_running = 1,
65         server_shutdown = 2,
66         server_hibernate = 3,
67 -       server_awaken = 4
68 +       server_awaken = 4,
69 +        server_time_changed = 5
70  } control_object_state_t;
71  
72  typedef struct {
73 diff --git a/server/dhcpd.c b/server/dhcpd.c
74 index 845d0cc..3b3bd3b 100644
75 --- a/server/dhcpd.c
76 +++ b/server/dhcpd.c
77 @@ -1767,6 +1767,12 @@ isc_result_t dhcp_set_control_state (control_object_state_t oldstate,
78  {
79         struct timeval tv;
80  
81 +        if (newstate == server_time_changed){
82 +          log_error ("System time has been changed. Leases information unreliable!");
83 +          return ISC_R_SUCCESS;
84 +        }
85 +
86 +                
87         if (newstate != server_shutdown)
88                 return DHCP_R_INVALIDARG;
89         /* Re-entry. */
90 -- 
91 2.35.1
92
This page took 0.041835 seconds and 3 git commands to generate.