Package: grub-pc
Version: 1.98~20091210-1
Tags: patch

hi!

i just received the grub-pc upgrade, to find out that /etc/grub/05_debian_theme 
now sources /usr/share/desktop-base/grub_background.sh, obviously expecting the 
grub background image ($WALLPAPER) and grub menu colors ($COLOR_NORMAL and 
$COLOR_HIGHLIGHT) to be set in there. but grub_background.sh doesn't exist. 
neither as a file, nor as something i was able to find documented somewhere in 
the package.
also, for configuration issues, i guess variables like these are (and should 
be) usually set in /etc/default/grub (like the readme says. and while we're at 
it, all variables in there have the prefix GRUB_, which is generally a very 
good idea i guess)?

i don't understand the rationale of /usr/share/desktop-base/grub_background.sh, 
but even if it's a good idea as some sort of hook, then even if WALLPAPER was 
set in /etc/default/grub, it would be overwritten in any case. to prevent this, 
i guess the best solution would be to remove the hardcoded default values from 
that file, and simply set them as default values in /etc/default/grub resp. 
/usr/share/grub/default/grub.

while i was at it i also added the following variables to be able to configure 
grub-menu-passwords:

GRUB_SUPERUSERS="user1 user2 ..."
GRUB_PASSWORD_user1="cryptstring"
...

(can be configured in /etc/default/grub, changed 00_header and grub-mkconfig to 
handle them)

the attached patches do the following:

- leave grub_background.sh sourcing as it is (assuming it makes some sense), 
just removing the part setting hardcoded defaults if the file doesn't exist
- rename the variable names to GRUB_ prefixed names as used throughout 
/etc/default/grub
- add the defaults (as formerly hardcoded in 05_debian_theme) to the default 
config (/usr/share/grub/default/grub)
- add user/password variables
- make variable names known to grub-mkconfig

kind regards,

        Chris
--- /etc/grub.d/00_header	2009-12-18 14:52:04.000000000 +0100
+++ /etc/grub.d/00_header.x	2009-12-18 14:41:58.000000000 +0100
@@ -41,6 +41,18 @@ cat << EOF
 set default=${GRUB_DEFAULT}
 EOF
 
+if [ "x${GRUB_SUPERUSERS}" != "x" ] ; then
+	cat << EOF
+set superusers="${GRUB_SUPERUSERS}"
+EOF
+	for i in ${GRUB_SUPERUSERS}; do
+		eval "GRUB_PASSWORD=\$GRUB_PASSWORD_$i"
+		cat << EOF
+password ${i} ${GRUB_PASSWORD}
+EOF
+	done
+fi
+
 case ${GRUB_TERMINAL_INPUT}:${GRUB_TERMINAL_OUTPUT} in
   serial:* | *:serial)
     if ! test -e ${grub_prefix}/serial.mod ; then
--- /etc/grub.d/05_debian_theme	2009-12-10 00:47:36.000000000 +0100
+++ /etc/grub.d/05_debian_theme.x	2009-12-18 14:23:42.000000000 +0100
@@ -6,10 +6,6 @@ source /usr/lib/grub/grub-mkconfig_lib
 f=/usr/share/desktop-base/grub_background.sh
 if test -e ${f} ; then
   source ${f}
-else
-  WALLPAPER="/usr/share/images/desktop-base/moreblue-orbit-grub.png"
-  COLOR_NORMAL="black/black"
-  COLOR_HIGHLIGHT="magenta/black"
 fi
 
 set_blue_theme()
@@ -23,7 +19,7 @@ EOF
 # check for usable backgrounds
 use_bg=false
 if [ "$GRUB_TERMINAL_OUTPUT" = "gfxterm" ] ; then
-  for i in /boot/grub/`basename ${WALLPAPER}` ${WALLPAPER} ; do
+  for i in /boot/grub/`basename ${GRUB_BACKGROUND_IMAGE}` ${GRUB_BACKGROUND_IMAGE} ; do
     if is_path_readable_by_grub $i ; then 
       bg=$i
       case ${bg} in
@@ -46,8 +42,8 @@ if ${use_bg} ; then
   cat << EOF
 insmod ${reader}
 if background_image `make_system_path_relative_to_its_root ${bg}` ; then
-  set color_normal=${COLOR_NORMAL}
-  set color_highlight=${COLOR_HIGHLIGHT}
+  set color_normal=${GRUB_COLOR_NORMAL}
+  set color_highlight=${GRUB_COLOR_HIGHLIGHT}
 else
 EOF
 fi
--- /usr/share/grub/default/grub	2009-12-10 00:47:36.000000000 +0100
+++ /usr/share/grub/default/grub.x	2009-12-18 14:37:44.000000000 +0100
@@ -20,3 +20,7 @@ GRUB_CMDLINE_LINUX=""
 
 # Uncomment to disable generation of recovery mode menu entries
 #GRUB_DISABLE_LINUX_RECOVERY="true"
+
+GRUB_BACKGROUND_IMAGE="/usr/share/images/desktop-base/moreblue-orbit-grub.png"
+GRUB_COLOR_NORMAL="black/black"
+GRUB_COLOR_HIGHLIGHT="magenta/black"
--- /usr/sbin/grub-mkconfig	2009-12-18 14:26:49.000000000 +0100
+++ /usr/sbin/grub-mkconfig.x	2009-12-18 14:47:09.000000000 +0100
@@ -224,7 +224,14 @@ export GRUB_DEFAULT \
   GRUB_DISABLE_LINUX_UUID \
   GRUB_DISABLE_LINUX_RECOVERY \
   GRUB_GFXMODE \
-  GRUB_DISABLE_OS_PROBER
+  GRUB_BACKGROUND_IMAGE \
+  GRUB_COLOR_NORMAL \
+  GRUB_COLOR_HIGHLIGHT \
+  GRUB_DISABLE_OS_PROBER \
+  GRUB_SUPERUSERS
+for i in ${GRUB_SUPERUSERS}; do
+	eval "export GRUB_PASSWORD_$i"
+done
 
 if test "x${grub_cfg}" != "x"; then
   rm -f ${grub_cfg}.new

Reply via email to