Class: Bootloader::GrubPasswordWidget
- Inherits:
-
CWM::CustomWidget
- Object
- CWM::CustomWidget
- Bootloader::GrubPasswordWidget
- Includes:
- Grub2Widget
- Defined in:
- src/lib/bootloader/grub2_widgets.rb
Overview
Represents grub password protection widget
Constant Summary
- MASKED_PASSWORD =
"**********"
Instance Method Summary (collapse)
- - (Object) contents
- - (Object) handle(event)
- - (Object) help
- - (Object) init
-
- (GrubPasswordWidget) initialize
constructor
A new instance of GrubPasswordWidget.
- - (Object) store
- - (Object) validate
Methods included from Grub2Widget
#grub2, #grub_default, #password, #sections, #stage1
Constructor Details
- (GrubPasswordWidget) initialize
Returns a new instance of GrubPasswordWidget
289 290 291 |
# File 'src/lib/bootloader/grub2_widgets.rb', line 289 def initialize textdomain "bootloader" end |
Instance Method Details
- (Object) contents
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 |
# File 'src/lib/bootloader/grub2_widgets.rb', line 295 def contents HBox( CheckBoxFrame( Id(:use_pas), _("Prot&ect Boot Loader with Password"), true, VBox( HBox( HSpacing(2), # TRANSLATORS: checkbox entry CheckBox(Id(:unrestricted_pw), _("P&rotect Entry Modification Only")), HStretch() ), HBox( HSpacing(2), # text entry Password(Id(:pw1), Opt(:hstretch), _("&Password")), # text entry HSpacing(2), Password(Id(:pw2), Opt(:hstretch), _("Re&type Password")), HStretch() ) ) ) ) end |
- (Object) handle(event)
353 354 355 356 357 358 359 360 361 362 |
# File 'src/lib/bootloader/grub2_widgets.rb', line 353 def handle(event) return unless event["ID"] == :use_pas enabled = Yast::UI.QueryWidget(Id(:use_pas), :Value) Yast::UI.ChangeWidget(Id(:unrestricted_pw), :Enabled, enabled) Yast::UI.ChangeWidget(Id(:pw1), :Enabled, enabled) Yast::UI.ChangeWidget(Id(:pw2), :Enabled, enabled) nil end |
- (Object) help
381 382 383 384 385 386 387 388 389 390 391 |
# File 'src/lib/bootloader/grub2_widgets.rb', line 381 def help _( "<p><b>Protect Boot Loader with Password</b><br>\n" \ "At boot time, modifying or even booting any entry will require the" \ " password. If <b>Protect Entry Modification Only</b> is checked then " \ "booting any entry is not restricted but modifying entries requires " \ "the password (which is the way GRUB 1 behaved).<br>" \ "YaST will only accept the password if you repeat it in " \ "<b>Retype Password</b>.</p>" ) end |
- (Object) init
339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'src/lib/bootloader/grub2_widgets.rb', line 339 def init enabled = password.used? # read state on disk only if not already set by user (bnc#900026) value = enabled && password.password? ? MASKED_PASSWORD : "" Yast::UI.ChangeWidget(Id(:use_pas), :Value, enabled) Yast::UI.ChangeWidget(Id(:pw1), :Enabled, enabled) Yast::UI.ChangeWidget(Id(:pw1), :Value, value) Yast::UI.ChangeWidget(Id(:pw2), :Enabled, enabled) Yast::UI.ChangeWidget(Id(:pw2), :Value, value) Yast::UI.ChangeWidget(Id(:unrestricted_pw), :Enabled, enabled) Yast::UI.ChangeWidget(Id(:unrestricted_pw), :Value, password.unrestricted?) end |
- (Object) store
364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 |
# File 'src/lib/bootloader/grub2_widgets.rb', line 364 def store usepass = Yast::UI.QueryWidget(Id(:use_pas), :Value) if !usepass password.used = false return end password.used = true value = Yast::UI.QueryWidget(Id(:pw1), :Value) # special value as we do not know password, so it mean user do not change it password.password = value if value != MASKED_PASSWORD value = Yast::UI.QueryWidget(Id(:unrestricted_pw), :Value) password.unrestricted = value end |
- (Object) validate
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 |
# File 'src/lib/bootloader/grub2_widgets.rb', line 322 def validate return true unless Yast::UI.QueryWidget(Id(:use_pas), :Value) if Yast::UI.QueryWidget(Id(:pw1), :Value) == "" Yast::Report.Error(_("The password must not be empty.")) Yast::UI.SetFocus(Id(:pw1)) return false end if Yast::UI.QueryWidget(Id(:pw1), :Value) == Yast::UI.QueryWidget(Id(:pw2), :Value) return true end Yast::Report.Error(_( "'Password' and 'Retype password'\ndo not match. Retype the password." )) Yast::UI.SetFocus(Id(:pw1)) false end |