#20 Fixed "id" path issue in sh.script.in

open
nobody
None
5
2012-12-11
2007-08-16
cjdance
No

The sh.script.in references the "id" command with an absolute path including looking in some left-of-center places like /usr/xpg4/bin/id . The script in it's current form fails to locate id if the distribution stores it in /bin (e.g. Mandriva). I'm not sure what the history is behind this section of the code, however I recommend the following minor change.

This diff fixes bug #1069929

--- sh.script.in 2007-08-16 12:08:26.000000000 +-1000
+++ sh.script.in 2007-08-16 12:08:26.000000000 +-1000
@@ -291,22 +291,26 @@
# $2 command

# Check the configured user. If necessary rerun this script as the desired user.
if [ "X$RUN_AS_USER" != "X" ]
then
# Resolve the location of the 'id' command
- IDEXE="/usr/xpg4/bin/id"
+ IDEXE=`which id 2>/dev/null`
+ if [ ! -x "$IDEXE" ]
+ then
+ IDEXE="/usr/xpg4/bin/id"
+ fi
if [ ! -x "$IDEXE" ]
then
IDEXE="/usr/bin/id"
- if [ ! -x "$IDEXE" ]
- then
- echo "Unable to locate 'id'."
- echo "Please report this message along with the location of the command on your system."
- exit 1
- fi
+ fi
+ if [ ! -x "$IDEXE" ]
+ then
+ echo "Unable to locate 'id'."
+ echo "Please report this message along with the location of the command on your system."
+ exit 1
fi

if [ "`$IDEXE -u -n`" = "$RUN_AS_USER" ]
then
# Already running as the configured user. Avoid password prompts by not calling su.
RUN_AS_USER=""

Discussion

  • cjdance
    cjdance
    2007-08-16

    sh.script.in-id-fix.diff