Merge branch 'master' of git://git.pcp.io/pcp into qt
[pcp.git] / qa / 832
blob9bf58d286b855196f2e02636bfc5ff71db1880d9
1 #!/bin/sh
2 # PCP QA Test No. 832
3 # Exercise enforced-authentication modes for pmcd.
5 # Copyright (c) 2013 Red Hat.
8 seq=`basename $0`
9 echo "QA output created by $seq"
11 # get standard environment, filters and checks
12 . ./common.product
13 . ./common.filter
14 . ./common.check
16 _get_libpcp_config
17 $unix_domain_sockets || _notrun "No unix domain socket support available"
18 $authentication || _notrun "No authentication support available"
20 gotplugins=false
21 which pluginviewer >/dev/null 2>&1 && gotplugins=true
22 if $gotplugins
23 then
24 pluginviewer=pluginviewer
25 else
26 which saslpluginviewer >/dev/null 2>&1 && gotplugins=true
27 pluginviewer=saslpluginviewer
29 $gotplugins || _notrun "SASL pluginviewer utility unavailable"
30 $pluginviewer -c | grep 'Plugin "plain"' >/dev/null 2>&1
31 test $? -eq 0 || _notrun 'No client support for plain authentication'
32 $pluginviewer -s | grep 'Plugin "plain"' >/dev/null 2>&1
33 test $? -eq 0 || _notrun 'No server support for plain authentication'
35 export PCP_CONSOLE=none
37 cleanup()
39 # restore any modified pmcd configuration files
40 _restore_config $PCP_PMCDOPTIONS_PATH
41 _restore_config $PCP_SASLCONF_DIR/pmcd.conf
43 $sudo $PCP_RC_DIR/pcp restart 2>&1 | _filter_pcp_stop | _filter_pcp_start
44 _wait_for_pmcd
45 _wait_for_pmlogger
47 rm -rf $tmp.*
50 status=1 # failure is the default!
51 $sudo rm -rf $tmp.* $seq.full
52 trap "cleanup; exit \$status" 0 1 2 3 15
54 # Handle spurious lines from deep inside SASL code ...
55 # [Mon Mar 2 17:58:40] pmcd_wait(16622) Alert: Parameter Error in ../plugins/plugin_common.c near line 357
57 # And this from libpcp (via pmcd_wait) ...
58 # 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
60 _filter()
62 sed \
63 -e 's/\[[^]]*] .* Alert: Parameter Error .* line [0-9][0-9]*//' \
64 -e '/ pmcd_wait([0-9][0-9]*) Error: __pmCloseChannelbyFd/s/\[.*//' \
65 -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]/' \
66 -e '/^[ ]*$/d' \
67 # end
70 # real QA test starts here
71 _save_config $PCP_SASLCONF_DIR/pmcd.conf
72 echo 'mech_list: plain' > $tmp.sasl
73 $sudo cp $tmp.sasl $PCP_SASLCONF_DIR/pmcd.conf
75 _save_config $PCP_PMCDOPTIONS_PATH
76 cat <<End-Of-File >$tmp.options
77 # Dummy lines added by PCP QA test $seq
80 End-Of-File
81 $sudo cp $tmp.options $PCP_PMCDOPTIONS_PATH
83 echo "Start pmcd with modified \$PCP_PMCDOPTIONS_PATH (pmcd.options)" | tee -a $seq.full
84 cat $PCP_PMCDOPTIONS_PATH >>$seq.full
85 $sudo $PCP_RC_DIR/pmcd stop 2>&1 | tee -a $seq.full >$tmp.out
86 $sudo $PCP_RC_DIR/pmcd start 2>&1 | tee -a $seq.full >$tmp.out
87 _wait_for_pmcd 10 unix: 2>&1 | tee -a $seq.full | _filter
88 grep -i 'starting pmcd' $tmp.out \
89 | _filter \
90 | sed -e "s/$$/MYPID/" \
91 | _filter_pcp_start
93 # should now be running in enforced-credentials mode, check it out.
94 # unix domain access should always succeed - no matter how binaries
95 # were configured/built
97 echo "testing secure mode access via unix domain socket (PASS)"
98 pmstore -h unix: sample.write_me 1 # store PDU
99 pmprobe -h unix: -v sample.write_me # fetch PDU
100 pminfo -th unix: sample.write_me # text PDU
101 pminfo -dh unix: sample.write_me # desc PDU
102 echo
104 echo "testing secure mode access attempt via inet socket (FAIL)"
105 pmstore -h localhost sample.write_me 2 2>&1 | _filter
106 pmprobe -h localhost -v sample.write_me 2>&1 | _filter
107 pminfo -th localhost sample.write_me 2>&1 | _filter
108 pminfo -dh localhost sample.write_me 2>&1 | _filter
109 echo
111 # success, all done
112 status=0
113 exit