Class: Bootloader::GRUB2Pwd

Inherits:
Object
  • Object
show all
Defined in:
src/lib/bootloader/grub2pwd.rb

Overview

class is responsible for detection, encryption and writing of grub2 password protection

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGRUB2Pwd

Reads or proposes configuration depending on stage


29
30
31
32
33
34
35
# File 'src/lib/bootloader/grub2pwd.rb', line 29

def initialize
  if Yast::Stage.initial
    propose
  else
    read
  end
end

Instance Attribute Details

#encrypted_passwordString?

Encrypted value of password

Returns:

  • (String, nil)

    specifies value of password after encryption. Nil if not set


24
# File 'src/lib/bootloader/grub2pwd.rb', line 24

attr_accessor :used, :unrestricted, :encrypted_password

#unrestrictedBoolean Also known as: unrestricted?

if password protection is unrestricted or not

Returns:

  • (Boolean)

    specifies if unrestricted password protection should be used (see fate#318574)

See Also:


24
# File 'src/lib/bootloader/grub2pwd.rb', line 24

attr_accessor :used, :unrestricted, :encrypted_password

#usedBoolean Also known as: used?

flag is password protection is used at all

Returns:

  • (Boolean)

    specifies if password protection enabled


24
25
26
# File 'src/lib/bootloader/grub2pwd.rb', line 24

def used
  @used
end

Instance Method Details

#password=(value) ⇒ Object

Sets password in encrypted form

Parameters:

  • value (String)

    plain text password


48
49
50
# File 'src/lib/bootloader/grub2pwd.rb', line 48

def password=(value)
  @encrypted_password = encrypt(value)
end

#password?Boolean

Gets if password is specified Rationale for this method is that in some cases it is possible to disable password configuration, but still keep old configuration in object, so after enabling it again it use old configuration

Returns:

  • (Boolean)

56
57
58
# File 'src/lib/bootloader/grub2pwd.rb', line 56

def password?
  !@encrypted_password.nil?
end

#writeObject

writes configuration to disk


38
39
40
41
42
43
44
# File 'src/lib/bootloader/grub2pwd.rb', line 38

def write
  if used?
    enable
  else
    disable
  end
end