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, #sections, #stage1

Constructor Details

#initializeTrustedBootWidget

Returns a new instance of TrustedBootWidget.



321
322
323
324
325
# File 'src/lib/bootloader/grub2_widgets.rb', line 321

def initialize
  textdomain "bootloader"

  super
end

Instance Method Details

#helpObject



331
332
333
334
335
336
337
338
339
340
341
342
343
344
# File 'src/lib/bootloader/grub2_widgets.rb', line 331

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



346
347
348
# File 'src/lib/bootloader/grub2_widgets.rb', line 346

def init
  self.value = grub2.trusted_boot
end

#labelObject



327
328
329
# File 'src/lib/bootloader/grub2_widgets.rb', line 327

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

#storeObject



350
351
352
# File 'src/lib/bootloader/grub2_widgets.rb', line 350

def store
  grub2.trusted_boot = value
end

#validateObject



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
# File 'src/lib/bootloader/grub2_widgets.rb', line 354

def validate
  return true if Yast::Mode.config || !value || grub2.name == "grub2-efi"

  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