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



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

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



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

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:



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

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



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

def used
  @used
end

Instance Method Details

#password=(value) ⇒ Object

Sets password in encrypted form

Parameters:

  • value (String)

    plain text password



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

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)


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

def password?
  !@encrypted_password.nil?
end

#writeObject

writes configuration to disk



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

def write
  if used?
    enable
  else
    disable
  end
end