Hello community, here is the log from the commit of package yast2-bootloader for openSUSE:Factory checked in at 2014-03-01 14:38:21 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/yast2-bootloader (Old) and /work/SRC/openSUSE:Factory/.yast2-bootloader.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "yast2-bootloader" Changes: -------- --- /work/SRC/openSUSE:Factory/yast2-bootloader/yast2-bootloader.changes 2014-02-16 09:10:51.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.yast2-bootloader.new/yast2-bootloader.changes 2014-03-01 14:38:22.000000000 +0100 @@ -1,0 +2,8 @@ +Thu Feb 27 08:32:24 UTC 2014 - [email protected] + +- Add support for password in GRUB2 (FATE#315404) +- restructure details dialog in GRUB2 to have better UX +- fix crash of GRUB2 module +- 3.1.6 + +------------------------------------------------------------------- Old: ---- yast2-bootloader-3.1.5.tar.bz2 New: ---- yast2-bootloader-3.1.6.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ yast2-bootloader.spec ++++++ --- /var/tmp/diff_new_pack.THekCg/_old 2014-03-01 14:38:23.000000000 +0100 +++ /var/tmp/diff_new_pack.THekCg/_new 2014-03-01 14:38:23.000000000 +0100 @@ -17,13 +17,15 @@ Name: yast2-bootloader -Version: 3.1.5 +Version: 3.1.6 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build Source0: %{name}-%{version}.tar.bz2 +BuildRequires: rubygem-rspec BuildRequires: update-desktop-files +BuildRequires: yast2 >= 3.1.0 BuildRequires: yast2-devtools >= 3.1.10 PreReq: /bin/sed %fillup_prereq # Installation::*version variables @@ -31,7 +33,7 @@ Requires: parted Requires: perl-Bootloader-YAML Requires: perl-Compress-Zlib -Requires: yast2 >= 2.21.22 +Requires: yast2 >= 3.1.0 Requires: yast2-core >= 2.18.7 Requires: yast2-packager >= 2.17.24 Requires: yast2-pkg-bindings >= 2.17.25 @@ -90,6 +92,9 @@ %build %yast_build +%check +make check VERBOSE=1 + %install %yast_install @@ -125,6 +130,7 @@ %dir %{yast_schemadir}/autoyast %dir %{yast_schemadir}/autoyast/rnc %{yast_schemadir}/autoyast/rnc/bootloader.rnc +%{yast_libdir}/bootloader %dir %{yast_docdir} %doc %{yast_docdir}/COPYING ++++++ yast2-bootloader-3.1.5.tar.bz2 -> yast2-bootloader-3.1.6.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/SUBDIRS new/yast2-bootloader-3.1.6/SUBDIRS --- old/yast2-bootloader-3.1.5/SUBDIRS 2014-02-12 17:28:04.000000000 +0100 +++ new/yast2-bootloader-3.1.6/SUBDIRS 2014-02-27 16:13:28.000000000 +0100 @@ -1 +1 @@ -SUBDIRS = src scripts doc +SUBDIRS = src scripts doc test diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/package/yast2-bootloader.changes new/yast2-bootloader-3.1.6/package/yast2-bootloader.changes --- old/yast2-bootloader-3.1.5/package/yast2-bootloader.changes 2014-02-12 17:28:04.000000000 +0100 +++ new/yast2-bootloader-3.1.6/package/yast2-bootloader.changes 2014-02-27 16:13:28.000000000 +0100 @@ -1,4 +1,12 @@ ------------------------------------------------------------------- +Thu Feb 27 08:32:24 UTC 2014 - [email protected] + +- Add support for password in GRUB2 (FATE#315404) +- restructure details dialog in GRUB2 to have better UX +- fix crash of GRUB2 module +- 3.1.6 + +------------------------------------------------------------------- Wed Feb 12 10:18:39 UTC 2014 - [email protected] - rephrase bootloader proposal on summary screen (BNC#853058) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/package/yast2-bootloader.spec new/yast2-bootloader-3.1.6/package/yast2-bootloader.spec --- old/yast2-bootloader-3.1.5/package/yast2-bootloader.spec 2014-02-12 17:28:04.000000000 +0100 +++ new/yast2-bootloader-3.1.6/package/yast2-bootloader.spec 2014-02-27 16:13:28.000000000 +0100 @@ -17,7 +17,7 @@ Name: yast2-bootloader -Version: 3.1.5 +Version: 3.1.6 Release: 0 BuildRoot: %{_tmppath}/%{name}-%{version}-build @@ -26,11 +26,13 @@ Group: System/YaST License: GPL-2.0+ BuildRequires: yast2-devtools >= 3.1.10 +BuildRequires: yast2 >= 3.1.0 BuildRequires: update-desktop-files +BuildRequires: rubygem-rspec PreReq: /bin/sed %fillup_prereq # Installation::*version variables # Wizard::SetDialogTitleAndIcon -Requires: yast2 >= 2.21.22 +Requires: yast2 >= 3.1.0 Requires: yast2-packager >= 2.17.24 Requires: yast2-pkg-bindings >= 2.17.25 Requires: perl-Bootloader-YAML @@ -74,6 +76,9 @@ %build %yast_build +%check +make check VERBOSE=1 + %install %yast_install @@ -110,6 +115,7 @@ %dir %{yast_schemadir}/autoyast %dir %{yast_schemadir}/autoyast/rnc %{yast_schemadir}/autoyast/rnc/bootloader.rnc +%{yast_libdir}/bootloader %dir %{yast_docdir} %doc %{yast_docdir}/COPYING diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/src/Makefile.am new/yast2-bootloader-3.1.6/src/Makefile.am --- old/yast2-bootloader-3.1.5/src/Makefile.am 2014-02-12 17:28:04.000000000 +0100 +++ new/yast2-bootloader-3.1.6/src/Makefile.am 2014-02-27 16:13:28.000000000 +0100 @@ -74,6 +74,11 @@ include/bootloader/ppc/dialogs.rb \ include/bootloader/ppc/helps.rb +ylibdir = "${yast2dir}/lib/bootloader" +ylib_DATA = \ + lib/bootloader/grub2base.rb \ + lib/bootloader/grub2pwd.rb + scrconf_DATA = \ scrconf/cfg_bootloader.scr \ scrconf/cfg_bootsplash.scr \ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/src/include/bootloader/grub/options.rb new/yast2-bootloader-3.1.6/src/include/bootloader/grub/options.rb --- old/yast2-bootloader-3.1.5/src/include/bootloader/grub/options.rb 2014-02-12 17:28:04.000000000 +0100 +++ new/yast2-bootloader-3.1.6/src/include/bootloader/grub/options.rb 2014-02-27 16:13:28.000000000 +0100 @@ -247,6 +247,24 @@ false end + def passwd_content + HBox( + CheckBoxFrame( + Id(:use_pas), + _("Prot&ect Boot Loader with Password"), + true, + HBox( + HSpacing(2), + # text entry + Password(Id(:pw1), Opt(:hstretch), _("&Password")), + # text entry + HSpacing(2), + Password(Id(:pw2), Opt(:hstretch), _("Re&type Password")), + HStretch() + ) + ) + ) + end # Build a map describing a widget @@ -255,22 +273,7 @@ { "widget" => :custom, # frame - "custom_widget" => HBox( - CheckBoxFrame( - Id(:use_pas), - _("Prot&ect Boot Loader with Password"), - true, - HBox( - HSpacing(2), - # text entry - Password(Id(:pw1), Opt(:hstretch), _("&Password")), - # text entry - HSpacing(2), - Password(Id(:pw2), Opt(:hstretch), _("Re&type Password")), - HStretch() - ) - ) - ), + "custom_widget" => passwd_content, "init" => fun_ref( method(:InitPasswdWidget), "void (string)" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/src/include/bootloader/grub2/dialogs.rb new/yast2-bootloader-3.1.6/src/include/bootloader/grub2/dialogs.rb --- old/yast2-bootloader-3.1.5/src/include/bootloader/grub2/dialogs.rb 2014-02-12 17:28:04.000000000 +0100 +++ new/yast2-bootloader-3.1.6/src/include/bootloader/grub2/dialogs.rb 2014-02-27 16:13:28.000000000 +0100 @@ -25,6 +25,7 @@ Yast.import "Label" Yast.import "Wizard" Yast.import "CWM" + Yast.import "CWMTab" Yast.import "BootCommon" Yast.import "Stage" @@ -37,60 +38,84 @@ @_grub2_efi_widgets = nil end + def boot_code_tab + lt = BootCommon.getLoaderType(false) + + { + "id" => "boot_code_tab", + "header" => _("Boot Code Options"), + # if name is not included, that it is not displayed + "widget_names" => lt == "grub2-efi" ? ["distributor"] : + ["distributor", "activate", "generic_mbr"], + "contents" => VBox( + VSpacing(1), + MarginBox(1, 0.5, "distributor"), + MarginBox(1, 0.5, Left("activate")), + MarginBox(1, 0.5, Left("generic_mbr")), + VStretch() + ) + } + end + + def kernel_tab + { + "id" => "kernel_tab", + "header" => _("Kernel Parameters"), + "widget_names" => ["vgamode", "append", "append_failsafe", "console"], + "contents" => VBox( + VSpacing(1), + MarginBox(1, 0.5, "vgamode"), + MarginBox(1, 0.5, "append"), + MarginBox(1, 0.5, "append_failsafe"), + MarginBox(1, 0.5, "console"), + VStretch() + ) + } + end + + def bootloader_tab + { + "id" => "bootloader_tab", + "header" => _("Bootloader Options"), + "widget_names" => ["default", "timeout", "password", "os_prober", "hiddenmenu"], + "contents" => VBox( + VSpacing(2), + HBox( + HSpacing(1), + "timeout", + HSpacing(1), + Left(VBox( "os_prober", "hiddenmenu")), + HSpacing(1) + ), + MarginBox(1, 1, "default"), + MarginBox(1, 1, "password"), + VStretch() + ) + } + end + # Run dialog for loader installation details for Grub2 # @return [Symbol] for wizard sequencer def Grub2LoaderDetailsDialog Builtins.y2milestone("Running Grub2 loader details dialog") - contents = HBox( - HSpacing(2), - VBox( - VStretch(), - HBox(HSquash("distributor"), "hiddenmenu", "os_prober", HStretch()), - HBox("activate", "generic_mbr", HStretch()), - HBox(HSquash("timeout"), "vgamode", HStretch()), - Left("append"), - Left("append_failsafe"), - Left("default"), - Left("console"), - Left("gfxterm"), - VStretch() - ), - HSpacing(2) - ) + widgets = Grub2Options() - lt = BootCommon.getLoaderType(false) - widget_names = lt == "grub2-efi" ? - [ - "distributor", - "hiddenmenu", - "os_prober", - "timeout", - "append", - "append_failsafe", - "console", - "default", - "vgamode" - ] : - [ - "distributor", - "activate", - "generic_mbr", - "hiddenmenu", - "os_prober", - "timeout", - "append", - "append_failsafe", - "console", - "default", - "vgamode" - ] + tabs = [ bootloader_tab, kernel_tab, boot_code_tab] + + tab_widget = CWMTab.CreateWidget({ + "tab_order" => tabs.map{ |t| t["id"] }, + "tabs" => Hash[tabs.map{|tab| [tab["id"], tab]}], + "initial_tab" => tabs.first["id"], + "widget_descr" => widgets + }) + widgets["tab"] = tab_widget caption = _("Boot Loader Options") CWM.ShowAndRun( { - "widget_descr" => Grub2Options(), - "widget_names" => widget_names, - "contents" => contents, + "widget_descr" => widgets, + "widget_names" => ["tab"], + "contents" => VBox("tab"), "caption" => caption, "back_button" => Label.BackButton, "abort_button" => Label.CancelButton, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/src/include/bootloader/grub2/options.rb new/yast2-bootloader-3.1.6/src/include/bootloader/grub2/options.rb --- old/yast2-bootloader-3.1.5/src/include/bootloader/grub2/options.rb 2014-02-12 17:28:04.000000000 +0100 +++ new/yast2-bootloader-3.1.6/src/include/bootloader/grub2/options.rb 2014-02-27 16:13:28.000000000 +0100 @@ -18,6 +18,9 @@ # # $Id: BootGRUB.ycp 63508 2011-03-04 12:53:27Z jreidinger $ # + +require "bootloader/grub2pwd" + module Yast module BootloaderGrub2OptionsInclude def initialize_bootloader_grub2_options(include_target) @@ -225,6 +228,95 @@ nil end + def ConsoleContent + VBox( + CheckBoxFrame( + Id(:gfxterm_frame), + _("Use &graphical console"), + true, + HBox( + HSpacing(2), + ComboBox( + Id(:gfxmode), + Opt(:editable, :hstretch), + _("&Console resolution"), + [""] + ), + HBox( + Left( + InputField( + Id(:gfxtheme), + Opt(:hstretch), + _("&Console theme") + ) + ), + VBox( + Left(Label("")), + Left( + PushButton( + Id(:browsegfx), + Opt(:notify), + Label.BrowseButton + ) + ) + ) + ), + HStretch() + ) + ), + CheckBoxFrame( + Id(:console_frame), + _("Use &serial console"), + true, + HBox( + HSpacing(2), + InputField( + Id(:console_args), + Opt(:hstretch), + _("&Console arguments") + ), + HStretch() + ) + ) + ) + end + + MASKED_PASSWORD = "**********" + + def grub2_pwd_store(key, event) + usepass = UI.QueryWidget(Id(:use_pas), :Value) + if !usepass + # we are in proper module that can store password + self.password = nil + return + end + + value = UI.QueryWidget(Id(:pw1), :Value) + # special value as we do not know password, so it mean user do not change it + if value == MASKED_PASSWORD + self.password = "" + else + self.password = value + end + end + + def grub2_pwd_init(widget) + passwd = GRUB2Pwd.new.used? + if passwd + UI.ChangeWidget(Id(:use_pas), :Value, true) + UI.ChangeWidget(Id(:pw1), :Enabled, true) + UI.ChangeWidget(Id(:pw1), :Value, MASKED_PASSWORD) + UI.ChangeWidget(Id(:pw2), :Enabled, true) + UI.ChangeWidget(Id(:pw2), :Value, MASKED_PASSWORD) + else + UI.ChangeWidget(Id(:use_pas), :Value, false) + UI.ChangeWidget(Id(:pw1), :Enabled, false) + UI.ChangeWidget(Id(:pw1), :Value, "") + UI.ChangeWidget(Id(:pw2), :Enabled, false) + UI.ChangeWidget(Id(:pw2), :Value, "") + end + end + def Grub2Options grub2_specific = { "distributor" => CommonInputFieldWidget( @@ -273,56 +365,7 @@ }, "console" => { "widget" => :custom, - "custom_widget" => VBox( - CheckBoxFrame( - Id(:gfxterm_frame), - _("Use &graphical console"), - true, - HBox( - HSpacing(2), - ComboBox( - Id(:gfxmode), - Opt(:editable, :hstretch), - _("&Console resolution"), - [""] - ), - HBox( - Left( - InputField( - Id(:gfxtheme), - Opt(:hstretch), - _("&Console theme") - ) - ), - VBox( - Left(Label("")), - Left( - PushButton( - Id(:browsegfx), - Opt(:notify), - Label.BrowseButton - ) - ) - ) - ), - HStretch() - ) - ), - CheckBoxFrame( - Id(:console_frame), - _("Use &serial console"), - true, - HBox( - HSpacing(2), - InputField( - Id(:console_args), - Opt(:hstretch), - _("&Console arguments") - ), - HStretch() - ) - ) - ), + "custom_widget" => ConsoleContent(), "init" => fun_ref(method(:ConsoleInit), "void (string)"), "store" => fun_ref( method(:ConsoleStore), @@ -334,6 +377,28 @@ ), "handle_events" => [:browsegfx], "help" => Ops.get(@grub_help_messages, "serial", "") + }, + "password" => { + "widget" => :custom, + "custom_widget" => passwd_content, + "init" => fun_ref( + method(:grub2_pwd_init), + "void (string)" + ), + "handle" => fun_ref( + method(:HandlePasswdWidget), + "symbol (string, map)" + ), + "store" => fun_ref( + method(:grub2_pwd_store), + "void (string, map)" + ), + "validate_type" => :function, + "validate_function" => fun_ref( + method(:ValidatePasswdWidget), + "boolean (string, map)" + ), + "help" => @grub_help_messages["password"] || "" } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/src/lib/bootloader/grub2base.rb new/yast2-bootloader-3.1.6/src/lib/bootloader/grub2base.rb --- old/yast2-bootloader-3.1.5/src/lib/bootloader/grub2base.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-bootloader-3.1.6/src/lib/bootloader/grub2base.rb 2014-02-27 16:13:28.000000000 +0100 @@ -0,0 +1,150 @@ +# encoding: utf-8 +require "yast" +require "bootloader/grub2pwd" + +module Yast + class GRUB2Base < Module + def main + Yast.import "UI" + + textdomain "bootloader" + + Yast.import "BootArch" + Yast.import "BootCommon" + Yast.import "BootStorage" + Yast.import "Kernel" + Yast.import "Mode" + Yast.import "Stage" + Yast.import "Storage" + Yast.import "StorageDevices" + Yast.import "Pkg" + Yast.import "HTML" + Yast.import "Initrd" + Yast.import "Product" + + # includes + # for simplified widgets than other + Yast.include self, "bootloader/grub2/dialogs.rb" + + # password can have three states + # 1. nil -> remove password + # 2. "" -> do not change it + # 3. "something" -> set password to this value + @password = "" + end + + # general functions + + # Propose global options of bootloader + def StandardGlobals + { + "timeout" => "8", + "default" => "0", + "vgamode" => "", + "gfxmode" => "auto", + "terminal" => "gfxterm", + "os_prober" => "true" + } + end + + # Update read settings to new version of configuration files + def Update + Read(true, true) + + #we don't handle sections, grub2 section create them for us + #BootCommon::UpdateSections (); + BootCommon.UpdateGlobals + + nil + end + + # Reset bootloader settings + # @param [Boolean] init boolean true to repropose also device map + def Reset(init) + return if Mode.autoinst + BootCommon.Reset(init) + + nil + end + + def Dialogs + Builtins.y2milestone("Called GRUB2 Dialogs") + { + "installation" => fun_ref( + method(:Grub2InstallDetailsDialog), + "symbol ()" + ), + "loader" => fun_ref( + method(:Grub2LoaderDetailsDialog), + "symbol ()" + ) + } + end + + def Propose + if BootCommon.was_proposed + # workaround autoyast config is Imported thus was_proposed always set + if Mode.autoinst + Builtins.y2milestone( + "autoinst mode we ignore meaningless was_proposed as it always set" + ) + else + Builtins.y2milestone( + "calling Propose with was_proposed set is really bogus, clear it to force a re-propose" + ) + return + end + end + + + BootCommon.globals ||= Hash.new + BootCommon.globals.merge! StandardGlobals() + + swap_parts = BootCommon.getSwapPartitions + largest_swap_part = swap_parts.max_by{|part, size| size}.first || "" + + resume = BootArch.ResumeAvailable ? largest_swap_part : "" + # try to use label or udev id for device name... FATE #302219 + if resume != "" && resume != nil + resume = BootStorage.Dev2MountByDev(resume) + end + + BootCommon.globals["append"] = BootArch.DefaultKernelParams(resume) + BootCommon.globals["append_failsafe"] = BootArch.FailsafeKernelParams + BootCommon.globals["distributor"] = Product.name + BootCommon.kernelCmdLine = Kernel.GetCmdLine + + Builtins.y2milestone("Proposed globals: %1", BootCommon.globals) + + nil + end + + # overwrite Save to allow generation of modification scripts + def Save(clean, init, flush) + case @password + when nil + GRUB2Pwd.new.disable + when "" + #do nothing + else + GRUB2Pwd.new.enable @password + end + + BootCommon.Save(clean, init, flush) + end + + # Initializer of GRUB bootloader + def Initializer + Builtins.y2milestone("Called GRUB2 initializer") + BootCommon.current_bootloader_attribs = { + "propose" => false, + "read" => false, + "scratch" => false, + "restore_mbr" => false, + "bootloader_on_disk" => false + } + + nil + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/src/lib/bootloader/grub2pwd.rb new/yast2-bootloader-3.1.6/src/lib/bootloader/grub2pwd.rb --- old/yast2-bootloader-3.1.5/src/lib/bootloader/grub2pwd.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-bootloader-3.1.6/src/lib/bootloader/grub2pwd.rb 2014-02-27 16:13:28.000000000 +0100 @@ -0,0 +1,59 @@ +require "yast" + +class GRUB2Pwd + YAST_BASH_PATH = Yast::Path.new(".target.bash_output") + PWD_ENCRYPTION_FILE = "/etc/grub.d/42_password" + + def used? + Yast.import "FileUtils" + + Yast::FileUtils.Exists PWD_ENCRYPTION_FILE + end + + def enable(password) + enc_passwd = encrypt(password) + + file_content = "#! /bin/sh\n" + + "exec tail -n +3 $0\n" + + "# File created by YaST and next password change in YaST will overwrite it\n" + + "set superusers=\"root\"\n" + + "password_pbkdf2 root #{enc_passwd}\n" + + "export superusers" + + Yast::SCR.Write( + Yast::Path.new(".target.string"), + [PWD_ENCRYPTION_FILE, 0755], + file_content + ) + end + + def disable + return unless used? + + Yast::SCR.Execute(YAST_BASH_PATH, "rm '#{PWD_ENCRYPTION_FILE}'") + end + +private + + def encrypt(password) + result = Yast::SCR.Execute(YAST_BASH_PATH, + "echo -e \"#{password}\\n#{password}\" | grub2-mkpasswd-pbkdf2" + ) + + if result["exit"] != 0 + raise "Failed to create encrypted password for grub2. Command output: #{result["stderr"]}" + end + + pwd_line = result["stdout"].split("\n").grep(/password is/).first + if !pwd_line + raise "INTERNAL ERROR: output do not contain encrypted password. Output: #{result["stdout"]}" + end + + ret = pwd_line[/^.*password is\s*(\S+)/,1] + if !ret + raise "INTERNAL ERROR: output do not contain encrypted password. Output: #{result["stdout"]}" + end + + return ret + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/src/modules/BootCommon.rb new/yast2-bootloader-3.1.6/src/modules/BootCommon.rb --- old/yast2-bootloader-3.1.5/src/modules/BootCommon.rb 2014-02-12 17:28:04.000000000 +0100 +++ new/yast2-bootloader-3.1.6/src/modules/BootCommon.rb 2014-02-27 16:13:28.000000000 +0100 @@ -996,10 +996,6 @@ Builtins.y2milestone( "It is XEN domU and the bootloader should be installed" ) - # bnc #766283 - opensuse 12.2 pv guests can not start after installation - # due to lack of grub2 support in the host - # fallback to use grub until grub2 really works on it - @loader_type = "grub" if @loader_type == "grub2" end if (Arch.i386 || Arch.x86_64) && Linuxrc.InstallInf("EFI") == "1" # use grub2-efi as default bootloader for x86_64/i386 EFI diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/src/modules/BootGRUB2.rb new/yast2-bootloader-3.1.6/src/modules/BootGRUB2.rb --- old/yast2-bootloader-3.1.5/src/modules/BootGRUB2.rb 2014-02-12 17:28:04.000000000 +0100 +++ new/yast2-bootloader-3.1.6/src/modules/BootGRUB2.rb 2014-02-27 16:13:28.000000000 +0100 @@ -19,49 +19,21 @@ # $Id: BootGRUB.ycp 63508 2011-03-04 12:53:27Z jreidinger $ # require "yast" +require "bootloader/grub2base" module Yast - class BootGRUB2Class < Module + class BootGRUB2Class < GRUB2Base def main - Yast.import "UI" - - textdomain "bootloader" - - Yast.import "BootArch" - Yast.import "BootCommon" - Yast.import "BootStorage" - Yast.import "Kernel" - Yast.import "Mode" - Yast.import "Stage" - Yast.import "Storage" - Yast.import "StorageDevices" - Yast.import "Pkg" - Yast.import "HTML" - Yast.import "Initrd" - Yast.import "Product" + super # includes # for shared some routines with grub Yast.include self, "bootloader/grub2/misc.rb" - # for simplified widgets than other - Yast.include self, "bootloader/grub2/dialogs.rb" BootGRUB2() end # general functions - # Propose global options of bootloader - def StandardGlobals - { - "timeout" => "8", - "default" => "0", - "vgamode" => "", - "gfxmode" => "auto", - "terminal" => "gfxterm", - "os_prober" => "true" - } - end - # Read settings from disk # @param [Boolean] reread boolean true to force reread settings from system # @param [Boolean] avoid_reading_device_map do not read new device map from file, use @@ -109,16 +81,6 @@ ret end - # Update read settings to new version of configuration files - def Update - Read(true, true) - - #we don't handle sections, grub2 section create them for us - #BootCommon::UpdateSections (); - BootCommon.UpdateGlobals - - nil - end # Write bootloader settings to disk # @return [Boolean] true on success def Write @@ -141,87 +103,9 @@ ret end - # Reset bootloader settings - # @param [Boolean] init boolean true to repropose also device map - def Reset(init) - return if Mode.autoinst - BootCommon.Reset(init) - - nil - end - - # Propose bootloader settings - def Propose - if BootCommon.was_proposed - # workaround autoyast config is Imported thus was_proposed always set - if Mode.autoinst - Builtins.y2milestone( - "autoinst mode we ignore meaningless was_proposed as it always set" - ) - else - Builtins.y2milestone( - "calling Propose with was_proposed set is really bogus, clear it to force a re-propose" - ) - return - end - end - - if BootCommon.globals == nil || Builtins.size(BootCommon.globals) == 0 - BootCommon.globals = StandardGlobals() - else - BootCommon.globals = Convert.convert( - Builtins.union(BootCommon.globals, StandardGlobals()), - :from => "map", - :to => "map <string, string>" - ) - end - - grub_LocationProposal - - swap_sizes = BootCommon.getSwapPartitions - swap_parts = Builtins.maplist(swap_sizes) { |name, size| name } - swap_parts = Builtins.sort(swap_parts) do |a, b| - Ops.greater_than(Ops.get(swap_sizes, a, 0), Ops.get(swap_sizes, b, 0)) - end - - largest_swap_part = Ops.get(swap_parts, 0, "") - - resume = BootArch.ResumeAvailable ? largest_swap_part : "" - # try to use label or udev id for device name... FATE #302219 - if resume != "" && resume != nil - resume = BootStorage.Dev2MountByDev(resume) - end - Ops.set( - BootCommon.globals, - "append", - BootArch.DefaultKernelParams(resume) - ) - Ops.set( - BootCommon.globals, - "append_failsafe", - BootArch.FailsafeKernelParams - ) - Ops.set( - BootCommon.globals, - "distributor", - Ops.add(Ops.add(Product.short_name, " "), Product.version) - ) - BootCommon.kernelCmdLine = Kernel.GetCmdLine - - Builtins.y2milestone("Proposed globals: %1", BootCommon.globals) - - # Let grub2 scripts detects correct root= for us. :) - # BootCommon::globals["root"] = BootStorage::Dev2MountByDev(BootStorage::RootPartitionDevice); - - # We don't set vga= if Grub2 gfxterm enabled, because the modesettings - # will be delivered to kernel by Grub2's gfxpayload set to "keep" - #if (BootArch::VgaAvailable () && Kernel::GetVgaType () != "") - #{ - # BootCommon::globals["vgamode"] = Kernel::GetVgaType (); - #} - - nil + super + grub_LocationProposal if !BootCommon.was_proposed || !Mode.autoinst end # FATE#303643 Enable one-click changes in bootloader proposal @@ -358,6 +242,7 @@ "read" => fun_ref(method(:Read), "boolean (boolean, boolean)"), "reset" => fun_ref(method(:Reset), "void (boolean)"), "propose" => fun_ref(method(:Propose), "void ()"), + "save" => fun_ref(method(:Save), "boolean (boolean, boolean, boolean)"), "summary" => fun_ref(method(:Summary), "list <string> ()"), "update" => fun_ref(method(:Update), "void ()"), "widgets" => fun_ref( @@ -369,20 +254,6 @@ } end - # Initializer of GRUB bootloader - def Initializer - Builtins.y2milestone("Called GRUB2 initializer") - BootCommon.current_bootloader_attribs = { - "propose" => false, - "read" => false, - "scratch" => false, - "restore_mbr" => false, - "bootloader_on_disk" => false - } - - nil - end - # Constructor def BootGRUB2 Ops.set( @@ -407,6 +278,7 @@ publish :variable => :grub_descriptions, :type => "map <string, string>" publish :variable => :grub2_help_messages, :type => "map <string, string>" publish :variable => :grub2_descriptions, :type => "map <string, string>" + publish :variable => :password, :type => "string" publish :function => :askLocationResetPopup, :type => "boolean (string)" publish :function => :grub2Widgets, :type => "map <string, map <string, any>> ()" publish :function => :grub2efiWidgets, :type => "map <string, map <string, any>> ()" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/src/modules/BootGRUB2EFI.rb new/yast2-bootloader-3.1.6/src/modules/BootGRUB2EFI.rb --- old/yast2-bootloader-3.1.5/src/modules/BootGRUB2EFI.rb 2014-02-12 17:28:04.000000000 +0100 +++ new/yast2-bootloader-3.1.6/src/modules/BootGRUB2EFI.rb 2014-02-27 16:13:28.000000000 +0100 @@ -19,49 +19,18 @@ # $Id: BootGRUB2EFI.ycp 63508 2011-03-04 12:53:27Z jreidinger $ # require "yast" +require "bootloader/grub2base" module Yast - class BootGRUB2EFIClass < Module + class BootGRUB2EFIClass < GRUB2Base def main - Yast.import "UI" + super - textdomain "bootloader" - - Yast.import "BootArch" - Yast.import "BootCommon" - Yast.import "BootStorage" - Yast.import "Kernel" - Yast.import "Mode" - Yast.import "Stage" - Yast.import "Storage" - Yast.import "StorageDevices" - Yast.import "Pkg" - Yast.import "HTML" - Yast.import "Initrd" - Yast.import "Product" - - # includes - # for shared some routines with grub - # include "bootloader/grub/misc.ycp"; - # for simplified widgets than other - Yast.include self, "bootloader/grub2/dialogs.rb" BootGRUB2EFI() end # general functions - # Propose global options of bootloader - def StandardGlobals - { - "timeout" => "8", - "default" => "0", - "vgamode" => "", - "gfxmode" => "auto", - "terminal" => "gfxterm", - "os_prober" => "true" - } - end - # Read settings from disk # @param [Boolean] reread boolean true to force reread settings from system # @param [Boolean] avoid_reading_device_map do not read new device map from file, use @@ -70,30 +39,7 @@ def Read(reread, avoid_reading_device_map) BootCommon.InitializeLibrary(reread, "grub2-efi") BootCommon.ReadFiles(avoid_reading_device_map) if reread - # TODO: check if necessary for grub2efi - # grub_DetectDisks (); - ret = BootCommon.Read(false, avoid_reading_device_map) - - # TODO: check if necessary for grub2 - # refresh device map if not read - # if (BootStorage::device_mapping == nil - # || size (BootStorage::device_mapping) == 0) - # { - # BootStorage::ProposeDeviceMap (); - # } - - ret - end - - # Update read settings to new version of configuration files - def Update - Read(true, true) - - #we don't handle sections, grub2 section create them for us - #BootCommon::UpdateSections (); - BootCommon.UpdateGlobals - - nil + BootCommon.Read(false, avoid_reading_device_map) end # Write bootloader settings to disk @@ -112,87 +58,6 @@ ret end - # Reset bootloader settings - # @param [Boolean] init boolean true to repropose also device map - def Reset(init) - return if Mode.autoinst - BootCommon.Reset(init) - - nil - end - - # Propose bootloader settings - - def Propose - if BootCommon.was_proposed - # workaround autoyast config is Imported thus was_proposed always set - if Mode.autoinst - Builtins.y2milestone( - "autoinst mode we ignore meaningless was_proposed as it always set" - ) - else - Builtins.y2milestone( - "calling Propose with was_proposed set is really bogus, clear it to force a re-propose" - ) - return - end - end - - if BootCommon.globals == nil || Builtins.size(BootCommon.globals) == 0 - BootCommon.globals = StandardGlobals() - else - BootCommon.globals = Convert.convert( - Builtins.union(BootCommon.globals, StandardGlobals()), - :from => "map", - :to => "map <string, string>" - ) - end - - swap_sizes = BootCommon.getSwapPartitions - swap_parts = Builtins.maplist(swap_sizes) { |name, size| name } - swap_parts = Builtins.sort(swap_parts) do |a, b| - Ops.greater_than(Ops.get(swap_sizes, a, 0), Ops.get(swap_sizes, b, 0)) - end - - largest_swap_part = Ops.get(swap_parts, 0, "") - - resume = BootArch.ResumeAvailable ? largest_swap_part : "" - # try to use label or udev id for device name... FATE #302219 - if resume != "" && resume != nil - resume = BootStorage.Dev2MountByDev(resume) - end - Ops.set( - BootCommon.globals, - "append", - BootArch.DefaultKernelParams(resume) - ) - Ops.set( - BootCommon.globals, - "append_failsafe", - BootArch.FailsafeKernelParams - ) - Ops.set( - BootCommon.globals, - "distributor", - Ops.add(Ops.add(Product.short_name, " "), Product.version) - ) - BootCommon.kernelCmdLine = Kernel.GetCmdLine - - Builtins.y2milestone("Proposed globals: %1", BootCommon.globals) - - # Let grub2 scripts detects correct root= for us. :) - # BootCommon::globals["root"] = BootStorage::Dev2MountByDev(BootStorage::RootPartitionDevice); - - # We don't set vga= if Grub2 gfxterm enabled, because the modesettings - # will be delivered to kernel by Grub2's gfxpayload set to "keep" - #if (BootArch::VgaAvailable () && Kernel::GetVgaType () != "") - #{ - # BootCommon::globals["vgamode"] = Kernel::GetVgaType (); - #} - - nil - end - # Display bootloader summary # @return a list of summary lines @@ -214,11 +79,6 @@ deep_copy(result) end - def Dialogs - Builtins.y2milestone("Called GRUB2 Dialogs") - { "loader" => fun_ref(method(:Grub2LoaderDetailsDialog), "symbol ()") } - end - # Return map of provided functions # @return a map of functions (eg. $["write":BootGRUB2EFI::Write]) def GetFunctions @@ -226,6 +86,7 @@ "read" => fun_ref(method(:Read), "boolean (boolean, boolean)"), "reset" => fun_ref(method(:Reset), "void (boolean)"), "propose" => fun_ref(method(:Propose), "void ()"), + "save" => fun_ref(method(:Save), "boolean (boolean, boolean, boolean)"), "summary" => fun_ref(method(:Summary), "list <string> ()"), "update" => fun_ref(method(:Update), "void ()"), "widgets" => fun_ref( @@ -238,20 +99,6 @@ end - # Initializer of GRUB2EFI bootloader - def Initializer - Builtins.y2milestone("Called GRUB2EFI initializer") - BootCommon.current_bootloader_attribs = { - "propose" => false, - "read" => false, - "scratch" => false, - "restore_mbr" => false, - "bootloader_on_disk" => false - } - - nil - end - # Constructor def BootGRUB2EFI Ops.set( @@ -273,6 +120,7 @@ publish :variable => :grub_descriptions, :type => "map <string, string>" publish :variable => :grub2_help_messages, :type => "map <string, string>" publish :variable => :grub2_descriptions, :type => "map <string, string>" + publish :variable => :password, :type => "string" publish :function => :askLocationResetPopup, :type => "boolean (string)" publish :function => :grub2Widgets, :type => "map <string, map <string, any>> ()" publish :function => :grub2efiWidgets, :type => "map <string, map <string, any>> ()" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/test/Makefile.am new/yast2-bootloader-3.1.6/test/Makefile.am --- old/yast2-bootloader-3.1.5/test/Makefile.am 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-bootloader-3.1.6/test/Makefile.am 2014-02-27 16:13:28.000000000 +0100 @@ -0,0 +1,7 @@ +TESTS = \ + grub2pwd_test.rb + +TEST_EXTENSIONS = .rb +RB_LOG_COMPILER = rspec --format doc +VERBOSE = 1 +EXTRA_DIST = $(TESTS) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/test/grub2pwd_test.rb new/yast2-bootloader-3.1.6/test/grub2pwd_test.rb --- old/yast2-bootloader-3.1.5/test/grub2pwd_test.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-bootloader-3.1.6/test/grub2pwd_test.rb 2014-02-27 16:13:28.000000000 +0100 @@ -0,0 +1,107 @@ +#! /usr/bin/env rspec --format doc + +require_relative "./test_helper" + +require "bootloader/grub2pwd" + +describe GRUB2Pwd do + subject { GRUB2Pwd.new } + + def mock_file_presence(exists) + Yast.import "FileUtils" + expect(Yast::FileUtils).to receive(:Exists).with("/etc/grub.d/42_password"). + and_return(exists) + end + + describe "#used?" do + it "return true if exists file #{GRUB2Pwd::PWD_ENCRYPTION_FILE}" do + mock_file_presence(true) + expect(subject.used?).to be_true + end + end + + describe "#disable" do + it "removes file #{GRUB2Pwd::PWD_ENCRYPTION_FILE} when exists" do + mock_file_presence(true) + + expect(Yast::SCR).to receive(:Execute).with(kind_of(Yast::Path),"rm '#{GRUB2Pwd::PWD_ENCRYPTION_FILE}'") + + subject.disable + end + + it "do nothing if file #{GRUB2Pwd::PWD_ENCRYPTION_FILE} does not exist" do + mock_file_presence(false) + + expect(Yast::SCR).to receive(:Execute).never + + subject.disable + end + end + + describe "#enabled" do + it "write encrypted password to #{GRUB2Pwd::PWD_ENCRYPTION_FILE} with executable permissions" do + passwd = "grub.pbkdf2.sha512.10000.774E325959D6D7BCFB7384A0245674D83D0D540A89C02FEA81E35489F8DE7ADFD93988190AD9857A0FFF363825DDF97C8F4E658D8CC49FC4A22C053B08AB3EFE.6FB19FF26FD03D85C40A33D8BA7C04E72EDE3DD5D7080C177553A4FED370F71C579AF0B15B3B93ECECEA355469A4B6D0560BFB53ED35DDA0B80F5363BFBD54E4" + success_stdout = <<EOF + Enter password: + + Reenter password: + PBKDF2 hash of your password is #{passwd} +EOF + + expect(Yast::SCR).to receive(:Execute). + with(kind_of(Yast::Path), /grub2-mkpasswd/). + and_return( + "exit" => 0, + "stderr" => "", + "stdout" => success_stdout + ) + expect(Yast::SCR).to receive(:Write).with( + kind_of(Yast::Path), + [GRUB2Pwd::PWD_ENCRYPTION_FILE, 0755], + /#{passwd}/ + ) + + subject.enable("really strong password") + end + + it "raise exception if grub2-mkpasswd-pbkdf failed" do + expect(Yast::SCR).to receive(:Execute). + with(kind_of(Yast::Path),/grub2-mkpasswd/). + and_return( + "exit" => 1, + "stderr" => "bad error", + "stdout" => "" + ) + expect(Yast::SCR).to receive(:Write).never + + expect{subject.enable("really strong password")}.to raise_error(RuntimeError, /bad error/) + end + + it "raise exception if grub2-mkpasswd-pbkdf do not provide password" do + expect(Yast::SCR).to receive(:Execute). + with(kind_of(Yast::Path),/grub2-mkpasswd/). + and_return( + "exit" => 0, + "stderr" => "", + "stdout" => "bad output" + ) + expect(Yast::SCR).to receive(:Write).never + + expect{subject.enable("really strong password")}.to raise_error(RuntimeError, /bad output/) + end + + + it "raise exception if grub2-mkpasswd-pbkdf create password line but without password" do + expect(Yast::SCR).to receive(:Execute). + with(kind_of(Yast::Path),/grub2-mkpasswd/). + and_return( + "exit" => 0, + "stderr" => "", + "stdout" => "password is" + ) + expect(Yast::SCR).to receive(:Write).never + + expect{subject.enable("really strong password")}.to raise_error(RuntimeError, /password is/) + end + end +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/yast2-bootloader-3.1.5/test/test_helper.rb new/yast2-bootloader-3.1.6/test/test_helper.rb --- old/yast2-bootloader-3.1.5/test/test_helper.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/yast2-bootloader-3.1.6/test/test_helper.rb 2014-02-27 16:13:28.000000000 +0100 @@ -0,0 +1,8 @@ +ENV["Y2DIR"] = File.expand_path("../../src", __FILE__) + +if ENV["COVERAGE"] + require "simplecov" + SimpleCov.start +end + +require "yast" -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
