Module: Yast::NisServerSecurenetsInclude
- Defined in:
- ../../src/include/nis_server/securenets.rb
Instance Method Summary (collapse)
- - (Object) initialize_nis_server_securenets(include_target)
-
- (Object) ItemizeSecurenets(nets)
Creates items for table from var_yp_securenets.scr any agent.
-
- (Array) MergeNetsEntries(orig, edit)
Merge edited entries with the original entries with comments.
-
- (Object) NetsEditPopup(id, netmask, network)
Popup dialog for editing netmask/network.
-
- (Object) QueryHosts
Securenets dialog.
Instance Method Details
- (Object) initialize_nis_server_securenets(include_target)
42 43 44 45 46 47 48 49 50 51 52 |
# File '../../src/include/nis_server/securenets.rb', line 42 def initialize_nis_server_securenets(include_target) Yast.import "UI" textdomain "nis_server" Yast.import "NisServer" Yast.import "Wizard" Yast.import "Label" Yast.import "Popup" Yast.import "IP" end |
- (Object) ItemizeSecurenets(nets)
Creates items for table from var_yp_securenets.scr any agent
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File '../../src/include/nis_server/securenets.rb', line 58 def ItemizeSecurenets(nets) nets = deep_copy(nets) not_comment = Builtins.filter(nets) do |e| Builtins.haskey(e, "netmask") || Builtins.haskey(e, "network") end result = [] i = 0 Builtins.foreach(not_comment) do |element| result = Builtins.add( result, Item( Id(i), Ops.get_string(element, "netmask", ""), Ops.get_string(element, "network", "") ) ) i = Ops.add(i, 1) end deep_copy(result) end |
- (Array) MergeNetsEntries(orig, edit)
Merge edited entries with the original entries with comments
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File '../../src/include/nis_server/securenets.rb', line 83 def MergeNetsEntries(orig, edit) orig = deep_copy(orig) edit = deep_copy(edit) edit_maps = Builtins.maplist(edit) do |e| { "netmask" => Ops.get_string(e, 1, ""), "network" => Ops.get_string(e, 2, "") } end result = Builtins.filter(orig) do |e| Builtins.haskey(e, "hash") || Builtins.haskey(e, "comment") || Builtins.contains(edit_maps, e) end edit_maps = Builtins.filter(edit_maps) do |e| !Builtins.contains(result, e) end result = Ops.add(result, edit_maps) deep_copy(result) end |
- (Object) NetsEditPopup(id, netmask, network)
Popup dialog for editing netmask/network
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 |
# File '../../src/include/nis_server/securenets.rb', line 111 def NetsEditPopup(id, netmask, network) contents = HBox( HSpacing(), VBox( VSpacing(0.3), # To translators: popup dialog heading Heading(_("Edit netmask and network")), VSpacing(0.5), # To translators: textentry label InputField(Id(:netmask), Opt(:hstretch), _("Net&mask"), netmask), VSpacing(0.3), # To translators: textentry label InputField(Id(:network), Opt(:hstretch), _("Net&work"), network), VSpacing(0.5), ButtonBox( PushButton(Id(:ok), Opt(:default), Label.OKButton), PushButton(Id(:cancel), Label.CancelButton) ), VSpacing(0.3) ), HSpacing() ) UI.OpenDialog(contents) UI.SetFocus(Id(:netmask)) ui = nil error_msg = "" begin error_msg = "" ui = Convert.to_symbol(UI.UserInput) if ui == :ok netmask = Convert.to_string(UI.QueryWidget(Id(:netmask), :Value)) network = Convert.to_string(UI.QueryWidget(Id(:network), :Value)) # explicitly allow 0.0.0.0 if netmask != "0.0.0.0" && !IP.Check4(netmask) # To translators: error message error_msg = Ops.add(error_msg, _("Wrong netmask!\n")) end # To translators: error message error_msg = Ops.add( error_msg, IP.Check4(network) ? "" : _("Wrong network!\n") ) if Ops.greater_than(Builtins.size(error_msg), 0) Popup.Error(error_msg) end end end until error_msg == "" && ui == :ok || ui == :cancel UI.CloseDialog ui == :ok ? Item(Id(id), netmask, network) : nil end |
- (Object) QueryHosts
Securenets dialog
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 |
# File '../../src/include/nis_server/securenets.rb', line 170 def QueryHosts # help text 1/4 helptext = _( "<p>Please enter which hosts are allowed to query the NIS server.</p>" ) # help text 2/4 helptext = Ops.add( helptext, _( "<p>A host address will be allowed if <b>network</b> is equal\nto the bitwise <i>AND</i> of the host's address and the <b>netmask</b>.</p>" ) ) # help text 3/4 helptext = Ops.add( helptext, _( "<p>The entry with <b>netmask</b> <tt>255.0.0.0</tt> and <b>network</b>\n<tt>127.0.0.0</tt> must exist to allow connections from the local host.</p>\n" ) ) # help text 4/4 helptext = Ops.add( helptext, _( "<p>Entering <b>netmask</b> <tt>0.0.0.0</tt> and\n<b>network</b> <tt>0.0.0.0</tt> gives access to all hosts.</p>" ) ) allow_query = ItemizeSecurenets(NisServer.securenets) n_items = Builtins.size(allow_query) contents = VBox( Table( Id(:table), Opt(:notify, :immediate), Header( # To translators: table header _("Netmask"), # To translators: table header _("Network") ), allow_query ), HBox( PushButton(Id(:add), Label.AddButton), PushButton(Id(:edit), Label.EditButton), PushButton(Id(:delete), Label.DeleteButton), HStretch() ) ) # To translators: dialog label Wizard.SetContents( _("NIS Server Query Hosts Setup"), contents, helptext, true, true ) Wizard.SetNextButton(:next, Label.FinishButton) ui = nil begin anyitems = UI.QueryWidget(Id(:table), :CurrentItem) != nil UI.ChangeWidget(Id(:edit), :Enabled, anyitems) UI.ChangeWidget(Id(:delete), :Enabled, anyitems) # Kludge, because a `Table still does not have a shortcut. #16116 UI.SetFocus(Id(:table)) ui = Convert.to_symbol(UI.UserInput) ui = :abort if ui == :cancel if ui == :delete id = Convert.to_integer(UI.QueryWidget(Id(:table), :CurrentItem)) allow_query = Builtins.filter(allow_query) do |e| id != Ops.get_integer(e, [0, 0], -1) end UI.ChangeWidget(Id(:table), :Items, allow_query) elsif ui == :edit id = Convert.to_integer(UI.QueryWidget(Id(:table), :CurrentItem)) item = Builtins.find(allow_query) do |e| id == Ops.get_integer(e, [0, 0], -1) end item = NetsEditPopup( id, Ops.get_string(item, 1, ""), Ops.get_string(item, 2, "") ) if item != nil allow_query = Builtins.maplist(allow_query) do |e| Ops.get_integer(e, [0, 0], -1) == id ? item : e end UI.ChangeWidget(Id(:table), :Items, allow_query) end elsif ui == :add new_item = NetsEditPopup(n_items, "", "") if new_item != nil n_items = Ops.add(n_items, 1) allow_query = Builtins.add(allow_query, new_item) UI.ChangeWidget(Id(:table), :Items, allow_query) end end ui = :again if ui == :abort && !Popup.ReallyAbort(NisServer.modified) end until Builtins.contains([:back, :next, :abort], ui) Wizard.RestoreNextButton if ui == :back securenets = MergeNetsEntries(NisServer.securenets, allow_query) # and finally merge if ui == :next && Builtins.sort(securenets) != Builtins.sort(NisServer.securenets) NisServer.securenets = deep_copy(securenets) NisServer.modified = true end ui end |