Merge branch 'master' of https://github.com/kmcdonell/pcp into kenj-merge
[pcp.git] / qa / 832
blob6715a760c826bdaf2a1ff42e1b9a17d2b18f5e9f
1 #!/bin/sh
2 # PCP QA Test No. 832
3 # Exercise enforced-authentication modes for pmcd.
5 # Copyright (c) 2013,2017 Red Hat.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 . ./common.secure
13 _get_libpcp_config
14 $unix_domain_sockets || _notrun "No unix domain socket support available"
15 $authentication || _notrun "No authentication support available"
17 sasl_notrun_checks
18 $pluginviewer -c | grep 'Plugin "plain"' >/dev/null 2>&1
19 test $? -eq 0 || _notrun 'No client support for plain authentication'
20 $pluginviewer -s | grep 'Plugin "plain"' >/dev/null 2>&1
21 test $? -eq 0 || _notrun 'No server support for plain authentication'
23 export PCP_CONSOLE=none
25 cleanup()
27 # restore any modified pmcd configuration files
28 _restore_config $PCP_PMCDOPTIONS_PATH
29 _restore_config $PCP_SASLCONF_DIR/pmcd.conf
31 _service pcp restart 2>&1 | _filter_pcp_stop | _filter_pcp_start
32 _restore_auto_restart pmcd
33 _wait_for_pmcd
34 _wait_for_pmlogger
36 rm -rf $tmp.*
39 status=1 # failure is the default!
40 $sudo rm -rf $tmp.* $seq.full
41 trap "cleanup; exit \$status" 0 1 2 3 15
43 _stop_auto_restart pmcd
45 # Handle spurious lines from deep inside SASL code ...
46 # [Mon Mar 2 17:58:40] pmcd_wait(16622) Alert: Parameter Error in ../plugins/plugin_common.c near line 357
48 # And this from libpcp (via pmcd_wait) ...
49 # Starting pmcd ... [Thu Aug 4 16:59:02] pmcd_wait(14208) Error: __pmCloseChannelbyFd: fd=3 expected PDU_ATTR received: Timeout waiting for a response from PMCD
51 _filter()
53 sed \
54 -e 's/\[[^]]*] .* Alert: Parameter Error .* line [0-9][0-9]*//' \
55 -e '/ pmcd_wait([0-9][0-9]*) Error: __pmCloseChannelbyFd/s/\[.*//' \
56 -e 's/\[[A-Z][a-z][a-z] [A-Z][a-z][a-z] *[0-9][0-9]* [0-9][0-9]:[0-9][0-9]:[0-9][0-9]]/[DATE]/' \
57 -e '/^[ ]*$/d' \
58 # end
61 # real QA test starts here
62 _save_config $PCP_SASLCONF_DIR/pmcd.conf
63 echo 'mech_list: plain' > $tmp.sasl
64 $sudo cp $tmp.sasl $PCP_SASLCONF_DIR/pmcd.conf
66 _save_config $PCP_PMCDOPTIONS_PATH
67 cat <<End-Of-File >$tmp.options
68 # Dummy lines added by PCP QA test $seq
71 End-Of-File
72 $sudo cp $tmp.options $PCP_PMCDOPTIONS_PATH
74 echo "Start pmcd with modified \$PCP_PMCDOPTIONS_PATH (pmcd.options)" | tee -a $seq.full
75 cat $PCP_PMCDOPTIONS_PATH >>$seq.full
76 _service pmcd stop 2>&1 | tee -a $seq.full >$tmp.out
77 # Note: need to use $PCP_RC_DIR/pmcd here, not _service pmcd so that
78 # systemd (if it is available) does not set pmcd.service into failed
79 # state when pmcd_wait -h local: fails with one of the SASL errors
80 # above (seen on vm31)
82 $sudo $PCP_RC_DIR/pmcd start 2>&1 | tee -a $seq.full >$tmp.out
83 if [ -f $PCP_LOG_DIR/pmcd/pmcd.log ]
84 then
85 echo "--- pmcd.log after start ---" >>$seq.full
86 cat $PCP_LOG_DIR/pmcd/pmcd.log >>$seq.full
87 else
88 echo "No pmcd.log?" >>$seq.full
89 $PCP_PS_PROG $PCP_PS_ALL_FLAGS | egrep '[P]ID|[p]mcd' >>$seq.full
91 _wait_for_pmcd 10 unix: 2>&1 | tee -a $seq.full | _filter
92 grep -i 'starting pmcd' $tmp.out \
93 | _filter \
94 | sed -e "s/$$/MYPID/" \
95 | _filter_pcp_start
97 # should now be running in enforced-credentials mode, check it out.
98 # unix domain access should always succeed - no matter how binaries
99 # were configured/built
101 echo "testing secure mode access via unix domain socket (PASS)"
102 pmstore -h unix: sample.write_me 1 # store PDU
103 pmprobe -h unix: -v sample.write_me # fetch PDU
104 pminfo -th unix: sample.write_me # text PDU
105 pminfo -dh unix: sample.write_me # desc PDU
106 echo
108 echo "testing secure mode access attempt via inet socket (FAIL)"
109 pmstore -h localhost sample.write_me 2 2>&1 | _filter
110 pmprobe -h localhost -v sample.write_me 2>&1 | _filter
111 pminfo -th localhost sample.write_me 2>&1 | _filter
112 pminfo -dh localhost sample.write_me 2>&1 | _filter
113 echo
115 # success, all done
116 status=0
117 exit