File: 1481

package info (click to toggle)
pcp 7.1.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 252,748 kB
  • sloc: ansic: 1,483,656; sh: 182,366; xml: 160,462; cpp: 83,813; python: 24,980; perl: 18,327; yacc: 6,877; lex: 2,864; makefile: 2,738; awk: 165; fortran: 60; java: 52
file content (147 lines) | stat: -rwxr-xr-x 4,355 bytes parent folder | download
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
#!/bin/sh
# PCP QA Test No. 1481
# Check tar postinstall mkdir|chmod|chown actions
#
# Copyright (c) 2024 Ken McDonell.  All Rights Reserved.
#

if [ $# -eq 0 ]
then
    seq=`basename $0`
    echo "QA output created by $seq"
else
    # use $seq from caller, unless not set
    [ -n "$seq" ] || seq=`basename $0`
    echo "QA output created by `basename $0` $*"
fi

# get standard environment, filters and checks
. ./common.product
. ./common.filter
. ./common.check

[ -d ../build/tar ] || _notrun "not in build dir, no ../build/tar"


( cd ../build/tar; $MAKE ) >>$seq_full 2>&1

_cleanup()
{
    cd $here
    $sudo rm -rf $tmp $tmp.*
}

status=0	# success is the default!
trap "_cleanup; exit \$status" 0 1 2 3 15

_filter()
{
    sed \
	-e "s@$tmp@TMP@g" \
    # end
}

LC_COLLATE=POSIX; export LC_COLLATE

# real QA test starts here
echo "Silence is golden ..."

# expand $(...) variables from permslist lines like:
# GNUmakefile|775|$(PCP_USER)|$(PCP_GROUP)|$(PCP_VAR_DIR)/config/pmda
# src/pmlogger/GNUmakefile|775|$(PCP_USER)|$(PCP_GROUP)|$(PCP_TMP_DIR)/pmlogger|optional
#
sed <src/permslist \
    -e "s/\$(PCP_USER)/$PCP_USER/g" \
    -e "s/\$(PCP_GROUP)/$PCP_GROUP/g" \
    -e "s@\$(PCP_LOG_DIR)@$PCP_LOG_DIR@g" \
    -e "s@\$(PCP_TMP_DIR)@$PCP_TMP_DIR@g" \
    -e "s@\$(PCP_VAR_DIR)@$PCP_VAR_DIR@g" \
    -e "s@\$(PCP_RUN_DIR)@$PCP_RUN_DIR@g" \
    -e "s@\$(PCP_TMPFILE_DIR)@$PCP_TMPFILE_DIR@g" \
    -e "s@\$(PCP_SA_DIR)@$PCP_SA_DIR@g" \
| $PCP_AWK_PROG -F '|' '{ print $5,$2,$3,$4,$6 }' \
| sort >$tmp.permslist

echo "--- permslist ---" >>$seq_full
cat $tmp.permslist >>$seq_full

# build similar last from shell commands in tarball postinstall
# script, where output looks like:
# + mkdir -p /var/lib/pcp/config/pmda
# + chown $PCP_USER:$PCP_GROUP /var/lib/pcp/config/pmda
# + chmod 775 /var/lib/pcp/config/pmda
#
( cd ../build/tar; ./postinstall -n ) 2>&1 \
| grep -E '^\+ (chown|chmod) ' \
| $PCP_AWK_PROG '
$2 == "chown"	{ if ($3 == "-R") {
			who = $4; start = 5
			Rflag = 1
		  }
		  else {
		  	who = $3; start = 4
			Rflag = 0
		  }
		  for (i = start; i <= NF; i++) {
		      obj = $i
		      if (Rflag) obj = obj "-R"
		      ug[obj] = who
		  }
		}
$2 == "chmod"	{ for (i = 4; i <= NF; i++) mode[$i] = $3 }
END		{ for (path in ug) {
		    if (mode[path] == "") mode[path] = "default-mode"
		    printf "%s %s %s\n",path,mode[path],ug[path]
		  }
		}' \
| sed -e 's/:/ /' \
| sort >$tmp.postinstall

echo "--- postinstall ---" >>$seq_full
cat $tmp.postinstall >>$seq_full

# join'd lines look like this
# /var/lib/pcp/tmp/pmie 775 pcp pcp /var/lib/pcp/tmp/pmie 775 pcp pcp optional
# expect these to be equal ...
# /var/lib/pcp/tmp/pmie             /var/lib/pcp/tmp/pmie
#                       775                               775
#                           pcp                               pcp
#                               pcp                               pcp
#
# and then ones line this
# /etc/default/pmcd default-mode root root MISSING MISSING MISSING MISSING MISSING
# /etc/pcp/pmie 755 root root MISSING MISSING MISSING MISSING MISSING
# are OK (tarball possibly empty dir creation) provided the user
# (and group) is root or wheel
#
# and ones like this are also OK (just being paranoid)
# /etc/pcp/pmcd/pmcd.conf 644 root root MISSING MISSING MISSING MISSING MISSING
# provided the user (and group) is root or wheel
#
# and testsuite ... pcpqa is OK
#
# and there is no config.default for pmie or pmlogger in the tarball
# today, but the postinstall is guarded by [ -f ... ]so these are OK
# /var/lib/pcp/config/pmie/config.default 644 pcp pcp MISSING MISSING MISSING MISSING MISSING
# /var/lib/pcp/config/pmlogger/config.default 644 pcp pcp MISSING MISSING MISSING MISSING MISSING
#
join -t ' ' -j 1 -a 1 -a 2 -e MISSING \
    -o 1.1,1.2,1.3,1.4,2.1,2.2,2.3,2.4,2.5 $tmp.postinstall $tmp.permslist \
| $PCP_AWK_PROG '
$1 == $5 && $2 == $6 && $3 == $7 && $4 == $8	{ next }
$2 == "default-mode" || $2 == "755" || $2 == "644"	{
			  ok = 1
			  if ($3 != "root" && $3 != "wheel") ok = 0
			  if ($4 != "root" && $4 != "wheel") ok = 0
			  for (i = 5; i <= NF; i++)
			    if ($i != "MISSING") ok = 0
			  if (ok == 1) next
			}
			{ print }' \
| sed \
    -e '/\/testsuite.*pcpqa pcpqa/d' \
    -e '/\/config\/pmie\/config.default/d' \
    -e '/\/config\/pmlogger\/config.default/d' \
# end
# success, all done
exit