Class: Bootloader::Systeminfo
- Inherits:
-
Object
- Object
- Bootloader::Systeminfo
- Extended by:
- Yast::Logger
- Defined in:
- src/lib/bootloader/systeminfo.rb
Overview
Provide system and architecture dependent information
Class Method Summary collapse
-
.bls_timeout_supported?(bootloader_name) ⇒ Boolean
Using bls timeout settings.
-
.console_supported?(bootloader_name) ⇒ Boolean
Check if console settings are supported.
-
.device_map?(bootloader_name) ⇒ Boolean
Check if setting device map is available.
- .efi? ⇒ Boolean
-
.efi_arch ⇒ String
Effective UEFI architecture.
-
.efi_mandatory? ⇒ Boolean
Check if EFI mandatory on this system.
-
.efi_platform_size ⇒ Integer
UEFI platform size (32 or 64 bits).
-
.efi_supported? ⇒ Boolean
Check if UEFI is available on this system.
-
.efi_used?(bootloader_name) ⇒ Boolean
Check if UEFI will be used.
-
.generic_mbr_available?(bootloader_name) ⇒ Boolean
Check if mbr configurable with a bootloader.
-
.hiding_menu_supported?(bootloader_name) ⇒ Boolean
Check if hiding menu are supported.
-
.loader_location_available?(bootloader_name) ⇒ Boolean
Check if loader location is configurable with a bootloader.
-
.nvram_available?(bootloader_name = nil) ⇒ Boolean
Check if the system is expected to have nvram - ie.
-
.password_supported?(bootloader_name) ⇒ Boolean
Check if setting password is supported.
-
.ppc_secure_boot ⇒ Object
Return secure boot status on ppc.
-
.ppc_secure_boot_active? ⇒ Boolean
Check if secure boot is currently active on an ppc machine.
-
.ppc_secure_boot_available? ⇒ Boolean
Check if secure boot is (in principle) available on an ppc machine.
-
.ppc_secure_boot_supported? ⇒ Boolean
Check if secure boot is supported with the current setup.
-
.s390_secure_boot_active? ⇒ Boolean
Check if secure boot is currently active on an s390 machine.
-
.s390_secure_boot_available? ⇒ Boolean
Check if secure boot is (in principle) available on an s390 machine.
-
.s390_secure_boot_supported? ⇒ Boolean
Check if secure boot is supported with the current setup.
-
.scsi?(device) ⇒ Boolean
Check if device is a SCSI device.
-
.secure_boot_active? ⇒ Boolean
Check current secure boot state.
-
.secure_boot_available?(bootloader_name) ⇒ Boolean
Check if secure boot is configurable with a bootloader.
-
.secure_boot_supported? ⇒ Boolean
Check if secure boot is in principle supported.
-
.shim_needed?(bootloader_name, secure_boot) ⇒ Boolean
Check if shim-install should be used instead of grub2-install.
-
.trusted_boot_active? ⇒ Boolean
Check current trusted boot state.
-
.trusted_boot_available?(bootloader_name) ⇒ Boolean
Check if trusted boot is configurable with a bootloader.
- .update_nvram_active? ⇒ Boolean
-
.writable_efivars? ⇒ Boolean
Checks if efivars exists and can be written The point here is that without writable UEFI variables the UEFI boot manager cannot (and must not) be updated.
-
.zipl_device ⇒ Y2Storage::Partition, NilClass
The partition where zipl is installed.
Class Method Details
.bls_timeout_supported?(bootloader_name) ⇒ Boolean
Using bls timeout settings
param bootloader_name [String] bootloader name
160 161 162 |
# File 'src/lib/bootloader/systeminfo.rb', line 160 def bls_timeout_supported?(bootloader_name) bootloader_name == "grub2-bls" end |
.console_supported?(bootloader_name) ⇒ Boolean
Check if console settings are supported
param bootloader_name [String] bootloader name
144 145 146 |
# File 'src/lib/bootloader/systeminfo.rb', line 144 def console_supported?(bootloader_name) !Yast::Arch.s390 && bootloader_name != "grub2-bls" end |
.device_map?(bootloader_name) ⇒ Boolean
Check if setting device map is available.
74 75 76 77 |
# File 'src/lib/bootloader/systeminfo.rb', line 74 def device_map?(bootloader_name) (Yast::Arch.x86_64 || Yast::Arch.i386) && !["grub2-efi", "grub2-bls"].include?(bootloader_name) end |
.efi? ⇒ Boolean
327 328 329 |
# File 'src/lib/bootloader/systeminfo.rb', line 327 def efi? Y2Storage::Arch.new.efiboot? end |
.efi_arch ⇒ String
Effective UEFI architecture.
Usually the same as the architecture except on x86_64 where it depends on the platform size.
201 202 203 204 205 |
# File 'src/lib/bootloader/systeminfo.rb', line 201 def efi_arch arch = Yast::Arch.architecture arch = "i386" if arch == "x86_64" && efi_platform_size == 32 arch end |
.efi_mandatory? ⇒ Boolean
Check if EFI mandatory on this system.
136 137 138 |
# File 'src/lib/bootloader/systeminfo.rb', line 136 def efi_mandatory? Yast::Arch.aarch64 || Yast::Arch.arm || Yast::Arch.riscv64 end |
.efi_platform_size ⇒ Integer
UEFI platform size (32 or 64 bits).
On x86_64 systems both variants are possible.
187 188 189 190 191 192 193 |
# File 'src/lib/bootloader/systeminfo.rb', line 187 def efi_platform_size bits = File.read("/sys/firmware/efi/fw_platform_size").to_i log.info "EFI platform size: #{bits}" bits rescue StandardError 0 end |
.efi_supported? ⇒ Boolean
Check if UEFI is available on this system.
It need not currently be used. It should just be possible to put the system into UEFI mode.
130 131 132 |
# File 'src/lib/bootloader/systeminfo.rb', line 130 def efi_supported? Yast::Arch.x86_64 || Yast::Arch.i386 || efi_mandatory? end |
.efi_used?(bootloader_name) ⇒ Boolean
Check if UEFI will be used.
param bootloader_name [String] bootloader name
120 121 122 |
# File 'src/lib/bootloader/systeminfo.rb', line 120 def efi_used?(bootloader_name) ["grub2-efi", "systemd-boot", "grub2-bls"].include?(bootloader_name) end |
.generic_mbr_available?(bootloader_name) ⇒ Boolean
Check if mbr configurable with a bootloader.
57 58 59 60 |
# File 'src/lib/bootloader/systeminfo.rb', line 57 def generic_mbr_available?(bootloader_name) (Yast::Arch.x86_64 || Yast::Arch.i386) && !["grub2-efi", "grub2-bls"].include?(bootloader_name) end |
.hiding_menu_supported?(bootloader_name) ⇒ Boolean
Check if hiding menu are supported
param bootloader_name [String] bootloader name
152 153 154 |
# File 'src/lib/bootloader/systeminfo.rb', line 152 def (bootloader_name) bootloader_name != "grub2-bls" end |
.loader_location_available?(bootloader_name) ⇒ Boolean
Check if loader location is configurable with a bootloader.
66 67 68 |
# File 'src/lib/bootloader/systeminfo.rb', line 66 def loader_location_available?(bootloader_name) (Yast::Arch.x86_64 || Yast::Arch.i386 || Yast::Arch.ppc) && bootloader_name == "grub2" end |
.nvram_available?(bootloader_name = nil) ⇒ Boolean
Check if the system is expected to have nvram - ie. update_nvram_active? makes a difference
91 92 93 |
# File 'src/lib/bootloader/systeminfo.rb', line 91 def nvram_available?(bootloader_name = nil) (bootloader_name ? efi_used?(bootloader_name) : efi_supported?) || Yast::Arch.ppc end |
.password_supported?(bootloader_name) ⇒ Boolean
Check if setting password is supported
param bootloader_name [String] bootloader name
168 169 170 |
# File 'src/lib/bootloader/systeminfo.rb', line 168 def password_supported?(bootloader_name) bootloader_name != "grub2-bls" end |
.ppc_secure_boot ⇒ Object
Return secure boot status on ppc
nil - no support 0 - disabled 1 - enabled in audit-only mode 2+ - enabled in enforcing mode
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
# File 'src/lib/bootloader/systeminfo.rb', line 257 def ppc_secure_boot # see bsc#1192764 result = nil return nil unless Yast::Arch.ppc begin result = File.read("/proc/device-tree/ibm,secure-boot") result = result.unpack1("N") log.info "reading ibm,secure-boot result #{result}" rescue StandardError => e log.info "reading ibm,secure-boot failed with #{e}" result = nil end result end |
.ppc_secure_boot_active? ⇒ Boolean
Check if secure boot is currently active on an ppc machine.
The 'real' state, not any config file setting.
294 295 296 297 |
# File 'src/lib/bootloader/systeminfo.rb', line 294 def ppc_secure_boot_active? # see bsc#1192764 ppc_secure_boot.to_i > 0 end |
.ppc_secure_boot_available? ⇒ Boolean
Check if secure boot is (in principle) available on an ppc machine.
276 277 278 279 |
# File 'src/lib/bootloader/systeminfo.rb', line 276 def ppc_secure_boot_available? # see bsc#1192764 !ppc_secure_boot.nil? end |
.ppc_secure_boot_supported? ⇒ Boolean
Check if secure boot is supported with the current setup.
285 286 287 |
# File 'src/lib/bootloader/systeminfo.rb', line 285 def ppc_secure_boot_supported? ppc_secure_boot_available? end |
.s390_secure_boot_active? ⇒ Boolean
Check if secure boot is currently active on an s390 machine.
The 'real' state, not any config file setting.
239 240 241 242 243 244 245 246 247 248 249 |
# File 'src/lib/bootloader/systeminfo.rb', line 239 def s390_secure_boot_active? return false unless Yast::Arch.s390 # see jsc#SLE-9425 res = File.read("/sys/firmware/ipl/secure", 1) log.info "s390 secure: #{res}" res == "1" rescue StandardError false end |
.s390_secure_boot_available? ⇒ Boolean
Check if secure boot is (in principle) available on an s390 machine.
210 211 212 213 214 215 216 217 218 219 220 |
# File 'src/lib/bootloader/systeminfo.rb', line 210 def s390_secure_boot_available? # see jsc#SLE-9425 return false unless Yast::Arch.s390 res = File.read("/sys/firmware/ipl/has_secure", 1) log.info "s390 has secure: #{res}" res == "1" rescue StandardError false end |
.s390_secure_boot_supported? ⇒ Boolean
Check if secure boot is supported with the current setup.
The catch here is that secure boot works only with SCSI disks.
228 229 230 231 232 |
# File 'src/lib/bootloader/systeminfo.rb', line 228 def s390_secure_boot_supported? return false unless Yast::Arch.s390 s390_secure_boot_available? && scsi?(zipl_device) end |
.scsi?(device) ⇒ Boolean
Check if device is a SCSI device.
param device [Y2Storage::Partition, NilClass] partition device (or nil)
318 319 320 321 322 323 324 325 |
# File 'src/lib/bootloader/systeminfo.rb', line 318 def scsi?(device) # checking if device name starts with 'sd' is not enough: it could # be a device mapper target (e.g. multipath) # see bsc#1171821 device.name.start_with?("/dev/sd") || device.udev_ids.any?(/^scsi-/) rescue StandardError false end |
.secure_boot_active? ⇒ Boolean
Check current secure boot state.
This reflects settings on OS level. If secure boot is not supported, it returns false.
23 24 25 26 |
# File 'src/lib/bootloader/systeminfo.rb', line 23 def secure_boot_active? secure_boot_supported? && Sysconfig.from_system.secure_boot end |
.secure_boot_available?(bootloader_name) ⇒ Boolean
Check if secure boot is configurable with a bootloader.
44 45 46 47 48 49 50 51 |
# File 'src/lib/bootloader/systeminfo.rb', line 44 def secure_boot_available?(bootloader_name) # no shim for i386 (yet) return false if efi_arch == "i386" # no shim neither secure boot support for 32 bit arm nor riscv64 (bsc#1229070) return false if Yast::Arch.arm || Yast::Arch.riscv64 efi_used?(bootloader_name) || s390_secure_boot_available? || ppc_secure_boot_available? end |
.secure_boot_supported? ⇒ Boolean
Check if secure boot is in principle supported.
31 32 33 34 35 36 37 38 |
# File 'src/lib/bootloader/systeminfo.rb', line 31 def secure_boot_supported? # no shim for i386 (yet) return false if efi_arch == "i386" # no shim neither secure boot support for 32 bit arm nor riscv64 (bsc#1229070) return false if Yast::Arch.arm || Yast::Arch.riscv64 efi_supported? || s390_secure_boot_supported? || ppc_secure_boot_supported? end |
.shim_needed?(bootloader_name, secure_boot) ⇒ Boolean
Check if shim-install should be used instead of grub2-install.
param bootloader_name [String] bootloader name param secure_boot [Boolean] secure boot setting
177 178 179 180 |
# File 'src/lib/bootloader/systeminfo.rb', line 177 def shim_needed?(bootloader_name, secure_boot) (Yast::Arch.x86_64 || Yast::Arch.i386 || Yast::Arch.aarch64) && secure_boot && efi_used?(bootloader_name) end |
.trusted_boot_active? ⇒ Boolean
Check current trusted boot state.
ATM this just returns the config file setting.
84 85 86 87 88 |
# File 'src/lib/bootloader/systeminfo.rb', line 84 def trusted_boot_active? # FIXME: this should probably be a real check as in Grub2Widget#validate # and then Grub2Widget#validate could use Systeminfo.trusted_boot_active? Sysconfig.from_system.trusted_boot end |
.trusted_boot_available?(bootloader_name) ⇒ Boolean
Check if trusted boot is configurable with a bootloader.
param bootloader_name [String] bootloader name
103 104 105 106 107 108 109 110 111 112 113 114 |
# File 'src/lib/bootloader/systeminfo.rb', line 103 def trusted_boot_available?(bootloader_name) # TPM availability is must have return false unless File.exist?("/dev/tpm0") # not for grub2-bls return false if bootloader_name == "grub2-bls" # for details about grub2 efi trusted boot support see FATE#315831 ( bootloader_name == "grub2" && (Yast::Arch.x86_64 || Yast::Arch.i386) ) || bootloader_name == "grub2-efi" end |
.update_nvram_active? ⇒ Boolean
95 96 97 |
# File 'src/lib/bootloader/systeminfo.rb', line 95 def update_nvram_active? Sysconfig.from_system.update_nvram end |
.writable_efivars? ⇒ Boolean
Checks if efivars exists and can be written The point here is that without writable UEFI variables the UEFI boot manager cannot (and must not) be updated.
338 339 340 341 |
# File 'src/lib/bootloader/systeminfo.rb', line 338 def writable_efivars? storage_arch = Y2Storage::Arch.new storage_arch.efiboot? && storage_arch.efibootmgr? end |
.zipl_device ⇒ Y2Storage::Partition, NilClass
The partition where zipl is installed.
302 303 304 305 306 307 308 309 310 311 |
# File 'src/lib/bootloader/systeminfo.rb', line 302 def zipl_device staging = Y2Storage::StorageManager.instance.staging mountpoint = Y2Storage::MountPoint.find_by_path(staging, "/boot/zipl").first || Y2Storage::MountPoint.find_by_path(staging, "/boot").first || Y2Storage::MountPoint.find_by_path(staging, "/").first mountpoint.filesystem.blk_devices.first rescue StandardError nil end |