Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not crash if grub.cfg is missing #552

Merged
merged 1 commit into from
Feb 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions package/yast2-bootloader.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Thu Feb 14 07:56:05 UTC 2019 - jreidinger@suse.com

- Do not crash if generated grub.cfg is missing (bsc#1124064)
- 4.1.17

-------------------------------------------------------------------
Fri Feb 8 08:47:35 UTC 2019 - dgonzalez@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-bootloader.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-bootloader
Version: 4.1.16
Version: 4.1.17
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
5 changes: 2 additions & 3 deletions src/lib/bootloader/grub2base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ def read
begin
grub_cfg.load
rescue Errno::ENOENT
# raise error only outside of first stage, as there may not need to be
# grub.cfg generated (bnc#976534)
raise unless Yast::Stage.initial
# there may not need to be grub.cfg generated (bnc#976534),(bsc#1124064)
log.info "/boot/grub2/grub.cfg is missing. Defaulting to empty one."
end
@sections = ::Bootloader::Sections.new(grub_cfg)
log.info "grub sections: #{@sections.all}"
Expand Down
8 changes: 8 additions & 0 deletions test/grub2base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@
subject.read
end

it "use empty file as default if grub.cfg is missing" do
grub_cfg = double(::CFA::Grub2::GrubCfg)
allow(::CFA::Grub2::GrubCfg).to receive(:new).and_return(grub_cfg)
allow(grub_cfg).to receive(:load).and_raise(Errno::ENOENT)

expect { subject.read }.to_not raise_error
end

it "reads trusted boot configuration from sysconfig" do
mocked_sysconfig = ::Bootloader::Sysconfig.new(trusted_boot: true)
allow(::Bootloader::Sysconfig).to receive(:from_system).and_return(mocked_sysconfig)
Expand Down