blob: 81ceef1254aeef6752b22412b57a467d86c8f3b9 (
plain)
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
|
#!/bin/sh
set -e
cd $(dirname $0)
# Rational:
# Test that su can be used to switch to root and to a normal account
# no testsuite password
# root password: rootF00barbaz
# myuser password: myuserF00barbaz
save()
{
[ ! -d tmp ] && mkdir tmp
for i in passwd group shadow gshadow
do
[ -f /etc/$i ] && cp -dp /etc/$i tmp/$i
[ -f /etc/$i- ] && cp -dp /etc/$i- tmp/$i-
done
DATE=$(date '+%s')
DATE=$(( DATE/3600/24 ))
WARN=$( egrep "^PASS_WARN_AGE" /etc/login.defs | { read var val ; echo $val; } )
saveifs=$IFS
IFS=":"
cat data/2/shadow |
while read f1 f2 f3 f4 f5 f6 f7 f8 fres
do
echo "$f1:$f2:$DATE:$f4:$f5:$WARN:::"
done > tmp/shadow.2
IFS=$saveifs
}
restore()
{
for i in passwd group shadow gshadow
do
[ -f tmp/$i ] && cp -dp tmp/$i /etc/$i && rm tmp/$i
[ -f tmp/$i- ] && cp -dp tmp/$i- /etc/$i- && rm tmp/$i-
done
rm tmp/shadow.2
rmdir tmp
}
save
# restore the files on exit
trap 'restore' 0
for i in passwd group shadow gshadow
do
rm -f /etc/$i
done
for i in passwd group
do
cp -f data/1/$i /etc/
done
echo -n "pwconv "
pwconv
echo -n "checking..."
diff -au /etc/passwd data/2/passwd
diff -au /etc/shadow tmp/shadow.2
diff -au /etc/group data/1/group
perms=$(stat -c "%a %u %G" /etc/shadow)
if [ "$perms" != "440 0 shadow" ]
then
echo "Wrong mode or owners on /etc/shadow."
exit 1
fi
if [ -f /etc/gshadow ]
then
echo "/etc/gshadow should not exist."
exit 1
fi
echo "OK"
echo -n "grpconv "
grpconv
echo -n "checking..."
diff -au /etc/passwd data/2/passwd
diff -au /etc/shadow tmp/shadow.2
diff -au /etc/group data/2/group
diff -au /etc/gshadow data/2/gshadow
echo "OK"
echo -n "pwunconv "
pwunconv
echo -n "checking..."
diff -au /etc/passwd data/1/passwd
if [ -f /etc/shadow ]
then
echo "/etc/shadow should not exist. "
exit 1
fi
diff -au /etc/group data/2/group
diff -au /etc/gshadow data/2/gshadow
echo "OK"
echo -n "grpunconv "
grpunconv
echo -n "checking..."
diff -au /etc/passwd data/1/passwd
if [ -f /etc/shadow ]
then
echo "/etc/shadow should not exist. "
exit 1
fi
diff -au /etc/group data/1/group
if [ -f /etc/gshadow ]
then
echo "/etc/gshadow should not exist. "
exit 1
fi
echo "OK"
|