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

Constant Summary

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (GRUB2Pwd) initialize

Reads or proposes configuration depending on stage



19
20
21
22
23
24
25
# File 'src/lib/bootloader/grub2pwd.rb', line 19

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

Instance Attribute Details

- (Boolean) unrestricted Also known as: unrestricted?

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

Returns:

  • (Boolean)

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



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

attr_accessor :used, :unrestricted

- (Boolean) used Also known as: used?

Returns specifies if password protection enabled

Returns:

  • (Boolean)

    specifies if password protection enabled



14
15
16
# File 'src/lib/bootloader/grub2pwd.rb', line 14

def used
  @used
end

Instance Method Details

- (Object) password=(value)

Sets password in encrypted form

Parameters:

  • value (String)

    plain text password



38
39
40
# File 'src/lib/bootloader/grub2pwd.rb', line 38

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

- (Boolean) password?

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)


46
47
48
# File 'src/lib/bootloader/grub2pwd.rb', line 46

def password?
  !@encrypted_password.nil?
end

- (Object) write

writes configuration to disk



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

def write
  if used?
    enable
  else
    disable
  end
end