summaryrefslogtreecommitdiffstats
path: root/tests/chage/02/run
blob: 74ac2682ac7027237ded996023be0adc7e0dc1da (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
#!/bin/sh

set -e

cd $(dirname $0)

# Rational:
# Test chage with bogus inputs

# 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 /etc/$i  tmp/$i
		[ -f /etc/$i- ] && cp /etc/$i- tmp/$i-
	done

	true
}

restore()
{
	for i in passwd group shadow gshadow
	do
		[ -f tmp/$i  ] && cp tmp/$i  /etc/$i  && rm tmp/$i
		[ -f tmp/$i- ] && cp tmp/$i- /etc/$i- && rm tmp/$i-
	done
	rm -f tmp/out
	rmdir tmp
}

save

# restore the files on exit
trap 'if [ "$?" != "0" ]; then echo "FAIL"; fi; restore' 0

for i in passwd group shadow gshadow
do
	cp data/$i /etc
done

echo "interractive test"
./run.exp $(date "+%Y-%m-%d")

echo "OK"