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



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

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)



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

attr_accessor :used, :unrestricted

- (Boolean) used Also known as: used?

Returns specifies if password protection enabled

Returns:

  • (Boolean)

    specifies if password protection enabled



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

def used
  @used
end

Instance Method Details

- (Object) password=(value)

Sets password in encrypted form

Parameters:

  • value (String)

    plain text password



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

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)


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

def password?
  !@encrypted_password.nil?
end

- (Object) write

writes configuration to disk



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

def write
  if used?
    enable
  else
    disable
  end
end