/var/lib/pcp/testsuite/common.secure is in pcp-testsuite 3.8.12ubuntu1.
This file is owned by root:root, with mode 0o644.
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 | #
# Common shell routines for testing security extensions
# Copyright (c) 2012-2013 Red Hat.
#
# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check
usersdb=${HOME}/.pki/nssdb
collectordb=$tmp/pki/nssdb
collectorpw=$tmp/pki/nssdb/pass
PCP_SECURE_DB_METHOD=${PCP_SECURE_DB_METHOD-'sql:'}
certopts="-d $PCP_SECURE_DB_METHOD$collectordb -f $collectorpw -z $tmp.rand"
userid=`id -u`
groupid=`id -g`
username=`id -u -n`
groupname=`id -g -n`
qahost=`_get_fqdn`
hostname=`hostname | sed -e 's/\..*//'`
nss_notrun_checks()
{
[ $PCP_VER -ge 3611 ] || _notrun "Installed pcp is too old"
eval `pmconfig -L`
[ "$secure_sockets" = "true" ] || _notrun "Secure sockets not supported"
which certutil >/dev/null 2>&1 || _notrun "certutil not installed (NSS tools)"
[ -c /dev/urandom ] || _notrun "No random number generator special file found"
}
nss_cleanup()
{
unset PCP_SECURE_SOCKETS
# restore any modified pmcd configuration file
cf=$PCP_PMCDOPTIONS_PATH
if test -f $cf.$seq
then
$sudo rm -f $cf
$sudo mv $cf.$seq $cf
fi
# restore user certificate DB from existing installation
if test -d $usersdb.$seq
then
$sudo rm -fr $usersdb
$sudo mv $usersdb.$seq $usersdb
fi
}
# backup pmcd configuration and certificate DBs from existing installation
nss_backup()
{
for f in $PCP_PMCDOPTIONS_PATH $usersdb
do
[ -e $f ] && $sudo mv $f $f.$seq
done
}
nss_filter_pminfo()
{
sed \
-e "s/$qahost/QAHOST/g" \
-e "s/$hostname/HOST/g" \
-e "/^SHA1 fingerprint is .*/d" \
-e 's/value [0-9][0-9]*/value NUMBER/'
}
nss_setup_randomness()
{
dd if=/dev/urandom of=$tmp.rand bs=1 count=10000 >/dev/null 2>&1
}
nss_subject_name()
{
fqdn=$1
host=$2
echo $fqdn | sed -e "s/^$host\./dc=/g" -e 's/\./,dc=/g'
}
nss_setup_certificates()
{
certdomain=`nss_subject_name $qahost $hostname`
echo "setup_certificates host details:" >> $seq.full
echo "HOST=$hostname" >> $seq.full
echo "QAHOST=$qahost" >> $seq.full
echo "DOMAIN=$certdomain" >> $seq.full
# create self-signed (-x) server certificate locally
echo "== Creating local certificates" | tee -a $seq.full
$sudo certutil $certopts -S -x \
-n "Local CA certificate" -s "cn=Local PCP Installation, $certdomain" \
-t "CT,," >> $seq.full 2>&1
$sudo certutil $certopts -S \
-n "PCP Collector certificate" -s "cn=PCP Collector" \
-c "Local CA certificate" -8 "$qahost,$hostname" \
-t "P,," >> $seq.full 2>&1
echo "== Certificate DB and local certificates created" | tee -a $seq.full
# export ascii copy of the certificate for later use
$sudo certutil $certopts -L -n "Local CA certificate" -a > $tmp.cacert.asc
cat $tmp.cacert.asc >> $seq.full
}
nss_setup_collector()
{
withcerts=$1
fqdn=$2
host=$3
# prepare new locations for certificates
$sudo rm -fr $collectordb
$sudo mkdir -p -m 0755 $collectordb
# prepare password file for certificates
echo "$seq.password" > $tmp.password
$sudo mv $tmp.password $collectorpw
echo "== Creating empty certificate DB" | tee -a $seq.full
$sudo certutil $certopts -N
$withcerts && nss_setup_certificates $fqdn $host
$sudo chmod -R 0644 $collectordb/*
$sudo chown -R pcp:pcp $collectordb
cat <<End-Of-File >$tmp.options
# Dummy lines added by PCP QA test $seq
#
-l $tmp.pmcd.log
-C $PCP_SECURE_DB_METHOD$collectordb
-P $collectorpw
End-Of-File
$sudo cp $tmp.options $PCP_PMCDOPTIONS_PATH
echo "Start pmcd, modified \$PCP_PMCDOPTIONS_PATH (pmcd.options):" | tee -a $seq.full
$sudo $PCP_RC_DIR/pcp restart | tee -a $seq.full >$tmp.out
_wait_for_pmcd
grep -i 'starting pmcd' $tmp.out | sed -e "s/$$/MYPID/" | _filter_pcp_start
echo "Checking pmcd.log for unexpected messages" | tee -a $seq.full
egrep 'Error:|Info:' $tmp.pmcd.log
cat $tmp.pmcd.log >> $seq.full
echo "--- end of pmcd.log ---" >> $seq.full
}
nss_setup_empty_userdb()
{
$sudo rm -fr $usersdb
echo > $tmp.empty
mkdir -p -m 0755 $usersdb
certutil -N -d $PCP_SECURE_DB_METHOD$usersdb -f $tmp.empty
}
nss_import_cert_userdb()
{
certutil -A -d $PCP_SECURE_DB_METHOD$usersdb -n "Local CA certificate" -t "CT,," -a -i $tmp.cacert.asc
}
find_users()
{
limit=$1
tail -n $limit /etc/passwd | $PCP_AWK_PROG -F: '{ print $1 }'
}
find_groups()
{
limit=$1
tail -n $limit /etc/group | $PCP_AWK_PROG -F: '{ print $1 }'
}
filter_sample_log_credentials()
{
grep Info $PCP_LOG_DIR/pmcd/sample.log | \
sed \
-e '/processid=/d' \
-e '/ctx=[0-9][0-9]*/s//ctx=N/' \
-e "s/userid=$userid/userid=UID/g" \
-e "s/groupid=$groupid/groupid=GID/g" \
-e "s/username=$username/username=USER/g" \
-e '/pmdasample([0-9][0-9]*)/s//pmdasample(PID)/' \
-e 's/^\[[A-Z].. [A-Z].. *[0-9][0-9]* ..:..:..]/[DATETIME]/'
}
|