Skip to content

Commit

Permalink
Merge pull request #394 from ancorgs/merge_before_fix_pmbr
Browse files Browse the repository at this point in the history
Sync storage-ng branch with master
  • Loading branch information
ancorgs committed Dec 20, 2016
2 parents e7b9c92 + f74a87d commit b46d3ee
Show file tree
Hide file tree
Showing 14 changed files with 312 additions and 12 deletions.
30 changes: 30 additions & 0 deletions package/yast2-bootloader.changes
@@ -1,10 +1,40 @@
-------------------------------------------------------------------
Mon Dec 5 13:58:33 UTC 2016 - jreidinger@suse.com

- stop failing with new cfa ( caused by deleting nil, change
in cfa needed for bsc#983486 )

-------------------------------------------------------------------
Wed Nov 30 08:36:28 UTC 2016 - jreidinger@suse.com

- Recommends syslinux as it is often used by generic_mbr, but it
is not hard requirement (bsc#1004229)

-------------------------------------------------------------------
Tue Nov 22 18:38:42 UTC 2016 - jreidinger@suse.com

- Do not crash in bootloader when default mount by is set to label
(bsc#1009493)

-------------------------------------------------------------------
Tue Nov 22 16:52:31 UTC 2016 - ancor@suse.com

- storage-ng: fixed minimal EFI proposal
- storage-ng: made minimal legacy proposal work
- 3.3.1

-------------------------------------------------------------------
Tue Nov 22 13:41:42 UTC 2016 - jreidinger@suse.com

- use proper sources when doing kexec (bsc#981434)

-------------------------------------------------------------------
Wed Nov 16 14:19:14 UTC 2016 - jreidinger@suse.com

- when protecting modification of kernel parameters by password,
add also rd.shell=0 parameter to avoid getting into initrd shell
(bsc#1009220)

-------------------------------------------------------------------
Mon Nov 14 14:21:16 UTC 2016 - lslezak@suse.cz

Expand Down
5 changes: 5 additions & 0 deletions package/yast2-bootloader.spec
Expand Up @@ -50,6 +50,11 @@ Requires: augeas-lenses

Requires: yast2-ruby-bindings >= 1.0.0

# only recommend syslinux, as it is not needed when generic mbr is not used (bsc#1004229)
%ifarch %ix86 x86_64
Recommends: syslinux
%endif

Summary: YaST2 - Bootloader Configuration
License: GPL-2.0+
Group: System/YaST
Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/device_map.rb
Expand Up @@ -102,7 +102,7 @@ def reduce_to_bios_limit

other_devices_size = size - grub_devices.size

(BIOS_LIMIT - other_devices_size..grub_devices.size).each do |index|
(BIOS_LIMIT - other_devices_size..(grub_devices.size - 1)).each do |index|
remove_mapping(grub_devices[index])
end

Expand Down
8 changes: 7 additions & 1 deletion src/lib/bootloader/grub2_widgets.rb
Expand Up @@ -2,6 +2,7 @@

require "bootloader/generic_widgets"
require "bootloader/device_map_dialog"
require "cfa/matcher"

Yast.import "BootStorage"
Yast.import "Initrd"
Expand Down Expand Up @@ -409,6 +410,8 @@ def handle(event)

def store
usepass = Yast::UI.QueryWidget(Id(:use_pas), :Value)
matcher = CFA::Matcher.new(key: "rd.shell")
grub_default.kernel_params.remove_parameter(matcher)
if !usepass
password.used = false
return
Expand All @@ -421,6 +424,7 @@ def store
password.password = value if value != MASKED_PASSWORD

value = Yast::UI.QueryWidget(Id(:unrestricted_pw), :Value)
grub_default.kernel_params.add_parameter("rd.shell", "0") if value
password.unrestricted = value
end

Expand All @@ -430,7 +434,9 @@ def help
"At boot time, modifying or even booting any entry will require the" \
" password. If <b>Protect Entry Modification Only</b> is checked then " \
"booting any entry is not restricted but modifying entries requires " \
"the password (which is the way GRUB 1 behaved).<br>" \
"the password (which is the way GRUB 1 behaved). As side-effect of " \
"this option, rd.shell=0 is added to kernel parameters, to prevent " \
"an unauthorized access to the initrd shell.<br>" \
"YaST will only accept the password if you repeat it in " \
"<b>Retype Password</b>. The password applies to the GRUB2 user 'root' " \
"which is distinct from the Linux 'root'. YaST currently does not support" \
Expand Down
4 changes: 2 additions & 2 deletions src/lib/bootloader/kexec.rb
Expand Up @@ -99,8 +99,8 @@ def copy_kernel
cmd = Yast::Builtins.sformat(
"/bin/cp -L %1/%2 %1/%3 %4",
Yast::Installation.destdir,
"vmlinuz",
"initrd",
"boot/vmlinuz",
"boot/initrd",
Yast::Directory.vardir
)

Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/sections.rb
Expand Up @@ -32,7 +32,7 @@ def default
end

# Sets default section internally.
# @param [String] new boot title to boot
# @param [String] value of new boot title to boot
# @note to write it to system use #write later
def default=(value)
log.info "set new default to '#{value.inspect}'"
Expand Down
4 changes: 2 additions & 2 deletions src/lib/bootloader/stage1_device.rb
Expand Up @@ -24,7 +24,7 @@ def initialize(device)
@intended_device = device
end

# @returns [Array<String>] list of devices where stage1 need to be installed
# @return [Array<String>] list of devices where stage1 need to be installed
# to fit the best intended device. Devices used kernel device names, so no
# udev names
def real_devices
Expand All @@ -44,7 +44,7 @@ def devicegraph
end

# underlaying_devices without any caching
# @see {#underlaying_devices}
# @see #underlaying_devices
def underlaying_devices_for(dev)
res = underlaying_devices_one_level(dev)

Expand Down
2 changes: 1 addition & 1 deletion src/lib/bootloader/stage1_proposal.rb
Expand Up @@ -8,7 +8,7 @@
module Bootloader
# Represents object that can set passed stage1 to proposed values.
# It is highly coupled with Stage1 class and it is recommended to use
# {Stage1#proposal} instead of direct usage of this class.
# {Bootloader::Stage1#propose} instead of direct usage of this class.
class Stage1Proposal
include Yast::Logger

Expand Down
6 changes: 6 additions & 0 deletions src/lib/bootloader/udev_mapping.rb
Expand Up @@ -58,6 +58,12 @@ def to_mountby_device(dev)
# explicit request to mount by kernel device
return kernel_dev if mount_by == :device
disk = Yast::Storage.GetTargetMap.key?(kernel_dev)
if disk && mount_by == :label
log.info "mount by label for disk, so using kernel device as fallback"
return kernel_dev
end
udev_data_key = MOUNT_BY_MAPPING_TO_UDEV[mount_by]
raise "Internal error unknown mountby #{mount_by}" unless udev_data_key
udev_pair = map_device_to_udev_devices(
Expand Down
7 changes: 3 additions & 4 deletions src/modules/Bootloader.rb
Expand Up @@ -298,7 +298,7 @@ def getDefaultSection
# Gets value for given parameter in kernel parameters for given flavor.
# @param [Symbol] flavor flavor of kernel, for possible values see #modify_kernel_param
# @param [String] key of parameter on kernel command line
# @returns [String,:missing,:present] Returns string for parameters with value,
# @return [String,:missing,:present] Returns string for parameters with value,
# `:missing` if key is not there and `:present` for parameters without value.
#
# @example get crashkernel parameter to common kernel
Expand Down Expand Up @@ -455,9 +455,8 @@ def mark_as_changed

NONSPLASH_VGA_VALUES = ["", "false", "ask"].freeze

# store new vgamode if needed and regenerate initrd in such case
# @param params_to_save used to store predefined vgamode value
# @return boolean if succeed
# regenerates initrd if needed
# @return boolean true if succeed
def write_initrd
return true unless Initrd.changed

Expand Down
211 changes: 211 additions & 0 deletions test/data/grub.cfg
@@ -0,0 +1,211 @@
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub2-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -f ${config_directory}/grubenv ]; then
load_env -f ${config_directory}/grubenv
elif [ -s $prefix/grubenv ]; then
load_env
fi

if [ "${env_block}" ] ; then
load_env -f "${env_block}"
fi

if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
if [ "${env_block}" ] ; then
save_env -f "${env_block}" next_entry
fi
set boot_once=true
else
set default="${saved_entry}"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
else
menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
set saved_entry="${prev_saved_entry}"
save_env saved_entry
set prev_saved_entry=
save_env prev_saved_entry
set boot_once=true
fi

function savedefault {
if [ -z "${boot_once}" ]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}

function load_video {
if [ x$feature_all_video_module = xy ]; then
insmod all_video
else
insmod efi_gop
insmod efi_uga
insmod ieee1275_fb
insmod vbe
insmod vga
insmod video_bochs
insmod video_cirrus
fi
}

if [ x$feature_default_font_path = xy ] ; then
font=unicode
else
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' b66c1028-cd4a-4c08-b92d-fc4b9840845d
else
search --no-floppy --fs-uuid --set=root b66c1028-cd4a-4c08-b92d-fc4b9840845d
fi
font="/usr/share/grub2/unicode.pf2"
fi

if loadfont $font ; then
set gfxmode=auto
load_video
insmod gfxterm
set locale_dir=$prefix/locale
set lang=ru_RU
insmod gettext
fi
terminal_output gfxterm
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' b66c1028-cd4a-4c08-b92d-fc4b9840845d
else
search --no-floppy --fs-uuid --set=root b66c1028-cd4a-4c08-b92d-fc4b9840845d
fi
insmod gfxmenu
loadfont ($root)/boot/grub2/themes/openSUSE/ascii.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans10.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans12.pf2
loadfont ($root)/boot/grub2/themes/openSUSE/DejaVuSans-Bold14.pf2
insmod png
set theme=($root)/boot/grub2/themes/openSUSE/theme.txt
export theme
if [ x${boot_once} = xtrue ]; then
set timeout=0
elif [ x$feature_timeout_style = xy ] ; then
set timeout_style=menu
set timeout=8
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
set timeout=8
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/00_tuned ###
set tuned_params=""
### END /etc/grub.d/00_tuned ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'openSUSE Tumbleweed' --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-b66c1028-cd4a-4c08-b92d-fc4b9840845d' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' b66c1028-cd4a-4c08-b92d-fc4b9840845d
else
search --no-floppy --fs-uuid --set=root b66c1028-cd4a-4c08-b92d-fc4b9840845d
fi
echo 'Загружается Linux 4.8.6-2-default …'
linux /boot/vmlinuz-4.8.6-2-default root=UUID=b66c1028-cd4a-4c08-b92d-fc4b9840845d splash=silent quiet showopts elevator=cfq
echo 'Загружается начальный виртуальный диск …'
initrd /boot/initrd-4.8.6-2-default
}
submenu 'Дополнительные параметры для openSUSE Tumbleweed' --hotkey=1 $menuentry_id_option 'gnulinux-advanced-b66c1028-cd4a-4c08-b92d-fc4b9840845d' {
menuentry 'openSUSE Tumbleweed, с Linux 4.8.6-2-default' --hotkey=2 --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.8.6-2-default-advanced-b66c1028-cd4a-4c08-b92d-fc4b9840845d' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' b66c1028-cd4a-4c08-b92d-fc4b9840845d
else
search --no-floppy --fs-uuid --set=root b66c1028-cd4a-4c08-b92d-fc4b9840845d
fi
echo 'Загружается Linux 4.8.6-2-default …'
linux /boot/vmlinuz-4.8.6-2-default root=UUID=b66c1028-cd4a-4c08-b92d-fc4b9840845d splash=silent quiet showopts elevator=cfq
echo 'Загружается начальный виртуальный диск …'
initrd /boot/initrd-4.8.6-2-default
}
menuentry 'openSUSE Tumbleweed, с Linux 4.8.6-1-default' --class opensuse --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.8.6-1-default-advanced-b66c1028-cd4a-4c08-b92d-fc4b9840845d' {
load_video
set gfxpayload=keep
insmod gzio
insmod part_msdos
insmod ext2
set root='hd0,msdos1'
if [ x$feature_platform_search_hint = xy ]; then
search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' b66c1028-cd4a-4c08-b92d-fc4b9840845d
else
search --no-floppy --fs-uuid --set=root b66c1028-cd4a-4c08-b92d-fc4b9840845d
fi
echo 'Загружается Linux 4.8.6-1-default …'
linux /boot/vmlinuz-4.8.6-1-default root=UUID=b66c1028-cd4a-4c08-b92d-fc4b9840845d splash=silent quiet showopts elevator=cfq
echo 'Загружается начальный виртуальный диск …'
initrd /boot/initrd-4.8.6-1-default
}
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###

### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/20_memtest86+ ###
### END /etc/grub.d/20_memtest86+ ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/40_custom ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f ${config_directory}/custom.cfg ]; then
source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f $prefix/custom.cfg ]; then
source $prefix/custom.cfg;
fi
### END /etc/grub.d/41_custom ###

### BEGIN /etc/grub.d/80_suse_btrfs_snapshot ###
### END /etc/grub.d/80_suse_btrfs_snapshot ###

### BEGIN /etc/grub.d/90_persistent ###
### END /etc/grub.d/90_persistent ###

### BEGIN /etc/grub.d/95_textmode ###
### END /etc/grub.d/95_textmode ###

0 comments on commit b46d3ee

Please sign in to comment.