This file is indexed.

/usr/share/rkhunter/scripts/readlink.sh is in rkhunter 1.4.2-5.

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
#!/bin/sh

#
# This is a short script to get the full pathname of a link file.
# It has the same effect as the Linux 'readlink -f' command. The
# script was written because some systems have no 'readlink' command,
# and others have no '-f' option for readlink. As such we use the 'ls'
# and 'awk' commands to get the link target.
#
# We check the 'pwd' command because the shell builtin command will
# usually print out the current directory, which may be a link, rather
# than the true working directory. The (typically) '/bin/pwd' command
# itself shows the true directory.
#
# A soft (symbolic) link has two parts to it:
#
#       linkname -> target
#
# Usage: readlink.sh [-f] <linkname> [pwd command]
#


#
# We don't actually do anything with the '-f' option
# if it is used.
#

test "$1" = "-f" && shift

LINKNAME=$1
PWD_CMD=$2

test -z "${PWD_CMD}" -o ! -x "${PWD_CMD}" && PWD_CMD="pwd"


#
# If we were given just a filename, then prepend
# the current directory to it.
#

if [ -z "`echo \"${LINKNAME}\" | grep '/'`" ]; then
	DIR=`${PWD_CMD}`
	test "${DIR}" = "/" && DIR=""

	LINKNAME="${DIR}/${LINKNAME}"
fi


#
# Now do some tests on the link name.
#

if [ -d "${LINKNAME}" ]; then
	FNAME=""
	DIR="${LINKNAME}"
else
	#
	# We have been given a pathname to a file. Separate
	# out the filename and the directory.
	#

	FNAME=`echo "${LINKNAME}" | sed -e 's:^.*/\([^/]*\)$:\1:'`
	DIR=`echo "${LINKNAME}" | sed -e 's:/[^/]*$::'`


	# Check if it is a top-level name.

	if [ -z "${DIR}" ]; then
		if [ ! -e "${LINKNAME}" ]; then
			DIR="${LINKNAME}"
		else
			DIR="/"
		fi
	fi

	if [ ! -d "${DIR}" ]; then
		echo "Directory ${DIR} does not exist." >&2
		echo "${LINKNAME}"
		exit
	fi
fi


#
# Get the true directory path.
#

DIR=`cd ${DIR}; ${PWD_CMD}`


#
# If we were only given a directory name, then return
# its true path.
#

if [ -z "${FNAME}" ]; then
	echo "${DIR}"
	exit
fi


#
# Now we loop round while we have a link.
#

RKHLINKCOUNT=0
ORIGLINK="${LINKNAME}"

while test -h "${DIR}/${FNAME}"; do
	#
	# Get the link directory, and the target.
	#

	LINKNAME="${DIR}"
	FNAME=`ls -ld "${DIR}/${FNAME}" | awk '{ print $NF }'`


	#
	# If the target is just a filename, then we
	# prepend the link directory path. If it isn't
	# just a filename, then we have a pathname. That
	# now becomes our new link name.
	#

	if [ -z "`echo \"${FNAME}\" | grep '^/'`" ]; then
		LINKNAME="${LINKNAME}/${FNAME}"
	else
		LINKNAME="${FNAME}"
	fi


	#
	# Once again, extract the file name and the directory
	# path, and then get the real directory path name.
	#

	FNAME=`echo "${LINKNAME}" | sed -e 's:^.*/\([^/]*\)$:\1:'`
	DIR=`echo "${LINKNAME}" | sed -e 's:/[^/]*$::'`

	DIR=`cd ${DIR}; ${PWD_CMD}`

	RKHLINKCOUNT=`expr ${RKHLINKCOUNT} + 1`

	if [ ${RKHLINKCOUNT} -ge 64 ]; then
		echo "Too many levels of symbolic links (${RKHLINKCOUNT}): ${ORIGLINK}" >&2
		echo "${ORIGLINK}"
		exit
	fi
done


#
# At this point we have a pathname to a file, which is not
# a link. To ensure we have the true pathname, we once again
# extract the directory.
#

FNAME=`echo "${LINKNAME}" | sed -e 's:^.*/\([^/]*\)$:\1:'`
DIR=`echo "${LINKNAME}" | sed -e 's:/[^/]*$::'`

test -n "${DIR}" && DIR=`cd ${DIR}; ${PWD_CMD}`

echo "${DIR}/${FNAME}"

exit