Index: check_path
===================================================================
RCS file: /cvsroot/tiger/tiger/systems/HPUX/check_path,v
retrieving revision 1.2
diff -u -p -r1.2 check_path
--- check_path	24 Nov 2003 23:11:36 -0000	1.2
+++ check_path	4 Apr 2004 06:06:05 -0000
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/ksh
 #
 #     tiger - A UN*X security checking system
 #     Copyright (C) 1993 Douglas Lee Schales, David K. Hess, David R. Safford
@@ -17,6 +17,10 @@
 #
 # check_path  - 06/14/93
 #
+# 04/03/2004 rbrad Change bash -> ksh.  Resolve the realpath when
+#      checking permissions.  Ignore permissions on broken symlinks.
+#      Add support for pathmunge function (Needed for RedHat 9).
+#      Add support for ~user/path.
 # 11/19/2003 rbrad Reimplementation to handle additional methods for 
 #      introducing directories into the PATH environment including
 #      $(<FILE) and /path/*/path. Common paths are only checked once.
@@ -105,7 +109,7 @@ check_permissions()
    okgroup=$3
    user=$4
    srcfile=$5
-
+ 
    [ ! -d $dir ] && continue
  
    # Check directory and file permissions.
@@ -116,8 +120,13 @@ check_permissions()
       # Skip non-executable files.
       [ "$ux$gx$ox" = '000' ] && continue
 
-      # Do an embedded check here.
+      # Resolve the REALPATH.
+      _execfile=`$REALPATH $dir/$_execfile`
 
+      # Skip dead symbolic links.
+      [ -z "$_execfile" -o ! -e "$_execfile" ] && continue
+
+      # Do an embedded check here.
 
       # Pretend the gw bit is not set if group in okgroup
       [ "$gw" = '1' ] && {
@@ -230,6 +239,7 @@ path_grep()
               -e 's/;//g' \
               -e 's/&&//g' \
               -e 's/||//g' \
+              -e 's/pathmunge \([^ I]*\)[[:blank:]]*.*/PATH=\1/g' \
               -e 's/[ 	]//g' \
          $file |
          $EGREP "$val" |
@@ -290,6 +300,9 @@ parse_file()
 
       # Handle the $ENV tokens.
       [[ "$token" = \$* ]] && {
+         # RedHat uses '$1' in the pathmunge function... skip it
+         [ "$token" = '$1' ] && continue
+
          token=${token##$}
 
          [[ "$seen" = *:$token:* ]] && continue
@@ -372,8 +385,8 @@ check_user()
    # Initialized the USR_PATH file.
    USR_PATH=$WORKDIR/usr_path
    >$USR_PATH
+   >$USR_PATH.$$
 
-   # Check for ~ entries in the SYS_PATH (i.e. $HOME/bin)
    $GREP '^~\$user' $SYS_PATH |
    while read dir1
    do
@@ -384,11 +397,27 @@ check_user()
    # Check for PATH settings in these 'dot' files.
    for file in .profile .cshrc .login .tcshrc .bash_profile .bashrc .kshrc
    do
-      [ -s $home/$file ] && parse_file $home/$file $USR_PATH
+      [ -s $home/$file ] && parse_file $home/$file $USR_PATH.$$
    done
 
+   # Check for ~ entries in the USR_PATH (i.e. $HOME/bin)
+   while read line
+   do
+      [[ $line = '~$user/'* ]] && {
+         eval dir=`echo $line | $SED -e "s:~\\\$user:$home:g"`
+         $BINDIR/realpath $dir >> $USR_PATH
+         continue;
+      }
+
+      echo "$line" >> $USR_PATH
+   done < $USR_PATH.$$ 
+   delete $USR_PATH.$$
+
    # Did we find a PATH for the user?
-   [ ! -s $USR_PATH ] && return
+   [ ! -s $USR_PATH ] && {
+   	delete $USR_PATH
+	return
+   }
 
    # Sort and uniq the $USR_PATH file.
    $SORT -u $USR_PATH | 
@@ -398,8 +427,8 @@ check_user()
       if [ $uid = '0' ]; then
          check_permissions $dir $Tiger_ROOT_PATH_OK_Owners $Tiger_ROOT_PATH_OK_Group_Write
       else
-	 ownok="$Tiger_PATH_OK_Owners\|$user"
-	 groupok="$Tiger_PATH_OK_Group_Write\|$user"
+	 ownok="$Tiger_PATH_OK_Owners|$user"
+	 groupok="$Tiger_PATH_OK_Group_Write|$user"
          check_permissions $dir $ownok $groupok $user
       fi
    done
