Author: juhliarik
Date: Mon Sep 8 17:01:09 2008
New Revision: 50815
URL: http://svn.opensuse.org/viewcvs/yast?rev=50815&view=rev
Log:
added support for trusted grub
M bootloader/src/grub/helps.ycp
* added help text
A bootloader/src/grub/trusted_grub_edit.ycp
* added new UI for detail editing measured files
M bootloader/src/grub/Makefile.am
* update makefile
M bootloader/src/config/bootloader.rnc
* update autoyast profile of bootloader
M bootloader/src/modules/BootCommon.ycp
* update import/export
M bootloader/src/modules/BootGRUB.ycp
* added new dialog
M bootloader/src/routines/lib_iface.ycp
M bootloader/src/modules/Bootloader_API.pm
* changed type of map section from map to
map
M bootloader/src/routines/section_widgets.ycp
* update UI
M bootloader/src/routines/misc.ycp
* added new function for handling import/export
M bootloader/src/routines/helps.ycp
* update help text
M bootloader/src/generic/boot_loader_locations_widget.ycp
M bootloader/src/generic/global_options_widget.ycp
M bootloader/src/generic/wizards.ycp
* update UI
Added:
trunk/bootloader/src/grub/trusted_grub_edit.ycp
Modified:
trunk/bootloader/src/config/bootloader.rnc
trunk/bootloader/src/generic/boot_loader_locations_widget.ycp
trunk/bootloader/src/generic/global_options_widget.ycp
trunk/bootloader/src/generic/wizards.ycp
trunk/bootloader/src/grub/Makefile.am
trunk/bootloader/src/grub/helps.ycp
trunk/bootloader/src/modules/BootCommon.ycp
trunk/bootloader/src/modules/BootGRUB.ycp
trunk/bootloader/src/modules/Bootloader_API.pm
trunk/bootloader/src/routines/helps.ycp
trunk/bootloader/src/routines/lib_iface.ycp
trunk/bootloader/src/routines/misc.ycp
trunk/bootloader/src/routines/section_widgets.ycp
Modified: trunk/bootloader/src/config/bootloader.rnc
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/config/bootloader.rnc?rev=50815&r1=50814&r2=50815&view=diff
==============================================================================
--- trunk/bootloader/src/config/bootloader.rnc (original)
+++ trunk/bootloader/src/config/bootloader.rnc Mon Sep 8 17:01:09 2008
@@ -43,6 +43,7 @@
element global {
element boot_custom { text }? &
element generic_mbr { text }? &
+ element trusted_grub{ text }? &
element serial { text }? &
element terminal { text }? &
lines_cache_id? &
@@ -55,6 +56,7 @@
boot_mbr? &
stage1_dev?
}
+
lines_cache_id = element lines_cache_id { text }
stage1_dev = element stage1_dev { text }
bl_timeout = element timeout { INTEGER }
@@ -88,6 +90,7 @@
element sectors {text}? &
element blockoffset {text}? &
element vgamode {text}? &
+ element measures ? &
element xen {text}? &
element xen_append {text}? &
element noverifyroot { "true" | "false" }? &
@@ -97,3 +100,15 @@
element image {text}?
}
kernel_parameters = element kernel_parameters { text }
+
+measure =
+ element measure {
+ element file { text } &
+ element pcr { text }
+ }
+
+measures =
+ element measures {
+ LIST,
+ measure+
+}
Modified: trunk/bootloader/src/generic/boot_loader_locations_widget.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/generic/boot_loader_locations_widget.ycp?rev=50815&r1=50814&r2=50815&view=diff
==============================================================================
--- trunk/bootloader/src/generic/boot_loader_locations_widget.ycp (original)
+++ trunk/bootloader/src/generic/boot_loader_locations_widget.ycp Mon Sep 8 17:01:09 2008
@@ -32,6 +32,12 @@
map _bll_options = nil;
/**
+ * option once propose
+ */
+
+boolean once_to_mbr = true;
+
+/**
* return map of boot loader options from global_options, cache them if
* necessary
*/
@@ -53,6 +59,13 @@
* @param widget string widget key
*/
void BLL_Init (string widget) {
+ // propose install grub to MBR if trusted GRUB is selected (only once)
+
+ if ((BootCommon::globals["trusted_grub"]:"" == "true") && (once_to_mbr))
+ {
+ BootCommon::globals["boot_mbr"] = "true";
+ once_to_mbr = false;
+ }
generic_Init(widget, BLL_options(), BootCommon::globals);
}
Modified: trunk/bootloader/src/generic/global_options_widget.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/generic/global_options_widget.ycp?rev=50815&r1=50814&r2=50815&view=diff
==============================================================================
--- trunk/bootloader/src/generic/global_options_widget.ycp (original)
+++ trunk/bootloader/src/generic/global_options_widget.ycp Mon Sep 8 17:01:09 2008
@@ -30,6 +30,21 @@
map _gow_options = nil;
map GOW_options () {
+ // HACK add checkbox for enabling trusted GRUB
+ if (BootCommon::getLoaderType (false) == "grub")
+ {
+ BootCommon::global_options["trusted_grub"] = "bool:Use Trusted Grub:true";
+ } else {
+ if (haskey(BootCommon::global_options, "trusted_grub"))
+ BootCommon::global_options = remove(BootCommon::global_options, "trusted_grub");
+ }
+ // HACK delete fallback and former_default_image_flavor
+ if (haskey(BootCommon::global_options, "former_default_image_flavor"))
+ BootCommon::global_options = remove(BootCommon::global_options, "former_default_image_flavor");
+
+ if (haskey(BootCommon::global_options, "fallback"))
+ BootCommon::global_options = remove(BootCommon::global_options, "fallback");
+
if ( _gow_options == nil)
{
_gow_options = filter( string key, any value, BootCommon::global_options, {
Modified: trunk/bootloader/src/generic/wizards.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/generic/wizards.ycp?rev=50815&r1=50814&r2=50815&view=diff
==============================================================================
--- trunk/bootloader/src/generic/wizards.ycp (original)
+++ trunk/bootloader/src/generic/wizards.ycp Mon Sep 8 17:01:09 2008
@@ -54,13 +54,12 @@
}
string se_type = "section_edit_" + type;
map > widget_descr = (map >)
- union (CommonSectionWidgets (), Bootloader::blWidgetMaps ());
+ union (CommonSectionWidgets (), Bootloader::blWidgetMaps ());
if (! haskey(widget_descr, se_type) ) {
y2error("Could not find a dialog %1", se_type);
return nil;
}
-
term contents = `HBox (
`HSpacing (2),
`VBox (
@@ -78,6 +77,8 @@
`HSpacing (2)
)
),
+ "trusted",
+
`VStretch ()
),
`HSpacing (2)
@@ -85,7 +86,7 @@
return CWM::ShowAndRun ($[
"widget_descr" : widget_descr,
- "widget_names" : ["name", se_type],
+ "widget_names" : ["name", "trusted", se_type],
"contents" : contents,
"caption" : _("Boot Loader Settings: Section Management"),
"back_button" : Label::BackButton (),
@@ -135,6 +136,7 @@
"main" : ``(MainDialog ()),
"installation_details" : ``(DetailsDialog ("installation")),
"loader_details" : ``(DetailsDialog ("loader")),
+ "t_grub" : ``(DetailsDialog ("trusted_grub")),
"add_new_section" : ``(AddNewSectionDialog ()),
"store_section" : [``(GenericStoreSection ()), true],
"manual_edit" : ``(runEditFilesDialog ()),
@@ -178,8 +180,15 @@
],
"section_edit" : $[
`next : "store_section",
+ `trusted_details : "t_grub",
+ `abort : `abort,
+ ],
+ "t_grub" : $[
+ `next : "section_edit",
+ //FIXME kokso: it is good idea handle abort via "section_edit" not `abort
`abort : `abort,
],
+
];
foreach (string st, section_types(), {
Modified: trunk/bootloader/src/grub/Makefile.am
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/grub/Makefile.am?rev=50815&r1=50814&r2=50815&view=diff
==============================================================================
--- trunk/bootloader/src/grub/Makefile.am (original)
+++ trunk/bootloader/src/grub/Makefile.am Mon Sep 8 17:01:09 2008
@@ -6,7 +6,8 @@
ynclude_DATA = \
helps.ycp \
- misc.ycp
+ misc.ycp \
+ trusted_grub_edit.ycp
EXTRA_DIST = \
$(ynclude_DATA)
Modified: trunk/bootloader/src/grub/helps.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/grub/helps.ycp?rev=50815&r1=50814&r2=50815&view=diff
==============================================================================
--- trunk/bootloader/src/grub/helps.ycp (original)
+++ trunk/bootloader/src/grub/helps.ycp Mon Sep 8 17:01:09 2008
@@ -44,6 +44,9 @@
"boot_boot" :
_("<p><b>Boot from Boot Partition</b> is one of the recommended options, the other is
<b>Boot from Root Partition</b>.</p>"),
+ "trusted_grub" :
+_("<p><b>Use Trusted Grub</b> means install trusted grub and use it. Option <i>Grafical Menu File</i> will be ignored.
+It is recommended to install grub to MBR</p>"),
"boot_mbr" :
_("<p><b>Boot from Master Boot Record</b> is not recommended if you have another operating system
installed on your computer</p>"),
@@ -124,6 +127,16 @@
_("<p><b>Menu Description File<b></p>"),
"other_remap" :
_("<p><b>Map Section to the First Disk from Device Map</b> Windows usually need to be on the first disk.</p>"),
+ "MeasuresTableHelp" :
+ _("<p><b>Measures</b> includes measured files with PCR. Change table is possible via buttons: <b>Add</b> ,
+<b>Edit</b> and <b>Delete</b></p>"),
+ "PCRKernelHelp" :
+ _("<p><b>PCR Index of Kernel<b> is Platform Configuration Register for kernel</p>"),
+ "PCRInitrdHelp" :
+ _("<p><b>PCR Index of Kernel<b> is Platform Configuration Register for initrd</p>"),
+ "PCRChainloaderHelp" :
+ _("<p><b>PCR Index of Kernel<b> is Platform Configuration Register for chainloader</p>"),
+
];
@@ -133,6 +146,7 @@
"timeout" : _("Timeout in Seconds"),
"default" : _("Default Boot Section"),
"generic_mbr" : _("Write generic Boot Code to MBR"),
+ "trusted_grub" : _("Use Trusted Grub"),
"boot_custom" : _("Custom Boot Partition"),
"boot_mbr" : _("Boot from Master Boot Record"),
"boot_root" : _("Boot from Root Partition"),
Added: trunk/bootloader/src/grub/trusted_grub_edit.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/grub/trusted_grub_edit.ycp?rev=50815&view=auto
==============================================================================
--- trunk/bootloader/src/grub/trusted_grub_edit.ycp (added)
+++ trunk/bootloader/src/grub/trusted_grub_edit.ycp Mon Sep 8 17:01:09 2008
@@ -0,0 +1,356 @@
+{
+
+textdomain "bootloader";
+
+import "CWM";
+import "Label";
+import "BootCommon";
+import "Popup";
+
+include "bootloader/grub/helps.ycp";
+
+
+/**
+ * Init function of widget
+ * @param widget string id of the widget
+ */
+
+void InitMeasuresTable(string widget)
+{
+ map meas = BootCommon::current_section["measure"]:$[];
+ list measures = [];
+
+ foreach(string file, string pcr, meas, {
+ measures = add(measures, `item(`id(file), file, pcr));
+ });
+
+ UI::ChangeWidget (`id (`measures), `Items, measures);
+}
+
+
+
+void AddEditMeasure (string file, string pcr)
+{
+ map meas = BootCommon::current_section["measure"]:$[];
+ string orig_file = file;
+ any ret = nil;
+
+ if (pcr == "")
+ pcr ="8";
+
+ UI::OpenDialog( (file != "") ? `Label( _("Edit Measure")): `Label( _("Add New Measure") ),
+ `VBox(
+ `HBox(
+ `InputField(`id(`measur), _("Measure File"), file),
+ `VBox ( `Label(""),
+ `PushButton(`id(`br), Label::BrowseButton())
+ )
+ ),
+ `Left(`IntField(`id(`pcr), _("PCR Index of File"),0, 100, tointeger(pcr))),
+ `HBox(
+ `PushButton(`id(`cancel), Label::CancelButton()),
+ `PushButton(`id(`ok), Label::OKButton())
+ )
+ )
+ ); // end of UI::OpenDialog(
+
+ while (true) {
+ ret = UI::UserInput();
+ if (ret == `br) {
+ string val = UI::AskForExistingFile ("/","*.*",_("Please Select File"));
+ UI::ChangeWidget(`id(`measur), `Value, val);
+ } else if ( ret == `ok ) {
+ string new_file = tostring(UI::QueryWidget(`id(`measur), `Value));
+ string new_pcr = tostring(UI::QueryWidget(`id(`pcr), `Value));
+ if (file != "")
+ {
+ meas = remove(meas, file);
+ }
+ meas[new_file] = new_pcr;
+ break;
+ } else if (ret == `cancel) {
+ break;
+ }
+ };
+ BootCommon::current_section["measure"] = meas;
+
+ UI::CloseDialog();
+}
+
+/**
+ * Handle function of a widget
+ * @param widget string widget key
+ * @param event map event description of event that occured
+ * @return symbol to return to wizard sequencer, or nil
+ */
+symbol HandleMeasuresTable (string widget, map event)
+{
+
+ any op = event["ID"]:nil;
+ if (event["ID"]:nil == `measures
+ && event["EventReason"]:"" == "Activated"
+ && event["EventType"]:"" == "WidgetEvent")
+ {
+ op = `edit;
+ }
+ map meas = BootCommon::current_section["measure"]:$[];
+
+ string current = (string)UI::QueryWidget (`id (`measures), `CurrentItem);
+ string act_file = "";
+ string act_pcr = "";
+
+ if ((current != nil) && (current != ""))
+ {
+ act_file = current;
+ act_pcr = meas[current]:"";
+ }
+ if (op == `add)
+ {
+ AddEditMeasure("", "");
+ InitMeasuresTable(widget);
+ } else if (op == `edit) {
+
+ AddEditMeasure(act_file, act_pcr);
+ InitMeasuresTable(widget) ;
+ } else if (op == `delete) {
+ string message = sformat(_("Really delete measured file: %1 with PCR: %2 ?"), act_file, act_pcr);
+ if (Popup::YesNo(message))
+ {
+ meas = remove(meas,act_file);
+ BootCommon::current_section["measure"] = meas;
+ InitMeasuresTable(widget);
+ }
+ }
+
+}
+/**
+ * Store function of a widget
+ * @param widget string widget key
+ * @param event map event that caused the operation
+ */
+void StoreMeasuresTable (string widget, map event)
+{
+ if ((size(BootCommon::current_section["measure"]:$[]) == 0) &&
+ (haskey(BootCommon::current_section, "measure")))
+ BootCommon::current_section = remove(BootCommon::current_section, "measure");
+}
+
+/**
+ * Init function of widget
+ * @param widget string id of the widget
+ */
+
+void InitPCRKernel (string widget) {
+ if ((BootCommon::current_section["type"]:"" == "image") || (BootCommon::current_section["type"]:"" == "xen"))
+ {
+ UI::ChangeWidget (`id ("PCRKernel"), `Enabled, true);
+ UI::ChangeWidget (`id ("PCRKernel"), `Value, tointeger(BootCommon::current_section["imagepcr"]:"8"));
+ } else {
+ UI::ChangeWidget (`id ("PCRKernel"), `Enabled, false);
+ }
+}
+
+
+/**
+ * Store function of a widget
+ * @param widget string widget key
+ * @param event map event that caused the operation
+ */
+void StorePCRKernel (string widget, map event) {
+ if ((BootCommon::current_section["type"]:"" == "image") ||
+ (BootCommon::current_section["type"]:"" == "xen"))
+ BootCommon::current_section["imagepcr"] = tostring(UI::QueryWidget (`id ("PCRKernel"), `Value));
+}
+
+/**
+ * Init function of widget
+ * @param widget string id of the widget
+ */
+
+void InitPCRInitrd (string widget) {
+ if ((BootCommon::current_section["type"]:"" == "image") || (BootCommon::current_section["type"]:"" == "xen"))
+ {
+ UI::ChangeWidget (`id ("PCRInitrd"), `Enabled, true);
+ UI::ChangeWidget (`id ("PCRInitrd"), `Value, tointeger(BootCommon::current_section["initrdpcr"]:"8"));
+ } else {
+ UI::ChangeWidget (`id ("PCRInitrd"), `Enabled, false);
+ }
+}
+
+
+/**
+ * Store function of a widget
+ * @param widget string widget key
+ * @param event map event that caused the operation
+ */
+void StorePCRInitrd (string widget, map event) {
+ if ((BootCommon::current_section["type"]:"" == "image") ||
+ (BootCommon::current_section["type"]:"" == "xen"))
+ BootCommon::current_section["initrdpcr"] = tostring(UI::QueryWidget (`id ("PCRInitrd"), `Value));
+}
+
+
+
+/**
+ * Init function of widget
+ * @param widget string id of the widget
+ */
+
+void InitPCRChainloader (string widget) {
+ if (BootCommon::current_section["type"]:"" != "other")
+ UI::ChangeWidget (`id ("PCRChainloader"), `Enabled, false);
+ else
+ UI::ChangeWidget (`id ("PCRChainloader"), `Value, tointeger(BootCommon::current_section["chainloaderpcr"]:"8"));
+}
+
+
+/**
+ * Store function of a widget
+ * @param widget string widget key
+ * @param event map event that caused the operation
+ */
+void StorePCRChainloader (string widget, map event) {
+ if (BootCommon::current_section["type"]:"" == "other")
+ BootCommon::current_section["chainloaderpcr"] = tostring(UI::QueryWidget (`id ("PCRChainloader"), `Value));
+}
+
+
+
+map > wid_handling = $[
+
+
+ "MeasuresTable" : $[
+ //TRANSLATORS: RadioButtonGroup Label
+ "label" : _("Measurement of Grub"),
+ "widget" : `custom,
+ "custom_widget" : `VBox(`Frame (_("Measures"),
+ `HBox (`HSpacing (2), `VBox (
+ `VSpacing (1),
+ `Table (`id (`measures),
+ `opt (`keepSorting, `notify),
+ `header (
+ // table header, Measure
+ _("Measure"),
+ // table header, PCR
+ _("PCR")
+ ), []
+ ),
+
+ `HBox (
+ `HStretch (),
+ `PushButton (`id (`add), `opt (`key_F3), Label::AddButton ()),
+ `PushButton (`id (`edit), `opt(`key_F5), Label::EditButton ()),
+ `PushButton (`id (`delete), `opt(`key_F5), Label::DeleteButton ()),
+ `HStretch ()
+ ),
+ `VSpacing (1)
+ )
+
+ )
+ )),
+ "init" : InitMeasuresTable,
+ "handle" : HandleMeasuresTable,
+ "store" : StoreMeasuresTable,
+ "help" : grub_help_messages["MeasuresTableHelp"]:"",
+
+ ],
+
+ "PCRKernel" : $[
+ //TRANSLATORS: IntField Label
+ "label" : _("PCR Index of &Kernel"),
+ "widget" : `intfield,
+ "minimum" : 0,
+ "maximum" : 100,
+ "init" : InitPCRKernel,
+ //"handle" :
+ "store" : StorePCRKernel,
+ "help" : grub_help_messages["PCRKernelHelp"]:"",
+ ],
+
+
+
+ "PCRInitrd" : $[
+ //TRANSLATORS: IntField Label
+ "label" : _("PCR Index of &Initrd"),
+ "widget" : `intfield,
+ "minimum" : 0,
+ "maximum" : 100,
+ "init" : InitPCRInitrd,
+ //"handle" :
+ "store" : StorePCRInitrd,
+ "help" : grub_help_messages["PCRInitrdHelp"]:"",
+ ],
+
+
+ "PCRChainloader" : $[
+ //TRANSLATORS: IntField Label
+ "label" : _("PCR &Index of Chainloader"),
+ "widget" : `intfield,
+ "minimum" : 0,
+ "maximum" : 100,
+ "init" : InitPCRChainloader,
+ //"handle" :
+ "store" : StorePCRChainloader,
+ "help" : grub_help_messages["PCRChainloaderHelp"]:"",
+ ],
+
+];
+
+
+
+
+symbol TrustedGrubDetails () {
+ y2milestone ("Running i386 loader details dialog");
+
+ term contents = `HBox (`HSpacing (2), `VBox (
+ "MeasuresTable",
+ `VSpacing (1),
+ "PCRKernel",
+ `VSpacing (1),
+ "PCRInitrd",
+ `VSpacing (1),
+ "PCRChainloader",
+ `VStretch ()
+ ), `HSpacing (2));
+
+ list<string> widget_names = ["MeasuresTable", "PCRKernel", "PCRInitrd", "PCRChainloader",];
+ map > widget_descr = wid_handling;
+ // dialog caption
+ string caption = _("Trusted GRUB Options");
+ return CWM::ShowAndRun ($[
+ "widget_descr" : widget_descr,
+ "widget_names" : widget_names,
+ "contents" : contents,
+ "caption" : caption,
+ "back_button" : Label::BackButton (),
+ "abort_button" : Label::CancelButton (),
+ "next_button" : Label::OKButton (),
+ ]);
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}
Modified: trunk/bootloader/src/modules/BootCommon.ycp
URL: http://svn.opensuse.org/viewcvs/yast/trunk/bootloader/src/modules/BootCommon.ycp?rev=50815&r1=50814&r2=50815&view=diff
==============================================================================
--- trunk/bootloader/src/modules/BootCommon.ycp (original)
+++ trunk/bootloader/src/modules/BootCommon.ycp Mon Sep 8 17:01:09 2008
@@ -118,6 +118,13 @@
*/
global string BootPartitionDevice = "";
+
+/**
+ * The variable indicate using of trusted GRUB
+ */
+
+global boolean isTrustedGrub = true;
+
/**
* string representing device name of / partition
*/
@@ -654,7 +661,8 @@
*/
global define boolean Import (map settings) {
globals = settings["global"]:$[];
- sections = settings["sections"]:[];
+ sections = importSections(settings["sections"]:[]);
+
// FIXME: for grub, repl_mbr is replaced by globals["generic_mbr"]; same
// for activate; remove the following when no bootloader uses these
// variables any more
@@ -792,11 +800,12 @@
// FATE: #110038: Serial console
// check and add console key with value for sections
addConsole();
+ /*
list