/usr/lib/tiger/scripts/check_services is in tiger 1:3.2.3-12.
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 | #!/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_services - 04/16/2003
#
# Check which services are configured in the system (usually in
# /etc/services) versus the ones that should be configured (in the
# provided services file)
#
# check_services - 10/18/2003 - jfs - Avoid misreports for services which
# are not defined in /etc/services but are generated by gen_services.
# Patch submitted by Dale Martin.
# check_services - 08/14/2003 - jfs - Added OUTPUTMETHOD to dependancies also
# incorporated tara's 3.0.3 changes
# check_services - 08/09/2003 - jfs - Added RM to dependancies.
# check_services - 08/08/2003 - jfs
# Created securely the $tmpservices file, otherwise, if the directory
# $WORKDIR is not secure it could be exploited as a race condition.
# check_services - 04/23/2003 - jfs
# Fixed requirements
# check_services - 04/16/2003 - jfs
# Separated check_services from check_inetd
# Modified script so that it does not FAIL on services which are
# already duplicated in the OS service file.
# check_inetd - 05/27/2002 - jfs
# Changed TigerInstallDir to .
# check_inetd - 12/13/01 - jfs
# Fixes to avoid false positives
# check_inetd - 04/20/99
# Portions corrected y Advanced Research Corporation (R)
#
#-----------------------------------------------------------------------------
#
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 SED AWK CAT GEN_SERVICES_SETS GREP JOIN SORT RM OUTPUTMETHOD || exit 1
haveallfiles BASEDIR WORKDIR SERVICESFILE || exit 1
echo "--CONFIG-- [init003c] $0: Configuration ok..."
exit 0
}
#------------------------------------------------------------------------
echo
echo "# Performing check of 'services' ..."
haveallcmds SED AWK CAT GEN_SERVICES_SETS GREP JOIN SORT RM OUTPUTMETHOD || exit 1
haveallfiles BASEDIR WORKDIR SERVICESFILE || exit 1
saveifs=$IFS
tmpservices=$WORKDIR/sec.$$ts
safe_temp "$tmpservices"
trap 'delete $tmpservices ; exit 1' 1 2 3 15
checkservices ()
{
services="$1"
# Check that these services have the correct port assigned.
while read currservice currport
do
[ ! -z "$currport" ] && {
matches="`$AWK '{ print $2 \" \" $1}' $services | $GREP \"^$currport \" | $AWK '{ print $1 }'`"
IFS=/
set $currport
IFS=$saveifs
currportnum=$1
serviceok="N"
# Note: The message is not sent and the serviceok variable is used
# so that problems with repeated entries do not lead to false positives
# (jfs, debian bug #123730)
for port in $matches
do
IFS=/
set $port
IFS=$saveifs
if [ "$1" = "$currportnum" ]; then
serviceok="Y"
fi
done
# added to handle when /etc/services has less services than the
# reference file
if [ "$matches" = "" ]; then serviceok="Y"; fi
if [ "$serviceok" = "N" ]; then
message FAIL inet002f "" "Service $currservice is assigned to port $port which should be $currport."
fi
}
done < $SERVICESFILE
# Check that these services are not set for any other services.
while read currservice currport
do
matches=`$GREP " $currport$" $services | $AWK '{ print $1 }'`
for service in $matches
do
if [ $service != $currservice ]; then
origmatch=`$GREP " $currport$" $SERVICESFILE | $AWK '{ print $1 }' | $GREP $service`
[ -z "$origmatch" ] &&
message WARN inet003w "" "The port for service $currservice is also assigned to service $service."
fi
done
done < $SERVICESFILE
# Print out any other entries that have been added
$AWK '{ print $1 " " $2 }' $services |
$GREP -v '^#' | $GREP -v '^ $' | $SORT |
while read currservice currport
do
matchescount=""
matches=`$AWK '{ print $1 " " $2 }' $SERVICESFILE | $GREP " $currport$" | $AWK '{ print $1 }'`
for service in $matches
do
if [ $service = $currservice ]; then
matchescount="$matchescount."
fi
done
if [ "x$matchescount" = "x" ]; then
message INFO inet004i "" "$currservice is $currport (local addition)."
fi
done
}
realpath="$REALPATH -d"
[ ! -n "$REALPATH" -o ! $TESTEXEC "$REALPATH" ] && realpath="echo"
{
haveallcmds GEN_SERVICES_SETS &&
haveallfiles SERVICESFILE && {
$GEN_SERVICES_SETS |
while read services_set
do
echo "# Checking services from `$CAT $services_set.src`."
$AWK '!/^#/ { print $1, $2 }' $services_set |
$SED -e '/^$/d' |
$SORT -u > $tmpservices
checkservices $tmpservices
delete $services_set $services_set.src $tmpservices
done
}
} |
$OUTPUTMETHOD
exit 0
|