Skip to content

Commit

Permalink
Also remove the "restrict" server option (bsc#954442)
Browse files Browse the repository at this point in the history
...from /etc/ntp.conf when a server is removed,
do not leave unused values.

- 2.17.19
  • Loading branch information
lslezak committed Nov 13, 2015
1 parent 819041b commit b028045
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
@@ -1 +1 @@
2.17.18
2.17.19
7 changes: 7 additions & 0 deletions package/yast2-ntp-client.changes
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Nov 13 11:55:05 UTC 2015 - lslezak@suse.cz

- Also remove the "restrict" server option from /etc/ntp.conf when
a server is removed, do not leave unused values (bsc#954442)
- 2.17.19

-------------------------------------------------------------------
Wed Nov 4 09:51:04 UTC 2015 - igonzalezsosa@suse.com

Expand Down
30 changes: 30 additions & 0 deletions src/NtpClient.ycp
Expand Up @@ -1107,8 +1107,38 @@ global define boolean deleteSyncRecord (integer index) ``{
y2error ("Record with index %1 doesn't exist", index);
return false;
}

y2milestone("Removing record at index %1: %2", index, ntp_records[index]:nil);

// server removal?
string removed_server = nil;
if (ntp_records[index,"type"]:"" == "server")
{
string address = ntp_records[index,"address"]:"";

if (address != "")
{
removed_server = address;
}
}

ntp_records[index] = nil;
ntp_records = filter (map<string,any> r, ntp_records, ``(r != nil));

if (removed_server != nil)
{
// remove the restrict option if the server is not used anymore (bsc#954442)
list<map> another_servers = filter (map<string,any> r, ntp_records, {
return r["type"]:"" == "server" && r["address"]:"" == removed_server;
});

if (size(another_servers) == 0)
{
y2milestone("Removing restrict option for %1", removed_server);
restrict_map = remove(restrict_map, removed_server);
}
}

modified = true;
return true;
}
Expand Down

0 comments on commit b028045

Please sign in to comment.