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.
This commit is contained in:
Robert Millan 2010-09-08 23:35:53 +02:00
parent 27f21a8bb6
commit 6b8e78aee3
4 changed files with 34 additions and 5 deletions

View file

@ -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 Vladimir Serbinenko <phcoder@gmail.com> 2010-09-08 Vladimir Serbinenko <phcoder@gmail.com>
Split minix.mod into minix.mod and minix2.mod. Split minix.mod into minix.mod and minix2.mod.

View file

@ -1,7 +1,7 @@
#! /bin/sh #! /bin/sh
# Install GRUB on your drive. # 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 # GRUB is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by # it under the terms of the GNU General Public License as published by
@ -327,8 +327,7 @@ if test "x$fs_module" = x -a "x$modules" = x; then
fi fi
# Then the partition map module. In order to support partition-less media, # 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 # this command is allowed to fail.
# filesystem will be accessible).
partmap_module= partmap_module=
for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do for x in `$grub_probe --target=partmap --device ${grub_device} 2> /dev/null`; do
partmap_module="$partmap_module part_$x"; partmap_module="$partmap_module part_$x";
@ -402,6 +401,14 @@ case "${target_cpu}-${platform}" in
*) mkimage_target=i386-coreboot; *) mkimage_target=i386-coreboot;
esac esac
# 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
if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then if [ "${target_cpu}-${platform}" = "i386-pc" ] || [ "${target_cpu}-${platform}" = "sparc64-ieee1275" ] ; then
$grub_mkimage ${config_opt} -O ${mkimage_target} --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1 $grub_mkimage ${config_opt} -O ${mkimage_target} --output=${grubdir}/core.img --prefix=${prefix_drive}${relative_grubdir} $modules || exit 1

View file

@ -303,6 +303,12 @@ for i in ${grub_mkconfig_dir}/* ; do
esac esac
done 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 if test "x${grub_cfg}" != "x" ; then
# none of the children aborted with error, install the new grub.cfg # none of the children aborted with error, install the new grub.cfg
mv -f ${grub_cfg}.new ${grub_cfg} mv -f ${grub_cfg}.new ${grub_cfg}

View file

@ -53,16 +53,23 @@ make_system_path_relative_to_its_root ()
is_path_readable_by_grub () is_path_readable_by_grub ()
{ {
path=$1 path=$1
device=$2
relpath=$3
# abort if path doesn't exist # abort if path doesn't exist
if test -e $path ; then : ;else if test -e $path ; then : ;else
return 1 return 1
fi 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 # abort if file read through GRUB doesn't match file read through system
# facilities # facilities
device=$(${grub_probe} --target=device $path)
relpath=$(${grub_mkrelpath} $path)
if ${grub_fstest} $device cmp $relpath $path > /dev/null 2>&1 ; then : ; else if ${grub_fstest} $device cmp $relpath $path > /dev/null 2>&1 ; then : ; else
return 1 return 1
fi fi