[yast-commit] r39180 - in /trunk/ntp-client/src: NtpClient.ycp dialogs.ycp widgets.ycp
Author: kmachalkova Date: Wed Jul 4 17:25:24 2007 New Revision: 39180 URL: http://svn.opensuse.org/viewcvs/yast?rev=39180&view=rev Log: Added option to define access control flags (notrust, noquery etc.) for ntp servers (FaTE #120109) Modified: trunk/ntp-client/src/NtpClient.ycp trunk/ntp-client/src/dialogs.ycp trunk/ntp-client/src/widgets.ycp Modified: trunk/ntp-client/src/NtpClient.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ntp-client/src/NtpClient.ycp?rev=39180&r1=39179&r2=39180&view=diff ============================================================================== --- trunk/ntp-client/src/NtpClient.ycp (original) +++ trunk/ntp-client/src/NtpClient.ycp Wed Jul 4 17:25:24 2007 @@ -25,6 +25,7 @@ import "Report"; import "Service"; import "SLPAPI"; +import "String"; import "Summary"; import "SuSEFirewall"; @@ -52,6 +53,7 @@ */ global list<map<string, any> > ntp_records = []; +global map <string, map <string,any> > restrict_map = $[]; /** * Should the daemon be started when system boots? @@ -226,7 +228,6 @@ integer steps = 2; integer sl = 500; - // We do not set help text here, because it was set outside Progress::New( caption, " ", steps, [ // progress stage @@ -299,7 +300,7 @@ string options = ""; if (contains ([ "server", "peer", "broadcast", "broadcastclient", "manycast", - "manycastclient", "fudge" ], + "manycastclient", "fudge", "restrict" ], type)) { list<string> l = splitstring (address, " \t"); @@ -324,10 +325,39 @@ string key = m["address"]:""; return $[key: m]; }); + + list<map<string, any> > restrict_records = filter (map<string,any> m, ntp_records, ``( + m["type"]:"" == "restrict" + )); + + restrict_map = (map <string, map <string,any> > )listmap (map m, restrict_records, + { + string key = m["address"]:""; + map value = $[]; + + list <string> opts = splitstring( String::CutBlanks( m["options"]:"" ), " \t"); + if ( opts[0]:"" == "mask") { + value["mask"] = opts[1]:""; + opts[0] = ""; opts[1] = ""; + } + else { + value["mask"] = ""; + } + + value["options"] = String::CutBlanks( mergestring(opts, " ")); + value["comment"] = m["comment"]:""; + + return $[key: value]; + }); + ntp_records = filter (map<string,any> m, ntp_records, ``( m["type"]:"" != "fudge" )); + ntp_records = filter (map<string,any> m, ntp_records, ``( + m["type"]:"" != "restrict" + )); + ntp_records = (list<map<string,any> >)maplist (map m, ntp_records, ``{ if (haskey (fudge_map, m["address"]:"")) { @@ -583,6 +613,17 @@ } else { + foreach (string key, map <string, any> m, restrict_map, { + map <string, any> ret = $[ + "address" : key, + "comment" : m["comment"]:"", + "type" : "restrict", + "options": ((m["mask"]:"" != "") ? " mask " + m["mask"]:"" : "" ) + " " + + m["options"]:"", + ]; + ntp_records = add(ntp_records, ret); + }); + y2milestone ("Writing settings %1", ntp_records); list<map<string, any> > save2 = (list<map<string, any> >)flatten (maplist( Modified: trunk/ntp-client/src/dialogs.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ntp-client/src/dialogs.ycp?rev=39180&r1=39179&r2=39180&view=diff ============================================================================== --- trunk/ntp-client/src/dialogs.ycp (original) +++ trunk/ntp-client/src/dialogs.ycp Wed Jul 4 17:25:24 2007 @@ -242,11 +242,16 @@ define symbol ServerDialog () ``{ term contents = `HBox (`HStretch (), `VBox ( `VSpacing (3), - "server_address", - `VSpacing (1), - `Left ("init_sync"), - `VSpacing (1), - "options", + `Frame( _("Server Settings"), + `VBox ( + "server_address", + `VSpacing (0.5), + `Left ("init_sync"), + `VSpacing (0.5), + "options") + ), + `VSpacing(1), + "ac_options", `VSpacing (3) ), `HStretch ()); @@ -254,7 +259,7 @@ string caption = _("NTP Server"); return CWM::ShowAndRun ($[ - "widget_names" : ["server_address", "init_sync", "options"], + "widget_names" : ["server_address", "init_sync", "options", "ac_options"], "widget_descr" : GetWidgets (), "contents" : contents, "caption" : caption, Modified: trunk/ntp-client/src/widgets.ycp URL: http://svn.opensuse.org/viewcvs/yast/trunk/ntp-client/src/widgets.ycp?rev=39180&r1=39179&r2=39180&view=diff ============================================================================== --- trunk/ntp-client/src/widgets.ycp (original) +++ trunk/ntp-client/src/widgets.ycp Wed Jul 4 17:25:24 2007 @@ -628,6 +628,30 @@ NtpClient::selected_record["options"] = UI::QueryWidget (`id ("options"), `Value); } +define void restrictOptionsInit ( string id ) ``{ + string address = NtpClient::selected_record["address"]:""; + if( haskey( NtpClient::restrict_map, address) ) + { + UI::ChangeWidget(`id(`use_ac), `Value, true); + UI::ChangeWidget(`id("ac_opts"), `Value, NtpClient::restrict_map[address,"options"]:""); + } +} + +define void restrictOptionsStore (string id, map event ) ``{ + string address = NtpClient::selected_record["address"]:""; + string opts = (string) UI::QueryWidget(`id("ac_opts"), `Value); + + if( haskey( NtpClient::restrict_map, address) ) + NtpClient::restrict_map[address, "options"] = opts; + else + { + NtpClient::restrict_map[address] = $[ + "comment" : "", + "mask" : "", + "options" : opts, + ]; + } +} /** * Initialize the widget * @param id any widget id @@ -1307,6 +1331,20 @@ "store" : optionsStore, "help" : HELPS["options"]:"", ], + "ac_options" : $[ + "widget" : `custom, + "custom_widget" : `CheckBoxFrame ( + `id(`use_ac), _("Apply Access Control for This Server"), false, + `VBox( + `VSpacing(0.5), + `Left(`TextEntry(`id("ac_opts"), "Access Control Options")), + `VSpacing(0.5) + ) + ), + "init" : restrictOptionsInit, + "store" : restrictOptionsStore, + "help": "", + ], "peer_types" : $[ "widget" : `radio_buttons, "items" : [ -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
kmachalkova@svn.opensuse.org