This file is indexed.

/var/lib/pcp/testsuite/069 is in pcp-testsuite 3.8.12ubuntu1.

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
#! /bin/sh
# PCP QA Test No. 069
# Test pmcd's ability to supress multiple access control warnings from the same
# host
#
# Copyright (c) 1995-2002 Silicon Graphics, Inc.  All Rights Reserved.
#

seq=`basename $0`
echo "QA output created by $seq"

# get standard filters
. ./common.product
. ./common.filter
. ./common.check

# ideally want a host with only 1 network interface ... getpmcdhosts
# cannot express this, so we used to go for 1 CPU as a likely co-condition,
# but even that has been dropped now that single CPU systems are so
# rare
#
eval `./getpmcdhosts -L -n2 | sed -e 's/^/other1=/' -e 's/ / other2=/'`
[ -z "$other1" ] && _notrun "Cannot find first remote host running pmcd"
[ -z "$other2" ] && _notrun "Cannot find second remote host running pmcd"

ipv6=false
eval `pmconfig -L 2>/dev/null`		# get IPv6, unix domain sockets status

rm -f $seq.out
if $ipv6
then
    ln $seq.out.ipv6 $seq.out || exit 1
else
    ln $seq.out.ipv4 $seq.out || exit 1
fi

# real QA test starts here

status=0
signal=$PCP_BINADM_DIR/pmsignal
usersignal=pmsignal	# not run as root, which may lose pcpqa PATH setting
config=$PCP_PMCDCONF_PATH
oconfig=${PCP_PMCDCONF_PATH}.save.$seq
nconfig=$tmp.pmcd.conf.new
log=$PCP_PMCDLOG_PATH
LOCALHOST=`hostname`
LOCALHOST_FULL=`pmhostname`
_needclean=true

rm -f $seq.full

_filter_log()
{
    fixed_width_ip="                        "
    sed <$log \
	-e 's/$/ /' \
	-e '/^irix/s/\/var\//\/usr\//' \
	-e '/^00[08]:/d' \
	-e 's/ \[0x[0-9a-f]*]//' \
	-e 's/ \[(nil)]//' \
	-e "s,$PCP_RUN_DIR,PCP_RUN_DIR,g" \
	-e "/$LOCALHOST\$/s/$LOCALHOST\$/ME/" \
	-e "s/ 127\.0\.0\.1 / MY_IP /" \
	-e "s/ ::1 / MY_IP /" \
	-e "s/ $me_ip / MY_IP /" \
	-e "s/ $other1_ip / OTHER1_IP /" \
	-e "s/ $other2_ip / OTHER2_IP /" \
	-e "s/ \(OTHER._IP\) *\( 255.255.255.255\) / \1 ${fixed_width_ip} \2 /" \
	-e '/access violation .* [0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\.[0-9]/{
N
d
}' \
	-e "s/ $me_xip / MY_HEXIP /" \
	-e "s/ $other1 / OTHER_1 /" \
	-e "s/ $other1_xip / OTHER1_HEXIP /" \
	-e "s/ $other2 / OTHER_2 /" \
	-e "s/ $other2_xip / OTHER2_HEXIP /" \
	-e 's/fd [0-9-][0-9]*/fd <n>/g' \
	-e '/client\[[0-9][0-9]*\]/s//client[N]/' \
	-e '/lib=.*\.'"$DSO_SUFFIX"'/s/[0-9] dso/N dso/' \
	-e 's/ $//' \
    | $PCP_AWK_PROG '
BEGIN				{ skip = 0 }
/client connection from/	{ print; print "..."; skip=1; next }
skip == 1 && NF == 0		{ skip = 0 }
skip == 1			{ next }
				{ print }' \
    | _filter_pmcd_log | \
    sed \
	-e '/UNIX_DOMAIN_SOCKET/d' \
	-e '/unix:/d'
}

if [ -d $PCP_LOG_DIR/pmlogger ]
then
    LOGGING_DIR=$PCP_LOG_DIR/pmlogger
else
    LOGGING_DIR=$PCP_LOG_DIR
fi

cleanup()
{
    if $_needclean
    then
        _needclean=false
	if [ -f $oconfig ]
	then
	    $sudo cp $oconfig $config
	    $sudo rm -f $oconfig
	fi
	unset PMCD_PORT # don't worry about preserving just get rid of it
	pmafm $LOGGING_DIR/$LOCALHOST/Latest remove >$tmp.cmd 2>&1 \
	&& $sudo sh $tmp.cmd
	echo "Restarting pmcd"
	$sudo $PCP_RC_DIR/pcp restart >/dev/null
	_wait_for_pmcd
	_wait_for_pmlogger
    fi
    rm -f $tmp.*
}

interrupt()
{
    trap 1 2 3 15
    echo "Interrupted"
    cleanup
    status=1
}

trap "interrupt; exit \$status" 1 2 3 15
trap "cleanup; exit \$status" 0

cat <<End-of-File >$tmp.c
#include <pcp/pmapi.h>
#ifdef HAVE_NETWORK_BYTEORDER
yes
#else
no
#endif
End-of-File

network_byteorder=`cc -E $tmp.c | sed -e '/^ *$/d' | tail -1`

_get_hex_addr()
{
    if [ $network_byteorder = yes ]
    then
	echo $1 \
	| $PCP_AWK_PROG -F '.' '{ printf "%02x%02x%02x%02x", $1, $2, $3, $4 }'
    else
	echo $1 \
	| $PCP_AWK_PROG -F '.' '{ printf "%02x%02x%02x%02x", $4, $3, $2, $1 }'
    fi
}

pmafm $LOGGING_DIR/$LOCALHOST/Latest remove >$tmp.cmd 2>&1 \
&& $sudo sh $tmp.cmd

echo "host1 = $other1" >>$seq.full
echo "host2 = $other2" >>$seq.full

# pick a tcp port that is not in use
#
port=`_get_port tcp 4340 4350`
if [ -z "$port" ]
then
    echo "Arrgh ... no free TCP port in the range 4340 ... 4350"
    exit 1
fi
echo "port=$port" >>$seq.full

me_ip=`_host_to_ipaddr $LOCALHOST`
me_xip=`_get_hex_addr $me_ip`
other1_ip=`_host_to_ipaddr $other1`
other1_xip=`_get_hex_addr $other1_ip`
other2_ip=`_host_to_ipaddr $other2`
other2_xip=`_get_hex_addr $other2_ip`

echo "me: ip=$me_ip hex_ip=$me_xip" >>$seq.full
echo "host1: ip=$other1_ip hex_ip=$other1_xip" >>$seq.full
echo "host2: ip=$other2_ip hex_ip=$other2_xip" >>$seq.full

echo "# from qa/$seq" >$nconfig
egrep '^(linux|irix|darwin|solaris)' $config >>$nconfig
grep '^pmcd' $config >>$nconfig

$sudo cp $config $oconfig
$sudo cp $nconfig $config
echo "--- initial pmcd.conf ---" >>$seq.full
cat $config >>$seq.full
export PMCD_CONNECT_TIMEOUT=30
export PMCD_PORT=$port
echo "export PMCD_CONNECT_TIMEOUT=30" >$tmp.start
echo "export PMCD_PORT=$port" >>$tmp.start
echo "sh $PCP_RC_DIR/pcp restart" >>$tmp.start
$sudo sh $tmp.start 2>&1 \
| tee -a $seq.full \
| sed '/Wait/d' \
| _filter_pcp_start
_wait_for_pmcd
_wait_for_pmlogger

echo "should be OK"
pminfo -f pmcd.numclients # should be controlled now - determinate

cat <<End-of-File >>$nconfig

[access]
allow $other1: all except store, maximum 1 connections;
allow $other2: all, maximum 1 connections;
disallow *: all;
End-of-File
$sudo cp $nconfig $config

echo "=== local pmcd.conf ===" >>$seq.full
cat $config >>$seq.full

$sudo $signal -a -s HUP pmcd
sleep 5

echo
echo "expect two access control errors:"
# for Linux sometimes see "Connection reset by peer" ... this is believed
# to be a timing issue, and the results are semantically equivalent for
# the purposes of this test, so ...
pminfo -f pmcd.numclients 2>&1 \
| sed \
    -e "s/\"local:\"/\"LOCALHOST\"/" \
    -e 's/"'$LOCALHOST'"/"LOCALHOST"/' \
    -e 's/Connection reset by peer/No permission to perform requested operation/'
pminfo -f pmcd.numclients 2>&1 \
| sed \
    -e "s/\"local:\"/\"LOCALHOST\"/" \
    -e 's/"'$LOCALHOST'"/"LOCALHOST"/' \
    -e 's/Connection reset by peer/No permission to perform requested operation/'
echo

echo "expect two connection limit errors:"
cmd1='sh -c "PMCD_CONNECT_TIMEOUT=30 PMCD_PORT='$PMCD_PORT'; export PMCD_CONNECT_TIMEOUT PMCD_PORT; pmval -h '$LOCALHOST_FULL' pmcd.numclients"'
echo "cmd1: $cmd1" >>$seq.full
(ssh -q pcpqa@$other1 $cmd1  &) 1>$tmp.pmval 2>&1
sleep 5

# not sure how long it takes to get the remote pmval command started,
# and connected to pmcd so be prepared to try a few times ...
#
cmd2='sh -c "PMCD_CONNECT_TIMEOUT=30 PMCD_PORT='$PMCD_PORT'; export PMCD_CONNECT_TIMEOUT PMCD_PORT; pminfo -h '$LOCALHOST_FULL' -f pmcd.numclients"'
echo "cmd2: $cmd2" >>$seq.full
cnt=0
echo >$tmp.pminfo
for i in 1 2 3 4 5 6 7 8 9 10
do
    ssh -q pcpqa@$other1 $cmd2 >$tmp.tmp 2>&1
    echo "--- attempt $i ---" >>$tmp.pminfo
    cat $tmp.tmp >>$tmp.pminfo
    if grep 'connection limit' $tmp.tmp >/dev/null
    then
	# bingo!
	sed -e 's/".*"/"OTHERHOST1"/' <$tmp.tmp
	cnt=`expr $cnt + 1`
	[ $cnt -eq 2 ] && break
    fi
    sleep 1
done
if [ $cnt -ne 2 ]
then
    cat $tmp.pminfo
fi
ssh -q pcpqa@$other1 $usersignal -a pmval > /dev/null 2>&1
echo
echo "=== pmval output ===" >>$seq.full
cat $tmp.pmval >>$seq.full
echo "=== pminfo output ===" >>$seq.full
cat $tmp.pminfo >>$seq.full

echo "expect two connection limit errors:"
(ssh -q pcpqa@$other2 $cmd1 &) > $tmp.pmval 2>&1
sleep 5

# not sure how long it takes to get the remote pmval command started
# and connected to pmcd so be prepared to try a few times ...
#
found=false
echo >$tmp.pminfo
for i in 1 2 3 4 5 6 7 8 9 10
do
    ssh -q pcpqa@$other2 $cmd2 >$tmp.tmp 2>&1
    echo "--- attempt $i ---" >>$tmp.pminfo
    cat $tmp.tmp >>$tmp.pminfo
    if grep 'connection limit' $tmp.tmp >/dev/null
    then
	# bingo!
	sed -e 's/".*"/"OTHERHOST2"/' <$tmp.tmp
	found=true
	break
    fi
    sleep 1
done
$found || cat $tmp.pminfo
#
# Make this one a store to see if connection and access errors are treated the
# same way.  Note that pmstore fails with connection limit exceeded before it
# gets to attempt the store.
#
cmd3='sh -c "PMCD_CONNECT_TIMEOUT=30 PMCD_PORT='$PMCD_PORT'; export PMCD_CONNECT_TIMEOUT PMCD_PORT; pmstore -h '$LOCALHOST_FULL' pmcd.control.debug 1"'
echo "cmd3: $cmd3" >>$seq.full
# not sure how long it takes to get the remote pmval command started
# and connected to pmcd so be prepared to try a few times ...
#
found=false
echo >$tmp.pmstore
for i in 1 2 3 4 5 6 7 8 9 10
do
    ssh -q pcpqa@$other2 $cmd3 >$tmp.tmp 2>&1
    echo "--- attempt $i ---" >>$tmp.pminfo
    cat $tmp.tmp >>$tmp.pmstore
    if grep 'connection limit' $tmp.tmp >/dev/null
    then
	# bingo!
	sed -e 's/".*"/"OTHERHOST2"/' <$tmp.tmp
	found=true
	break
    fi
    sleep 1
done
$found || cat $tmp.pmstore
ssh -q pcpqa@$other2 $usersignal -a pmval > /dev/null 2>&1
echo
echo "=== pmval output ===" >>$seq.full
cat $tmp.pmval >>$seq.full
echo "=== pminfo output ===" >>$seq.full
cat $tmp.pminfo >>$seq.full
echo "=== pmstore output ===" >>$seq.full
cat $tmp.pmstore >>$seq.full

echo 'expect 3 access violation messages for localhost, OTHERHOST1 and OTHERHOST2
and one endclient access violation for localhost and one endclient connection
limit for each of OTHERHOST1 and OTHERHOST2'
_filter_log

echo "=== pmcd.log ===" >>$seq.full
cat $log >>$seq.full

echo
echo "If failure, check $seq.full"