File: 1484

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 (159 lines) | stat: -rwxr-xr-x 4,482 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
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/sh
# PCP QA Test No. 1484
# Workout for pcp-reboot-init - $PCP_LOG_DIR/NOTICES fixup part
#
# 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


_cleanup()
{
    cd $here
    $sudo chown $PCP_USER:$PCP_GROUP "$PCP_LOG_DIR"
    $sudo chown $PCP_USER:$PCP_GROUP "$PCP_LOG_DIR"/NOTICES
    $sudo rm -rf $tmp $tmp.*
}

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

# last 2 expressions are to deal with "smart" (i.e. stupid)
# quoting from some versions of some GNU utils ... yuk!
#
_filter()
{
    sed \
	-e "s@$tmp@TMP@g" \
	-e "s@$PCP_BINADM_DIR@PCP_BINADM_DIR@g" \
	-e 's@^drwx.*TMP$@... ls output for TMP@' \
	-e '/^ls: /{
s/cannot access .*TMP/cannot access TMP/
s/[^A-Za-z/*]*: No such file or/: No such file or/
}' \
	-e '/^touch: /{
s/cannot touch .*TMP/cannot touch TMP/
s/[^A-Z*]: Permission/: Permission/
}' \
    # end
}

# strip ls -l output to the essentials ...
# drwxrwxr-x 2 pcpqa pcpqa 4096 Jan 16 15:09 TMP/run
# ^^^^^^^^^^   ^^^^^ ^^^^^                   ^^^^^^^
#           . (maybe)
_myls()
{
    $PCP_AWK_PROG '
/^PCP_BINADM/	{ print; next }
/^touch/	{ print; next }
/cannot access/	{ print; next }
		{ print $1,$3,$4,$9 }' \
    | sed -e 's/\([r-][w-][x-]\)\. /\1 /' \
    | _filter
}

umask 022
mkdir $tmp
PCP_LOG_DIR=$tmp/log; export PCP_LOG_DIR

# real QA test starts here

echo
echo "=== \$PCP_LOG_DIR missing"
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
ls -ld $tmp/log 2>&1 | _myls

echo
echo "=== \$PCP_LOG_DIR/NOTICES exists and OK, so do nothing"
mkdir "$PCP_LOG_DIR"
touch "$PCP_LOG_DIR"/NOTICES
$sudo chown $PCP_USER:$PCP_GROUP "$PCP_LOG_DIR"
$sudo chown $PCP_USER:$PCP_GROUP "$PCP_LOG_DIR"/NOTICES
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter 
ls -l $tmp/log/NOTICES* 2>&1 | _myls

echo
echo "=== \$PCP_LOG_DIR/NOTICES does not exist ..."
$sudo rm -f "$PCP_LOG_DIR"/NOTICES
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter 
ls -l $tmp/log/NOTICES* 2>&1 | _myls

echo
echo "=== \$PCP_LOG_DIR/NOTICES does not exist, but cannot create ..."
$sudo rm -f "$PCP_LOG_DIR"/NOTICES
$sudo chown pcpqa:pcpqa "$PCP_LOG_DIR"
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 \
| _filter  \
| _myls
ls -l $tmp/log/NOTICES* 2>&1 | _myls
$sudo chown $PCP_USER:$PCP_GROUP "$PCP_LOG_DIR"

echo
echo "=== \$PCP_LOG_DIR/NOTICES exists, but wrong ownership, no NOTICES.old ..."
$sudo rm -f "$PCP_LOG_DIR"/NOTICES*
$sudo touch "$PCP_LOG_DIR"/NOTICES
$sudo chown root:root "$PCP_LOG_DIR"/NOTICES
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter 
ls -l $tmp/log/NOTICES* 2>&1 | _myls

echo
echo "=== \$PCP_LOG_DIR/NOTICES exists, but wrong ownership, root owns NOTICES.old ..."
$sudo rm -f "$PCP_LOG_DIR"/NOTICES*
$sudo touch "$PCP_LOG_DIR"/NOTICES.old
$sudo chown root:root "$PCP_LOG_DIR"/NOTICES.old
$sudo touch "$PCP_LOG_DIR"/NOTICES
$sudo chown pcpqa:pcpqa "$PCP_LOG_DIR"/NOTICES
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter 
ls -l $tmp/log/NOTICES* 2>&1 | _myls

echo
echo "=== \$PCP_LOG_DIR/NOTICES exists, but wrong ownership, cannot create ..."
$sudo rm -f "$PCP_LOG_DIR"/NOTICES*
$sudo touch "$PCP_LOG_DIR"/NOTICES
$sudo chown pcpqa:pcpqa "$PCP_LOG_DIR"/NOTICES
$sudo chown pcpqa:pcpqa "$PCP_LOG_DIR"
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 \
| _filter \
| _myls
ls -l $tmp/log/NOTICES* 2>&1 | _myls
$sudo chown $PCP_USER:$PCP_GROUP "$PCP_LOG_DIR"

echo
echo "=== \$PCP_LOG_DIR/NOTICES exists, but wrong mode"
$sudo rm -f "$PCP_LOG_DIR"/NOTICES*
$sudo touch "$PCP_LOG_DIR"/NOTICES
$sudo chmod 666 "$PCP_LOG_DIR"/NOTICES
$sudo chown $PCP_USER:$PCP_GROUP "$PCP_LOG_DIR"/NOTICES
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
ls -l $tmp/log/NOTICES* 2>&1 | _myls

echo
echo "=== \$PCP_LOG_DIR/NOTICES exists, but is symlink"
$sudo rm -f "$PCP_LOG_DIR"/NOTICES*
$sudo rm -f /etc/$seq-foobar
$sudo touch /etc/$seq-foobar
echo "Created by PCP QA $seq on `date`" | $sudo dd of=/etc/$seq-foobar 2>/dev/null
$sudo chmod 400 /etc/$seq-foobar
$sudo ln -s /etc/$seq-foobar "$PCP_LOG_DIR"/NOTICES
$sudo $PCP_BINADM_DIR/pcp-reboot-init 2>&1 | _filter
ls -l $tmp/log/NOTICES* 2>&1 | _myls
ls -l /etc/$seq-foobar | _myls
$sudo rm -f /etc/$seq-foobar

# success, all done
exit