This file is indexed.

/usr/sbin/update-inetd is in rlinetd 0.9-2.

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
#!/bin/sh
# vim:ts=4:sts=4:fdm=marker:cms=\ #\ %s
#
# rlinetd's version of update-inetd.
# Robert Luberda <robert@debian.org>, 2001, 2009, 2011, 2013
#

set -e

PATH=/usr/sbin:$PATH

# global variables
g_version='0.9-2'
g_rlinconfdir="/etc/rlinetd.d"
g_ucfdir="/var/lib/rlinetd/ucf"

g_debug=0
g_need_reload=0
g_line=""
g_mode=""

# error - prints error message and exits the program  # {{{
error()
{
	msg="$1"
	echo "update-inetd: $msg" >&2
	debug "Program arguments: --$g_mode \"$line\""
	exit 1
} # }}}

# debug - prints debug info # {{{
debug()
{
	[ $g_debug -eq 1 ] || return 0
	msg="$1"
	echo "$msg"
} # }}}

# check_debconf - ugly hack to check if debconf is still running # {{{
check_debconf()
{
  conffile="$1"
  if [ "$DEBIAN_HAS_FRONTEND" ] &&  [ -e /usr/share/debconf/confmodule ] && [ $(id -u) = 0 ]; then
	status=0
	tmseconds=15

	debug "Checking (for up to $tmseconds seconds) if debconf is running"
	timeout -k 1 "$tmseconds" /bin/sh -c '. /usr/share/debconf/confmodule; db_version > /dev/null' \
		|| status="$?"
	debug "debconf check status: $status"

	case "$status" in
		0) # OK, debconf is running
			;;
		124|137) # debconf hung
			error \
"The \"${DPKG_MAINTSCRIPT_PACKAGE:-unknown}\" package stops debconf before calling update-inetd!
 This prevents rlinetd's version of update-inetd from updating file ${conffile}.
 Please report this as a bug in package \"${DPKG_MAINTSCRIPT_PACKAGE:-rlinetd}\".

 Note: update-inetd was called with the following arguments:
 $0 --$g_mode \"$line\"
"
			;;
		*) # something strange has just happend
			error \
"internal error: cannot check debconf, timeout command failed with $status
 Please report this as a bug in package rlinetd.
"
			;;
		esac
	fi
} # }}}

# ucf_ack - asks user a question using ucf # {{{
ucf_ask()
{
	cachedfile="$1"
	conffile="$2"

	if [ ! -e "$conffile" ] || ! cmp -s "$cachedfile" "$conffile"; then
		check_debconf "$conffile"
		debug "Running ucf on $cachedfile and $conffile"
		ucf --three-way --debconf-ok "$cachedfile" "$conffile"
		ucfr "rlinetd" "$conffile"
		g_need_reload=1
	else
		debug "$cachedfile and $conffile identical, skipping ucf"
	fi

} # }}}

# ucf_purge - purges ucf configuration # {{{
ucf_purge()
{
	conffile="$1"

	debug "Removing $conffile from ucf"
	ucf --purge "$conffile"
    ucfr --purge "rlinetd" "$conffile" || true
	g_need_reload=1
} # }}}

# enable_disable_util - enables or disables an entry # {{{
enable_disable_util()
{
	cachedfile="$1"
	conffile="$2"
	enable="$3"

	debug "Setting enable to $3 in $cachedfile"

	sed -e "s/^\([ \t]*enabled[ \t][ \t]*\).*$/\1$enable;/" < "$cachedfile" >  "$cachedfile.tmp"
	mv "$cachedfile.tmp"  "$cachedfile"


	ucf_ask "$cachedfile" "$conffile"

} # }}}

# enable - calls enable_disable_util to enable an entry # {{{
enable()
{
	enable_disable_util "$1" "$2" "yes"
} # }}}

# disable - calls enable_disable_util to disable an entry # {{{
disable()
{
	enable_disable_util "$1" "$2" "no"
} # }}}

# remove - removes an entry # {{{
remove()
{
	cachedfile="$1"
	conffile="$2"

	debug "Removing $cachedfile, $conffile"

	rm -f "$cachedfile" "$conffile"
	ucf_purge "$conffile"

} # }}}

# remove_regexp - removes an entry based on regexp # {{{
remove_regexp()
{
	regexp="$1"
	regexp="^# Generated from: ${regexp#^}"
	debug "Searching for files matching \"$regexp\""
	files=`cd $g_ucfdir && egrep -l "$regexp" -- *`
	[ "$files" ] || { debug "None found"; return 1; }
	debug "Found: $files"
	for basefile in $files; do
		remove "$g_ucfdir/$basefile" "$g_rlinconfdir/$basefile"
	done
	return 0

} # }}}

# add - adds a new entry # {{{
add()
{
	line="$1"
	files=`inetd2rlinetd --force-overwrite --print-file-names --add-from-comment -l "$line" "$g_ucfdir"`
	debug "Converted $line saved in $files"
	[ -z "$file" ] || return 0

	for file in $files; do
		file="${file##*/}"
		case "$file" in
			*_udp)
				basename="${file%_*}"
				if [ ! -e "$g_rlinconfdir/$file" ] &&
					[ ! -e "$g_ucfdir/$basename" ]  &&
					[ -f "$g_rlinconfdir/$basename" ]; then
					# rename previous versions of file
					debug "Renaming $g_rlinconfdir/$basename to $g_rlinconfdir/$file"
					mv -f "$g_rlinconfdir/$basename" "$g_rlinconfdir/$file"
				fi
				;;
		esac

		ucf_ask "$g_ucfdir/$file" "$g_rlinconfdir/$file"
	done
} # }}}

# operation  - calls add, remove, enable or disable # {{{
operation()
{
	operation="$1"
	line="$2"

	[ -n "$line" ] || error "--$operation requires argument"

	debug "Running $operation for $line"

	# add
	if [ "$operation" = "add" ]; then
		add "$line"
		return 0
	fi

	# disable, enable: line can be comma separated list of values
	# remove: treat line as is.
	service=""
	found=0
	while [ "$line" != "$service" ] ; do
		if [ "$operation" = "remove" ] ; then
			service="$line"
		else
			service="${line%,*}"
			line="${line#*,}"
		fi

		for proto in "" _udp; do
			basefile="${service}${proto}"
			file="$g_ucfdir/$basefile"
			debug "Checking for file $file"
			if [ -e "$file" ]; then
				found=1
				"$operation" "$file" "$g_rlinconfdir/$basefile"
			fi
		done

		if [ $found -eq 0 ] && [ "$operation" = "remove" ]; then
			! remove_regexp "$line" || found=1
		fi

		if [ $found -eq 0 ]; then
			echo "Cannot find cached rlinetd's config files for service $service, ignoring $operation request" >&2;
		fi
	done
} # }}}

# reload_rlinetd - reloads rlinetd daemon # {{{
reload_rlinetd()
{
	if [ "$g_need_reload" -eq 0 ]; then
		debug "Configuration not changed, not reloading rlinetd"
		return 0
	fi

	debug "Reloading rlinetd config files"

    killall -HUP rlinetd || true
} # }}}


# MAIN FUNCTION # {{{

# parse arguments # {{{
ignore_next=0
for i in "$@" ; do
    # note: the original update-inetd allows things  like "--add --comment-chars XX LINE_TO_ADD"
    if [ "$ignore_next" -eq 1 ] ; then
		ignore_next=0
		continue
	fi

	case "$i" in
		"--add"|"--remove"|"--disable"|"--enable")
			[ -z "$mode" ] || error "$i conflicts with --$mode"
			g_mode="$i"
			g_mode="${g_mode#--}"
			;;
		"--debug")
			g_debug=1
			;;
		"--version")
			echo "rlinetd's version of update-inetd"
			echo "version: $g_version"
			exit 0
			;;
		"--multi"|"--verbose")
			# ignore
			;;
		"--file"|"--group"|"--comment-chars")
			ignore_next=1
			;;
		"--*")
			echo "Unknown option \`$i\' passed to $0, ignoring" >&2;
			;;
		*)	if [ -n "$g_mode" ] ; then
				[ -z "$g_line" ] || error "--$g_mode requires only one argument"
				g_line="$i"
			fi
			;;
	esac
done # }}}

# do our job
[ -z "$g_mode" ] || operation "$g_mode" "$g_line"

# reload configuration
reload_rlinetd

# execute real update-inetd
real_upd=`dpkg-divert --truename /usr/sbin/update-inetd`
[ -x "$real_upd" ] && exec "$real_upd" "$@"

exit 0
 # }}}