Skip to content

Commit

Permalink
drop restrict which is no longer used in chrony and instead more comp…
Browse files Browse the repository at this point in the history
…lex allow/deny is used
  • Loading branch information
jreidinger committed Nov 6, 2017
1 parent 88dad58 commit 99c0257
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 111 deletions.
4 changes: 1 addition & 3 deletions src/include/ntp-client/dialogs.rb
Expand Up @@ -167,8 +167,6 @@ def MainDialog
VSpacing(1),
HBox(
VBox(
Left("secure"),
VSpacing(),
"firewall"
)
),
Expand All @@ -192,7 +190,7 @@ def MainDialog
"security" => {
"header" => _("Security Settings"),
"contents" => tab2,
"widget_names" => ["secure", "firewall"]
"widget_names" => ["firewall"]
}
}

Expand Down
9 changes: 0 additions & 9 deletions src/include/ntp-client/helps.rb
Expand Up @@ -41,15 +41,6 @@ def initialize_ntp_client_helps(_include_target)
"and the system time will be set periodically by a <i>cron</i> script. \n" \
"The interval is configurable, by default it is %d minutes."
) % NtpClientClass::DEFAULT_SYNC_INTERVAL,
# help text 2/5
"secure" => _(
"<p><b><big>Secure NTP Configuration</big></b><br>\n" \
"By selecting <b>Restrict NTP Service to Configured Servers Only</b>, remote hosts " \
"will not be able to view and modify NTP settings on your \ncomputer. The NTP " \
"service is restricted to servers in the <tt>/etc/ntp.conf</tt> file and to " \
"localhost.<br> \nAccess control flags can be fine-tuded in the servers overview " \
"table. This option is not available if NTP is configured via DHCP.</p>\n"
),
# help text 3/5
"config_dhcp" => _(
"<p><b><big>Configuring via DHCP</big></b><br>\n" \
Expand Down
111 changes: 12 additions & 99 deletions src/include/ntp-client/widgets.rb
Expand Up @@ -340,53 +340,6 @@ def fudgeButtonHandle(_key, _event)
:fudge
end

def secureInit(_id)
Builtins.y2milestone("Restrict %1", NtpClient.restrict_map)
if NtpClient.PolicyIsNonstatic
UI.ChangeWidget(Id("secure"), :Enabled, false)
else
UI.ChangeWidget(Id("secure"), :Value, NtpClient.restrict_map != {})
end

nil
end

def secureStore(id, _event)
restrict = Convert.to_boolean(UI.QueryWidget(Id(id), :Value))

if restrict
servers = NtpClient.GetUsedNtpServers

if NtpClient.restrict_map == {}
Ops.set(
NtpClient.restrict_map,
"default",
"mask" => "", "comment" => "", "options" => "ignore"
)

Ops.set(
NtpClient.restrict_map,
"127.0.0.1",
"mask" => "", "comment" => "", "options" => ""
)

Builtins.foreach(servers) do |s|
Ops.set(
NtpClient.restrict_map,
s,
"mask" => "",
"comment" => "",
"options" => "nomodify notrap noquery"
)
end
end
else
NtpClient.restrict_map = {}
end

nil
end

# Initialize the widget
# @param [String] id any widget id
def PolicyInit(_id)
Expand Down Expand Up @@ -538,15 +491,11 @@ def overviewRedraw
# @param [Hash] event map event that caused storing process
# @return [Object] event to pass to WS or nil
def overviewHandle(id, event)
event = deep_copy(event)
# ntpEnabledOrDisabled (id, event);
if Ops.get(event, "ID") == :display_log
event_id = event["ID"]
case event_id
when :display_log
showLogPopup
return nil
end
ev_id = Ops.get(event, "ID")
if ev_id == "boot" || ev_id == "never" || ev_id == "sync" ||
ev_id == "policy_combo"
when "boot", "never", "sync", "policy_combo"
pol = Convert.to_symbol(UI.QueryWidget(Id("policy_combo"), :Value))

enabled = UI.QueryWidget(Id("start"), :CurrentButton) != "never"
Expand All @@ -571,40 +520,11 @@ def overviewHandle(id, event)
event
)
NtpClient.modified = true
return nil
end
types = {
"server" => :server,
"peer" => :peer,
"__clock" => :clock,
"broadcast" => :bcast,
"broadcastclient" => :bcastclient
}
if Ops.get(event, "ID") == :add
NtpClient.selectSyncRecord(-1)
@peer_type_selected = nil
Builtins.y2milestone(
"set modified from %1 to true 4.2 id %2 map %3",
NtpClient.modified,
id,
event
)
NtpClient.modified = true
return :add
elsif Ops.get(event, "ID") == :edit || Ops.get(event, "ID") == :overview
NtpClient.selectSyncRecord(
Convert.to_integer(UI.QueryWidget(Id(:overview), :CurrentItem))
)
type = Ops.get_string(NtpClient.selected_record, "type", "")
Builtins.y2milestone(
"set modified from %1 to true 4.3 id %2 map %3",
NtpClient.modified,
id,
event
)
NtpClient.modified = true
return Ops.get(types, type)
elsif Ops.get(event, "ID") == :delete
when :add
# TODO:
when :edit, :overview
# TODO:
when :delete
# yes-no popup
if Confirm.DeleteSelected
NtpClient.deleteSyncRecord(
Expand All @@ -620,7 +540,10 @@ def overviewHandle(id, event)
)
NtpClient.modified = true
end
else
#CWM internal events or from other widget, just ignore
end

nil
end

Expand Down Expand Up @@ -1354,16 +1277,6 @@ def InitWidgets
"handle_events" => ["boot", "never", "sync"],
"opt" => [:notify]
},
"secure" => {
"widget" => :checkbox,
# TRANSLATORS:
"label" => _(
"&Restrict NTP Service to Configured Servers Only "
),
"init" => fun_ref(method(:secureInit), "void (string)"),
"store" => fun_ref(method(:secureStore), "void (string, map)"),
"help" => Ops.get_string(@HELPS, "secure", "")
},
"policy_combo" => { # FIXME
"widget" => :combobox,
"opt" => [:notify],
Expand Down

0 comments on commit 99c0257

Please sign in to comment.