Module: Yast::SudoComplexInclude
- Defined in:
- ../../src/include/sudo/complex.rb
Instance Method Summary (collapse)
- - (Object) AddCommandDialog(c, p)
- - (Object) AddHostDialog(host)
- - (Object) AddUserDialog(users)
- - (Object) EnableDisableButtons(edit_button, delete_button, items)
- - (Object) initialize_sudo_complex(include_target)
- - (Object) UpdateCmdList(members)
- - (Object) ValidateCommand(cmd)
- - (Object) ValidateHost(hostname)
-
- (Object) WriteDialog
Write settings dialog.
Instance Method Details
- (Object) AddCommandDialog(c, p)
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 |
# File '../../src/include/sudo/complex.rb', line 184 def AddCommandDialog(c, p) new_command = "" items = Sudo.GetAliasNames("command") items = Builtins.prepend(items, "ALL") UI.OpenDialog( Opt(:decorated), VBox( Frame( _("Add new command with optional parameters"), VBox( VSpacing(0.5), VBox( HBox( MinWidth( 40, ComboBox(Id("cmd"), Opt(:editable), _("Command"), items) ), VBox(VSpacing(1.1), PushButton(Id("browse_c"), _("Browse"))) ), Left(TextEntry(Id("params"), _("Parameters (optional)"), p)) ), VSpacing(0.5) ) ), VSpacing(0.5), ButtonBox( PushButton(Id(:ok), Opt(:default, :okButton), Label.OKButton), PushButton(Id(:cancel), Opt(:cancelButton), Label.CancelButton) ) ) ) UI.ChangeWidget(Id("cmd"), :Value, c) ret = nil while true ret = UI.UserInput if ret == :ok cmd = Convert.to_string(UI.QueryWidget(Id("cmd"), :Value)) params = Convert.to_string(UI.QueryWidget(Id("params"), :Value)) if !ValidateCommand(cmd) UI.SetFocus(Id("cmd")) next end new_command = Ops.add(Ops.add(cmd, " "), params) break elsif ret == :cancel break elsif ret == "browse_c" new_cmd = UI.AskForExistingFile("/", "*", "Choose a command") UI.ChangeWidget(Id("cmd"), :Value, new_cmd) end end UI.CloseDialog new_command end |
- (Object) AddHostDialog(host)
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 |
# File '../../src/include/sudo/complex.rb', line 88 def AddHostDialog(host) new_host = host UI.OpenDialog( Opt(:decorated), VBox( Frame( _("Add New Host to the Alias"), MarginBox( 1, 1, InputField(Id("host_name"), _("Hostname or Network"), new_host) ) ), ButtonBox( PushButton(Id(:ok), Opt(:default, :okButton), Label.OKButton), PushButton(Id(:cancel), Opt(:cancelButton), Label.CancelButton) ) ) ) ret = nil while true ret = UI.UserInput if ret == :ok new_host = Convert.to_string(UI.QueryWidget(Id("host_name"), :Value)) if !ValidateHost(new_host) UI.SetFocus(Id("host_name")) next end break elsif ret == :cancel break end end UI.CloseDialog new_host end |
- (Object) AddUserDialog(users)
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/sudo/complex.rb', line 128 def AddUserDialog(users) users = deep_copy(users) new_user = "" UI.OpenDialog( Opt(:decorated), VBox( Frame( _("Add New User to the Alias"), MarginBox( 1, 1, ComboBox( Id("user_name"), _("Local and System Users (Groups)"), users ) ) ), ButtonBox( PushButton(Id(:ok), Opt(:default, :okButton), Label.OKButton), PushButton(Id(:cancel), Opt(:cancelButton), Label.CancelButton) ) ) ) ret = nil while true ret = UI.UserInput if ret == :ok new_user = Convert.to_string(UI.QueryWidget(Id("user_name"), :Value)) break elsif ret == :cancel break end end UI.CloseDialog new_user end |
- (Object) EnableDisableButtons(edit_button, delete_button, items)
53 54 55 56 57 58 59 |
# File '../../src/include/sudo/complex.rb', line 53 def EnableDisableButtons(, , items) items = deep_copy(items) UI.ChangeWidget(Id(), :Enabled, items != []) UI.ChangeWidget(Id(), :Enabled, items != []) nil end |
- (Object) initialize_sudo_complex(include_target)
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File '../../src/include/sudo/complex.rb', line 30 def initialize_sudo_complex(include_target) Yast.import "UI" textdomain "sudo" Yast.import "Label" Yast.import "Popup" Yast.import "Wizard" Yast.import "Confirm" Yast.import "Sudo" Yast.import "Report" Yast.import "Address" Yast.import "Netmask" Yast.import "FileUtils" Yast.include include_target, "sudo/helps.rb" @current_alias_name = "" @current_spec_idx = -1 @initial_screen = "user_specs" end |
- (Object) UpdateCmdList(members)
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 |
# File '../../src/include/sudo/complex.rb', line 246 def UpdateCmdList(members) members = deep_copy(members) idx = 0 items = [] Builtins.foreach(members) do |it| pos = Builtins.findfirstof(it, " \t") cmd = "" param = "" if pos != nil cmd = Builtins.substring(it, 0, pos) param = Builtins.substring(it, Ops.add(pos, 1)) else cmd = it param = "" end items = Builtins.add(items, Item(Id(idx), cmd, param)) idx = Ops.add(idx, 1) end deep_copy(items) end |
- (Object) ValidateCommand(cmd)
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File '../../src/include/sudo/complex.rb', line 168 def ValidateCommand(cmd) if FileUtils.Exists(cmd) || Builtins.contains(Sudo.GetAliasNames("command"), cmd) || cmd == "ALL" return true else Popup.Error( Builtins.sformat( _("File, directory or command alias '%1' does not exist."), cmd ) ) return false end end |
- (Object) ValidateHost(hostname)
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 |
# File '../../src/include/sudo/complex.rb', line 61 def ValidateHost(hostname) netmask = "" if Builtins.findfirstof(hostname, "/") != nil tmp = Builtins.splitstring(hostname, "/") hostname = Ops.get(tmp, 0, "") netmask = Ops.get(tmp, 1, "") if !Netmask.Check(netmask) netmask = "" Popup.Error( _( "A valid netmask is either in dotted quad notation \n" + "(4 integers in the range 128 - 255 separated by dots) \n" + "or single integer in the range 0 - 32" ) ) return false end end if !Address.Check(hostname) Popup.Error(Address.Valid4) return false end true end |
- (Object) WriteDialog
Write settings dialog
284 285 286 287 288 289 290 291 292 293 294 295 296 |
# File '../../src/include/sudo/complex.rb', line 284 def WriteDialog Wizard.RestoreHelp(Ops.get_string(@HELPS, "write", "")) ret = Sudo.Write #yes-no popup - an error occured when saving the configuration if !ret && Popup.YesNo( _("Saving sudoer's configuration failed. Change the settings?") ) return :back end ret ? :next : :abort end |