]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
2010-09-08 Robert Millan <rmh@gnu.org>
authorRobert Millan <rmh@aybabtu.com>
Wed, 8 Sep 2010 21:41:27 +0000 (23:41 +0200)
committerRobert Millan <rmh@aybabtu.com>
Wed, 8 Sep 2010 21:41:27 +0000 (23:41 +0200)
* util/grub-mkconfig_lib.in (is_path_readable_by_grub): Improve
with (optional) parameters to specify device and relative path.
* util/grub-install.in: Use is_path_readable_by_grub() to
verify readability of a few critical files.
* util/grub-mkconfig.in: Use is_path_readable_by_grub() to
verify readability of grub.cfg.new.

ChangeLog
util/grub-install.in
util/grub-mkconfig.in
util/grub-mkconfig_lib.in

index 2acf132ee835faa9a701dea1159493f551ab408c..eef306cc98b17fb498006699db33edf54b85f909 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-09-08  Robert Millan  <rmh@gnu.org>
+
+       * util/grub-mkconfig_lib.in (is_path_readable_by_grub): Improve
+       with (optional) parameters to specify device and relative path.
+       * util/grub-install.in: Use is_path_readable_by_grub() to
+       verify readability of a few critical files.
+       * util/grub-mkconfig.in: Use is_path_readable_by_grub() to
+       verify readability of grub.cfg.new.
+
 2010-09-08  Colin Watson  <cjwatson@ubuntu.com>
 
        * grub-core/kern/efi/init.c (grub_efi_set_prefix): If the prefix
index 0956c090281544ebc39771f1c751f7c74c153cac..eb7ef48b6af709f81d217b7ef1cf1450fe723a50 100644 (file)
@@ -1,7 +1,7 @@
 #! /bin/sh
 
 # Install GRUB on your drive.
-# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009  Free Software Foundation, Inc.
+# Copyright (C) 1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010  Free Software Foundation, Inc.
 #
 # GRUB is free software: you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -457,8 +457,7 @@ if test "x$fs_module" = x -a "x$modules" = x; then
 fi
 
 # Then the partition map module.  In order to support partition-less media,
-# this command is allowed to fail (--target=fs already grants us that the
-# filesystem will be accessible).
+# this command is allowed to fail.
 partmap_module=
 for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do
    partmap_module="$partmap_module part_$x";
@@ -555,6 +554,14 @@ elif [ "${target_cpu}-${platform}" = "i386-efi" ] || [ "${target_cpu}-${platform
     $grub_mkimage ${config_opt} -O ${mkimage_target} --output=${grubdir}/grub.efi --prefix="" $modules || exit 1
 fi
 
+# Verify readability of a few critical files
+for file in grubenv core.${imgext} normal.mod ; do
+  if is_path_readable_by_grub ${grubdir}/${file} ${grub_device} ${relative_grubdir}/${file} ; then : ; else
+    echo "GRUB is unable to read ${grubdir}/${file}" >&2
+    exit 1
+  fi
+done
+
 # Perform the platform-dependent install
 if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
     # Now perform the installation.
index 6f1d375a72fc0b3ddb08294418bfdfcab4f48337..9ea01e8f66b7c3785eaf6dfb5d295f37eae72ec2 100644 (file)
@@ -313,6 +313,12 @@ for i in ${grub_mkconfig_dir}/* ; do
   esac
 done
 
+# Verify readability of ${grub_cfg}.new
+if is_path_readable_by_grub ${grub_cfg}.new ; then : ; else
+  echo "GRUB is unable to read ${grubdir}/${file}" >&2
+  exit 1   
+fi
+
 if test "x${grub_cfg}" != "x" ; then
   # none of the children aborted with error, install the new grub.cfg
   mv -f ${grub_cfg}.new ${grub_cfg}
index c6f79fb4924ff81014df2d1ccd63f1a65ba2d0ec..6d4f9f3bb32ddcdb5fc9ca4bb3ed17db2cc73f65 100644 (file)
@@ -53,16 +53,23 @@ make_system_path_relative_to_its_root ()
 is_path_readable_by_grub ()
 {
   path=$1
+  device=$2
+  relpath=$3
 
   # abort if path doesn't exist
   if test -e $path ; then : ;else
     return 1
   fi
 
+  if [ "${device}" = "" ] ; then
+    device=$(${grub_probe} --target=device $path)
+  fi
+  if [ "${relpath}" = "" ] ; then
+    relpath=$(${grub_mkrelpath} $path)
+  fi
+
   # abort if file read through GRUB doesn't match file read through system
   # facilities
-  device=$(${grub_probe} --target=device $path)
-  relpath=$(${grub_mkrelpath} $path)
   if ${grub_fstest} $device cmp $relpath $path > /dev/null 2>&1 ; then : ; else
     return 1
   fi