aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-installer/anaconda/files/0027-disable-ntp-support.patch
blob: 030e06b045b36923d98b76fa143d1b69a76d71a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
From 754f8b04817bf4c5b6cb8584c918b1b852717f9b Mon Sep 17 00:00:00 2001
From: Hongxu Jia <hongxu.jia@windriver.com>
Date: Tue, 24 Jul 2018 14:51:05 +0800
Subject: [PATCH 27/65] disable ntp support

The upstream RHEL7 use chrony.service to support ntp,
it did not exist in oe-core, so remove it.

Do not support NTP, here are the reasons:
- For systemd based, it already had NTP supported,
  another ntp will cause confliction.

- We also need to consider the situation of sysvinit
  based system, it requires a ntp package to be
  installed.

Upstream-Status: Inappropriate [oe specific]

Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 pyanaconda/kickstart.py                       | 56 +----------------
 pyanaconda/ui/gui/spokes/datetime_spoke.glade | 74 ----------------------
 pyanaconda/ui/gui/spokes/datetime_spoke.py    | 89 ---------------------------
 3 files changed, 1 insertion(+), 218 deletions(-)

diff --git a/pyanaconda/kickstart.py b/pyanaconda/kickstart.py
index e8c5734..d39d121 100644
--- a/pyanaconda/kickstart.py
+++ b/pyanaconda/kickstart.py
@@ -1892,37 +1892,7 @@ class Timezone(RemovedCommand):
         return timezone_proxy.GenerateKickstart()
 
     def setup(self, ksdata):
-        timezone_proxy = TIMEZONE.get_proxy()
-        services_proxy = SERVICES.get_proxy()
-
-        enabled_services = services_proxy.EnabledServices
-        disabled_services = services_proxy.DisabledServices
-
-        # do not install and use NTP package
-        if not timezone_proxy.NTPEnabled or NTP_PACKAGE in ksdata.packages.excludedList:
-            if util.service_running(NTP_SERVICE) and \
-                    can_touch_runtime_system("stop NTP service"):
-                ret = util.stop_service(NTP_SERVICE)
-                if ret != 0:
-                    timezone_log.error("Failed to stop NTP service")
-
-            if NTP_SERVICE not in disabled_services:
-                disabled_services.append(NTP_SERVICE)
-                services_proxy.SetDisabledServices(disabled_services)
-        # install and use NTP package
-        else:
-            if not util.service_running(NTP_SERVICE) and \
-                    can_touch_runtime_system("start NTP service"):
-                ret = util.start_service(NTP_SERVICE)
-                if ret != 0:
-                    timezone_log.error("Failed to start NTP service")
-
-            self.packages.append(NTP_PACKAGE)
-
-            if not NTP_SERVICE in enabled_services and \
-                    not NTP_SERVICE in disabled_services:
-                enabled_services.append(NTP_SERVICE)
-                services_proxy.SetEnabledServices(enabled_services)
+        pass
 
     def execute(self, *args):
         # get the DBus proxies
@@ -1939,30 +1909,6 @@ class Timezone(RemovedCommand):
 
         timezone.write_timezone_config(timezone_proxy, util.getSysroot())
 
-        # write out NTP configuration (if set) and --nontp is not used
-        kickstart_ntp_servers = timezone_proxy.NTPServers
-
-        if timezone_proxy.NTPEnabled and kickstart_ntp_servers:
-            chronyd_conf_path = os.path.normpath(util.getSysroot() + ntp.NTP_CONFIG_FILE)
-            pools, servers = ntp.internal_to_pools_and_servers(kickstart_ntp_servers)
-            if os.path.exists(chronyd_conf_path):
-                timezone_log.debug("Modifying installed chrony configuration")
-                try:
-                    ntp.save_servers_to_config(pools, servers, conf_file_path=chronyd_conf_path)
-                except ntp.NTPconfigError as ntperr:
-                    timezone_log.warning("Failed to save NTP configuration: %s", ntperr)
-            # use chrony conf file from installation environment when
-            # chrony is not installed (chrony conf file is missing)
-            else:
-                timezone_log.debug("Creating chrony configuration based on the "
-                                   "configuration from installation environment")
-                try:
-                    ntp.save_servers_to_config(pools, servers,
-                                               conf_file_path=ntp.NTP_CONFIG_FILE,
-                                               out_file_path=chronyd_conf_path)
-                except ntp.NTPconfigError as ntperr:
-                    timezone_log.warning("Failed to save NTP configuration without chrony package: %s", ntperr)
-
 class User(commands.user.F24_User):
     def execute(self, storage, ksdata, instClass, users):
 
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.glade b/pyanaconda/ui/gui/spokes/datetime_spoke.glade
index 37c7c6e..875cfea 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.glade
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.glade
@@ -460,80 +460,6 @@
                                 <property name="position">3</property>
                               </packing>
                             </child>
-                            <child>
-                              <object class="GtkAlignment" id="alignment4">
-                                <property name="visible">True</property>
-                                <property name="can_focus">False</property>
-                                <property name="xalign">1</property>
-                                <property name="xscale">0.20000000298023224</property>
-                                <property name="right_padding">24</property>
-                                <child>
-                                  <object class="GtkBox" id="box6">
-                                    <property name="visible">True</property>
-                                    <property name="can_focus">False</property>
-                                    <property name="halign">end</property>
-                                    <child>
-                                      <object class="GtkLabel" id="networkTimeLabel">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">False</property>
-                                        <property name="label" translatable="yes" context="GUI|Date and Time">_Network Time</property>
-                                        <property name="use_underline">True</property>
-                                        <property name="mnemonic_widget">networkTimeSwitch</property>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">True</property>
-                                        <property name="padding">3</property>
-                                        <property name="position">0</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkSwitch" id="networkTimeSwitch">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <signal name="notify::active" handler="on_ntp_switched" swapped="no"/>
-                                        <child internal-child="accessible">
-                                          <object class="AtkObject" id="networkTimeSwitch-atkobject">
-                                            <property name="AtkObject::accessible-name" translatable="yes">Use Network Time</property>
-                                          </object>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">True</property>
-                                        <property name="padding">1</property>
-                                        <property name="position">1</property>
-                                      </packing>
-                                    </child>
-                                    <child>
-                                      <object class="GtkButton" id="ntpConfigButton">
-                                        <property name="visible">True</property>
-                                        <property name="can_focus">True</property>
-                                        <property name="receives_default">True</property>
-                                        <property name="image">configImage</property>
-                                        <signal name="clicked" handler="on_ntp_config_clicked" swapped="no"/>
-                                        <child internal-child="accessible">
-                                          <object class="AtkObject" id="ntpConfigButton-atkobject">
-                                            <property name="AtkObject::accessible-name" translatable="yes">Configure NTP</property>
-                                          </object>
-                                        </child>
-                                      </object>
-                                      <packing>
-                                        <property name="expand">False</property>
-                                        <property name="fill">True</property>
-                                        <property name="padding">1</property>
-                                        <property name="position">2</property>
-                                      </packing>
-                                    </child>
-                                  </object>
-                                </child>
-                              </object>
-                              <packing>
-                                <property name="expand">True</property>
-                                <property name="fill">True</property>
-                                <property name="position">4</property>
-                              </packing>
-                            </child>
                           </object>
                         </child>
                       </object>
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py
index 73055d1..e8a47b7 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.py
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py
@@ -497,8 +497,6 @@ class DatetimeSpoke(FirstbootSpokeMixIn, NormalSpoke):
         self._year_format, suffix = formats[widgets.index(year_box)]
         year_label.set_text(suffix)
 
-        self._ntpSwitch = self.builder.get_object("networkTimeSwitch")
-
         self._regions_zones = get_all_regions_and_timezones()
 
         # Set the initial sensitivity of the AM/PM toggle based on the time-type selected
@@ -507,9 +505,6 @@ class DatetimeSpoke(FirstbootSpokeMixIn, NormalSpoke):
         if not flags.can_touch_runtime_system("modify system time and date"):
             self._set_date_time_setting_sensitive(False)
 
-        self._config_dialog = NTPconfigDialog(self.data, self._timezone_module)
-        self._config_dialog.initialize()
-
         threadMgr.add(AnacondaThread(name=constants.THREAD_DATE_TIME,
                                      target=self._initialize))
 
@@ -597,8 +592,6 @@ class DatetimeSpoke(FirstbootSpokeMixIn, NormalSpoke):
             # TODO: seen should be set from the module
             self._kickstarted = False
 
-        self._timezone_module.proxy.SetNTPEnabled(self._ntpSwitch.get_active())
-
     def execute(self):
         if self._update_datetime_timer is not None:
             self._update_datetime_timer.cancel()
@@ -635,20 +628,6 @@ class DatetimeSpoke(FirstbootSpokeMixIn, NormalSpoke):
 
         self._update_datetime()
 
-        has_active_network = nm.nm_is_connected()
-        if not has_active_network:
-            self._show_no_network_warning()
-        else:
-            self.clear_info()
-            gtk_call_once(self._config_dialog.refresh_servers_state)
-
-        if flags.can_touch_runtime_system("get NTP service state"):
-            ntp_working = has_active_network and util.service_running(NTP_SERVICE)
-        else:
-            ntp_working = self._timezone_module.proxy.NTPEnabled
-
-        self._ntpSwitch.set_active(ntp_working)
-
     @async_action_wait
     def _set_timezone(self, timezone):
         """
@@ -1100,71 +1079,3 @@ class DatetimeSpoke(FirstbootSpokeMixIn, NormalSpoke):
         footer_alignment = self.builder.get_object("footerAlignment")
         footer_alignment.set_sensitive(sensitive)
 
-    def _show_no_network_warning(self):
-        self.set_warning(_("You need to set up networking first if you "\
-                           "want to use NTP"))
-
-    def _show_no_ntp_server_warning(self):
-        self.set_warning(_("You have no working NTP server configured"))
-
-    def on_ntp_switched(self, switch, *args):
-        if switch.get_active():
-            #turned ON
-            if not flags.can_touch_runtime_system("start NTP service"):
-                #cannot touch runtime system, not much to do here
-                return
-
-            if not nm.nm_is_connected():
-                self._show_no_network_warning()
-                switch.set_active(False)
-                return
-            else:
-                self.clear_info()
-
-                working_server = self._config_dialog.working_server
-                if working_server is None:
-                    self._show_no_ntp_server_warning()
-                else:
-                    #we need a one-time sync here, because chronyd would not change
-                    #the time as drastically as we need
-                    ntp.one_time_sync_async(working_server)
-
-            ret = util.start_service(NTP_SERVICE)
-            self._set_date_time_setting_sensitive(False)
-
-            #if starting chronyd failed and chronyd is not running,
-            #set switch back to OFF
-            if (ret != 0) and not util.service_running(NTP_SERVICE):
-                switch.set_active(False)
-
-        else:
-            #turned OFF
-            if not flags.can_touch_runtime_system("stop NTP service"):
-                #cannot touch runtime system, nothing to do here
-                return
-
-            self._set_date_time_setting_sensitive(True)
-            ret = util.stop_service(NTP_SERVICE)
-
-            #if stopping chronyd failed and chronyd is running,
-            #set switch back to ON
-            if (ret != 0) and util.service_running(NTP_SERVICE):
-                switch.set_active(True)
-
-            self.clear_info()
-
-    def on_ntp_config_clicked(self, *args):
-        self._config_dialog.refresh()
-
-        with self.main_window.enlightbox(self._config_dialog.window):
-            response = self._config_dialog.run()
-
-        if response == 1:
-            pools, servers = self._config_dialog.pools_servers
-            self._timezone_module.proxy.SetNTPServers(ntp.pools_servers_to_internal(pools, servers))
-
-            if self._config_dialog.working_server is None:
-                self._show_no_ntp_server_warning()
-            else:
-                self.clear_info()
-
-- 
2.7.4