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.



404
405
406
407
408
# File 'src/lib/bootloader/grub2_widgets.rb', line 404

def initialize
  textdomain "bootloader"

  super
end

Instance Method Details

#helpObject



414
415
416
417
418
419
420
421
422
423
424
425
426
427
# File 'src/lib/bootloader/grub2_widgets.rb', line 414

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



429
430
431
# File 'src/lib/bootloader/grub2_widgets.rb', line 429

def init
  self.value = grub2.trusted_boot
end

#labelObject



410
411
412
# File 'src/lib/bootloader/grub2_widgets.rb', line 410

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

#storeObject



433
434
435
# File 'src/lib/bootloader/grub2_widgets.rb', line 433

def store
  grub2.trusted_boot = value
end

#validateObject



437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
# File 'src/lib/bootloader/grub2_widgets.rb', line 437

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