Bug#486040: bashism in /bin/sh script

Vincent Zweije vincent at zweije.nl.eu.org
Sun Jun 15 13:41:50 UTC 2008


user debian-release at lists.debian.org
usertag 486040 -goal-dash
tag 486040 patch
severity 486040 minor
usertag 486042 -goal-dash
tag 486042 patch
severity 486042 minor
thanks

On Thu, Jun 12, 2008 at 11:13:07PM -0500, Raphael Geissert wrote:

||  While performing an archive wide checkbashisms (from the 'devscripts' package)
||  check I've found your package containing one or more /bin/sh scripts making
||  use of bashisms.
||
||  checkbashisms' output:
||  > possible bashism in ./usr/sbin/update-grub line 71 ($UID should be "id
||  > -ru"):
||  > if [ "x$UID" = "x" ] ; then
||  > possible bashism in ./usr/sbin/update-grub line 75 ($UID should be "id
||  > -ru"):
||  > if [ "$UID" != 0 ] ; then

On inspection this code appears safe. If UID is empty, it sets it using
id -u.

There is however a different although minor bug: the code should be
using $EUID (or set UID using id -ru).

The following patch should change the use of UID to EUID:

diff -rud grub2-1.96+20080601.orig/util/update-grub.in grub2-1.96+20080601/util/update-grub.in
--- grub2-1.96+20080601.orig/util/update-grub.in	2008-05-31 11:47:06.000000000 +0200
+++ grub2-1.96+20080601/util/update-grub.in	2008-06-15 14:35:59.000000000 +0200
@@ -68,11 +68,11 @@
 
 . ${libdir}/grub/update-grub_lib
 
-if [ "x$UID" = "x" ] ; then
-  UID=`id -u`
+if [ "x$EUID" = "x" ] ; then
+  EUID=`id -u`
 fi
 
-if [ "$UID" != 0 ] ; then
+if [ "$EUID" != 0 ] ; then
   echo "$0: You must run this as root" >&2
   exit 1
 fi

Ciao. Vincent.





More information about the Pkg-grub-devel mailing list