Class: DInstaller::LuksActivationQuestion

Inherits:
Question
  • Object
show all
Defined in:
lib/dinstaller/luks_activation_question.rb

Overview

This class represent a question to ask whether to activate a LUKS device

Clients have to answer one of these options:

* skip: to skip the activation of the LUKS device
* decrypt: to activate the device using the provided password

Examples:

question = LuksActivationQuestion.new("/dev/sda1", label: "mydata", size: "10 GiB")
question.password = "n0ts3cr3t"

question.answer = :skip    # in case you do not want to activate the device

question.answer = :decrypt # in case you want to decrypt with the given password

Instance Attribute Summary collapse

Attributes inherited from Question

#answer, #default_option, #id, #options, #text

Instance Method Summary collapse

Methods inherited from Question

#answered?

Constructor Details

#initialize(device, label: nil, size: nil, attempt: 1) ⇒ LuksActivationQuestion

Constructor

Parameters:

  • device (String)

    name of the device to be activated (e.g., “/dev/sda1”)

  • label (String, nil) (defaults to: nil)

    label of the device

  • size (String, nil) (defaults to: nil)

    size of the device (e.g., “5 GiB”)



49
50
51
52
53
54
55
56
# File 'lib/dinstaller/luks_activation_question.rb', line 49

def initialize(device, label: nil, size: nil, attempt: 1)
  @device = device
  @label = label
  @size = size
  @attempt = attempt

  super(generate_text, options: [:skip, :decrypt])
end

Instance Attribute Details

#attemptInteger (readonly)

Current attempt to decrypt the device

Returns:

  • (Integer)


42
43
44
# File 'lib/dinstaller/luks_activation_question.rb', line 42

def attempt
  @attempt
end

#passwordString?

Password to activate the LUKS device

Returns:

  • (String, nil)

    nil means a password has not been provided yet



61
62
63
# File 'lib/dinstaller/luks_activation_question.rb', line 61

def password
  @password
end