This file is indexed.

/usr/lib/tiger/scripts/check_path is in tiger 1:3.2.3-10.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
#!/bin/sh
#
#     tiger - A UN*X security checking system
#     Copyright (C) 1993 Douglas Lee Schales, David K. Hess, David R. Safford
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2, or (at your option)
#    any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#     Please see the file `COPYING' for the complete copyright notice.
#
# check_path  - 06/14/93
#
# 05/02/2004 jfs  Try to avoid eval problems if handling variables with
#                 special characters (such as space)
# 10/07/2003 jfs Redirected LS error to /dev/null since dangling symlinks
#                will print errors. Properly cleaned temporary file.
# 09/19/2003 jfs Use -L to check properly for symlinks (I've checked and
#                its supported by all the LS implementations I've seen)
#                (Fixes Debian Bug #161993)
# 08/14/2003 jfs Added OUTPUTMETHOD to dependancies
# 08/13/2003 jfs Return if the files do not exist (a safeguard for the
#                functions but these is redundant code anyway)
# 08/08/2003 jfs Improved temporary file creation.
# 10/22/2002 jfs Fixed check for PATH in config files (was not done properly
#            due to the way it was being tested)
# 07/25/2002 jfs Added a sanity check for password files
# ARC check_path - 05/10/99  Fixed problem with parse_csh
#
#
#-----------------------------------------------------------------------------
#
TigerInstallDir="/usr/lib/tiger"

#
# Set default base directory.
# Order or preference:
#      -B option
#      TIGERHOMEDIR environment variable
#      TigerInstallDir installed location
#
basedir=${TIGERHOMEDIR:=$TigerInstallDir}

for parm
do
   case $parm in
   -B) basedir=$2; break;;
   esac
done

#
# Verify that a config file exists there, and if it does
# source it.
#
[ ! -r $basedir/config ] && {
  echo "--ERROR-- [init002e] No 'config' file in \`$basedir'."
  exit 1
}

. $basedir/config

. $BASEDIR/initdefs
#
# If run in test mode (-t) this will verify that all required
# elements are set.
#
[ "$Tiger_TESTMODE" = 'Y' ] && {
  haveallcmds AWK GEN_PASSWD_SETS GREP JOIN RM SED TR OUTPUTMETHOD || exit 1
  haveallfiles BASEDIR WORKDIR || exit 1
  haveallvars HOSTNAME || exit 1
  
  echo "--CONFIG-- [init003c] $0: Configuration ok..."
  exit 0
}

#------------------------------------------------------------------------

echo
echo "# Performing check of PATH components..."

haveallcmds AWK GEN_PASSWD_SETS GREP JOIN RM SED TR OUTPUTMETHOD || exit 1
haveallfiles BASEDIR WORKDIR || exit 1

safe_temp $WORKDIR/pth.$$
trap 'delete $WORKDIR/pth.$$ ; exit 1' 1 2 3 15

checkcmds()
{
  _user="$1"
  _dir="$2"
  _srcfile="$3"

  okown=$Tiger_ROOT_PATH_OK_Owners
  [ "$_user" != 'root' ] && okown=$Tiger_PATH_OK_Owners
  [ ! -n "$okown" ] && okown='root'

  okgroup=$Tiger_ROOT_PATH_OK_Group_Write
  [ "$_user" != 'root' ] && okgroup=$Tiger_PATH_OK_Group_Write

  [ -d $_dir ] &&
  $LS -Ld $_dir/*  2>/dev/null|
  getpermit |
  while read _execfile _owner _group ur uw ux gr gw gx or ow ox suid sgid stk
  do
    [ "$ux$gx$ox" != '000' ] && {
      [ -n "$TigerCheckEmbedded" -a "$_user" = 'root' ] && {
	echo "$_execfile /$_srcfile(PATH)" >> $TigerCheckEmbedded
      }
      
      [ "$gw" = '1' -a -n "$okgroup" ] && {
	eval "case \"$_group\" in
	  $okgroup) gw=0;;
	esac"
      }
      
      case "$gw$ow" in
	00) _msg='';;
	01) _msg='world'; __newmode='o-w';;
	10) _msg="group \`$_group'"; __newmode='g-w';;
	11) _msg="group \`$_group' and world";__newmode='go-w';;
	*) _msg='';;
      esac
      [ -n "$_msg" ] && {
	message WARN path001w "" "$_execfile in $_user's PATH from $_srcfile is $_msg writable."
	changelog "WARN : chmod : $__newmode : $_execfile"
      }
      if [ "$suid" = '0' ]; then
	eval "case \"\$_owner\" in
	  $okown);;
	  *) message WARN path002w \"\" \"$_execfile in $_user's PATH from $_srcfile is not owned by root (owned by $_owner).\"
	  changelog \"WARN : chown : root : $_execfile\"
	  ;;
	esac"
      else
	eval "case \"$_owner\" in
	  $okown);;
	  *) message INFO path008i \"\" \"Setuid program $_execfile in $_user's PATH from $_srcfile is not owned by root (owned by $_owner).\";;
	esac"
      fi
    }
  done
}

parse_path()
{
  user="$1"
  file="$2"
  pth="$3"
  saveifs=$IFS

  [ ! -n "$pth" -a "$user" = 'root' ] && {
    message INFO path003i "" "Unable to ascertain PATH from $user's $file."
    return
  }

  case "$pth" in
    *:) pth="${pth}.";;
  esac
  
  IFS=:
  set X $pth
  IFS=$saveifs
  shift
  
  dotinpath=
  
  for pcomp
  do
    comp="${pcomp:=.}"
    if [ "$comp" = '.' ]; then
      dotinpath=Y
      [ "$user" = 'root' ] && {
	message WARN path004w "" "PATH in $user's $file contains '.'"
      }
    elif [ -d "$comp" ]; then
      lgetpermit "$comp" |
      pathmsg path006 path007 "$comp" "$user" "The PATH set in $user's $file contains"
    fi
    [ "$user" = 'root' -a "$comp" != '.' ] && checkcmds $user "$comp" "$file"
  done
  [ "$lastcomp" != '.' -a -n "$dotinpath" ] && {
    message WARN path005w "" "'.' in PATH from $user's $file is not the last entry."
  }
}

#
# Parse Bourne SHell style file (sh, ksh, bash)
#
# This creates a file which all contains variable assignments in
# it.  We try to strip out command substitions or anything else
# that might execute a command, but...
#
parse_bsh()
{
  user="$1"
  dir="$2"
  file="$3"
  [ ! -f "$dir/$file" ] && return
  
  $AWK '
  BEGIN {LINE="";}
  $0 ~ /\\$/ {printf("%s ", substr($0, 1, length($0)-1));}
  $0 !~ /\\$/ {printf("%s\n", $0);}
  END {printf("\n");}
  ' $dir/$file |
  $GREP -v '".*;.*"' |
  $TR ';' '\012' |
  # Bob Hall suggests chaging the SED from
  # -e 's/\${\([a-zA-Z_][a-zA-Z0-9_]*}[^a-zA-Z0-9_]\)/${XXX_\1/g' \
  # to
  # -e 's/\${\([a-zA-Z_][a-zA-Z0-9_]*}\)$/${XXX_\1/g' \
  # on HP-UX 
  # TODO:(does this apply to other OS?
  $SED -e 's/#.*$//' \
       -e '/^$/d' \
       -e 's/^[ 	]*//' \
       -e 's/export[ 	][ 	]*//' \
       -e 's/^setenv[ 	]*\([a-zA-Z_][a-zA-Z0-9_]*\)[ 	]*\(.*\)$/XXX_\1=\2/g' \
       -e 's/^\([a-zA-Z_][a-zA-Z0-9_]*=.*\)$/XXX_\1/g' \
       -e 's/\$\([a-zA-Z_][a-zA-Z0-9_]*[^a-zA-Z0-9_]\)/$XXX_\1/g' \
       -e 's/\$\([a-zA-Z_][a-zA-Z0-9_]*\)$/$XXX_\1/g' \
       -e 's/\$([^)]*)//g' \
       -e 's/`[^`]*`//g' |
  $GREP -v '`' |
  $GREP -v '\$(' |
  $GREP -v '^.*=[^ 	]*[ 	]' |
  $GREP -v 'DISPLAY' |
  $GREP '^XXX_[a-zA-Z_][a-zA-Z0-9]*=' > $WORKDIR/pth.$$
  #
  # Now, source the file to get variable values.
  # Use a subshell so we don't contaminate.  Everything
  # should start with XXX_, but take no chances if IFS.
  #
  (
    XXX_USER="$user"
    XXX_LOGNAME="$user"
    XXX_HOME="$dir"
    saveifs=$IFS
    . $WORKDIR/pth.$$
    IFS=$saveifs
    delete $WORKDIR/pth.$$
    parse_path $user $file "$XXX_PATH"
  )
}

#
# Parse C SHell style file (csh, tcsh)
#
# This creates a file which contains all variable assignments (sh style)
# in it.  We try to strip out command substitions or anything else
# that might execute a command, but...
#
parse_csh()
{
  user="$1"
  dir="$2"
  file="$3"

  [ ! -f "$dir/$file" ] && return
  
  $AWK '
  $0 ~ /\\$/ {printf("%s ", substr($0, 1, length($0)-1));}
  $0 !~ /\\$/ {print}
  END {printf("\n");}
  ' $dir/$file |
  $GREP -v '".*;.*"' |
  $TR ';' '\012' |
  $SED -e 's/#.*$//' \
       -e '/^$/d' \
       -e 's/^[ 	]*//' \
       -e 's/[()]//g' \
       -e 's/^set \([a-zA-Z_][a-zA-Z0-9_]*\)[ 	]*=[ 	]*\(.*\)$/XXX_\1=\2/g' \
       -e 's/^setenv[ 	]*\([a-zA-Z_][a-zA-Z0-9_]*\)[ 	]*\(.*\)$/XXX_\1=\2/g' \
       -e 's/[ 	]$//' \
       -e 's/[ 	]/:/g' \
       -e 's%~%'"$dir"'%g' \
       -e 's/\$\([a-zA-Z_][a-zA-Z0-9_]*[^a-zA-Z0-9_]\)/$XXX_\1/g' \
       -e 's/\$\([a-zA-Z_][a-zA-Z0-9_]*\)$/$XXX_\1/g' \
       -e 's/XXX_path/XXX_PATH/g' \
       -e 's/`[^`]*`//g' \
       -e '/\$</d' |
  $GREP -v '`' |
  $GREP -v 'DISPLAY' |
  $GREP -v '^.*=[^ 	]*[ 	]' |
  $GREP '^XXX_[a-zA-Z_][a-zA-Z0-9]*=' > $WORKDIR/pth.$$
  #
  # Now, source the file to collect variable values.  Use
  # a subshell so we don't contaminate.  Everything should
  # start with XXX_, but take no chances with IFS.
  #
  (
    XXX_USER="$user"
    XXX_LOGNAME="$user"
    XXX_HOME="$dir"
    saveifs=$IFS
    . $WORKDIR/pth.$$
    IFS=$saveifs
    delete $WORKDIR/pth.$$
    parse_path $user $file "$XXX_PATH"
  )
}

check_user()
{
  user="$1"
  dir="$2"

  [ -s $dir/.profile ] && parse_bsh $user $dir .profile
  [ -s $dir/.cshrc ] && parse_csh $user $dir .cshrc
  [ -s $dir/.login ] && parse_csh $user $dir .login
  [ -s $dir/.tcshrc ] && parse_csh $user $dir .tcshrc
  [ -s $dir/.bashrc ] && parse_bsh $user $dir .bashrc
  [ "$user" = 'root' -a ! -f $dir/.profile ] && {
    parse_path $user default $SYSDEFAULTPATH
  }
  # Only do this if no /bin/csh config files, but there IS a /bin/sh config
  [ "$user" = 'root' -a ! -f $dir/.cshrc -a ! -f $dir/.login -a -f $dir/.profile ] && {
    parse_path $user default $SYSDEFAULTPATH
  }
}

realpath="$REALPATH -d"

[ ! -n "$REALPATH" -o ! $TESTEXEC "$REALPATH" ] && realpath="echo"

[ ! -n "$SYSDEFAULTPATH" ] && {
  SYSDEFAULTPATH="/bin:/usr/bin:/usr/sbin"
}
[ -n "$Tiger_Global_PATH" ] && {
  for file in $Tiger_Global_PATH
    do
      [ -r $file ] && {
        case $file in
          /etc/profile|/etc/bashrc)
            found=`$GREP -v \# $file | $GREP PATH | $GREP export 2>/dev/null`
            if [ -z "$found" ]; then
                message WARN path009w "" "$file does not export an initial setting for PATH."
            fi
            ;;
          /etc/csh.login)
            found="`$GREP -v \# $file | $GREP PATH | $GREP setenv 2>/dev/null`" 
            if [ -z "$found" ]; then
                message WARN path009w "" "$file does not setenv an initial setting for PATH."
            fi
            ;;
         *)
            found="`$GREP -v \# $file | $GREP PATH `"
            if [ -z "$found" ]; then
                message WARN path009w "" "$file does not have an initial setting for PATH."
            fi
            ;;
       esac
      }
    done
}

{
  if [ "$TIGER_Check_PATHALL" = 'Y' ]; then
    haveallcmds GEN_PASSWD_SETS &&
    haveallvars HOSTNAME && {
      {
	if [ -n "$Tiger_PasswdFiles" ]; then
	  [ -f "$Tiger_PasswdFiles" ] && $CAT "$Tiger_PasswdFiles" > $WORKDIR/pass.list.$$
	else
	  $GEN_PASSWD_SETS $WORKDIR/pass.list.$$
	fi
      }
      while read passwd_set
      do
	echo
	echo "# Checking accounts from `$CAT $passwd_set.src`..."
  
	$AWK -F: '{print $1, $6}' $passwd_set |
	$BASEDIR/util/${GETFSHOST:=getfs-std} > $WORKDIR/home.hosts.$$
      
	$AWK -F: '{ printf("%s %s\n", $1, $6); }' $passwd_set |
	$JOIN -o 1.1 1.2 2.3 - $WORKDIR/home.hosts.$$ |
	while read user homedir host
	do
	  [ "$host" = "$HOSTNAME" ] && {
	    check_user $user $homedir
	  }
	done
	[ ! -n "$Tiger_PasswdFiles" ] && delete $passwd_set $passwd_set.src
	delete $WORKDIR/home.hosts.$$
      done < $WORKDIR/pass.list.$$
	delete $WORKDIR/pass.list.$$
    }
  else
    echo "# Only checking user 'root'"
    check_user root /
  fi
} |
$OUTPUTMETHOD

delete $WORKDIR/pth.$$

exit 0