Class: Bootloader::Grub2Widget::TrustedBootWidget

Inherits:
CWM::CheckBox
  • Object
show all
Includes:
Grub2Helper
Defined in:
src/lib/bootloader/grub2_widgets.rb

Overview

Represents switcher for Trusted Boot

Instance Method Summary collapse

Methods included from Grub2Helper

#grub2, #grub_default, #password, #stage1

Constructor Details

#initializeTrustedBootWidget

Returns a new instance of TrustedBootWidget.



213
214
215
216
217
# File 'src/lib/bootloader/grub2_widgets.rb', line 213

def initialize
  textdomain "bootloader"

  super
end

Instance Method Details

#helpObject



223
224
225
226
227
228
229
230
231
232
233
234
235
236
# File 'src/lib/bootloader/grub2_widgets.rb', line 223

def help
  res = _("<p><b>Trusted Boot</b> " \
          "means measuring the integrity of the boot process,\n" \
          "with the help from the hardware (a TPM, Trusted Platform Module,\n" \
          "chip).\n")
  if grub2.name == "grub2"
    res += _("First you need to make sure Trusted Boot is enabled in the BIOS\n" \
             "setup (the setting may be named \"Security Chip\", for example).\n")
  end

  res += "</p>"

  res
end

#initObject



238
239
240
# File 'src/lib/bootloader/grub2_widgets.rb', line 238

def init
  self.value = grub2.trusted_boot
end

#labelObject



219
220
221
# File 'src/lib/bootloader/grub2_widgets.rb', line 219

def label
  _("&Trusted Boot Support")
end

#storeObject



242
243
244
# File 'src/lib/bootloader/grub2_widgets.rb', line 242

def store
  grub2.trusted_boot = value
end

#validateObject



246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
# File 'src/lib/bootloader/grub2_widgets.rb', line 246

def validate
  return true if Yast::Mode.config || !value || ["grub2-efi",
                                                 "grub2-bls"].include?(grub2.name)

  tpm_files = Dir.glob("/sys/**/pcrs")
  if !tpm_files.empty? && !File.read(tpm_files[0], 1).nil?
    # check for file size does not work, since FS reports it 4096
    # even if the file is in fact empty and a single byte cannot
    # be read, therefore testing real reading (details: bsc#994556)
    return true
  end

  Yast::Popup.ContinueCancel(_("Trusted Platform Module not found.\n" \
                               "Make sure it is enabled in BIOS.\n" \
                               "The system will not boot otherwise."))
end