Bump to 1.14.1
[platform/upstream/augeas.git] / tests / test-put-symlink-augnew.sh
1 #!/bin/sh
2
3 # Test that we don't follow symlinks when writing to .augnew
4
5 ROOT=$abs_top_builddir/build/test-put-symlink-augnew
6 LENSES=$abs_top_srcdir/lenses
7
8 HOSTS=$ROOT/etc/hosts
9 HOSTS_AUGNEW=${HOSTS}.augnew
10
11 ATTACK_FILE=$ROOT/other/attack
12
13 rm -rf $ROOT
14 mkdir -p $(dirname $HOSTS)
15 mkdir -p $(dirname $ATTACK_FILE)
16
17 cat <<EOF > $HOSTS
18 127.0.0.1 localhost
19 EOF
20 touch $ATTACK_FILE
21
22 (cd $(dirname $HOSTS) && ln -s ../other/attack $(basename $HOSTS).augnew)
23
24 HOSTS_SUM=$(sum $HOSTS)
25
26 augtool --nostdinc -I $LENSES -r $ROOT --new > /dev/null <<EOF
27 set /files/etc/hosts/1/alias myhost
28 save
29 EOF
30
31 if [ ! -f $HOSTS  -o  -h $HOSTS ] ; then
32     echo "/etc/hosts is no longer a regular file"
33     exit 1
34 fi
35 if [ ! "x${HOSTS_SUM}" = "x$(sum $HOSTS)" ]; then
36     echo "/etc/hosts has changed"
37     exit 1
38 fi
39
40 if [ -h $HOSTS_AUGNEW ] ; then
41     echo "/etc/hosts.augnew is still a symlink, should be unlinked"
42     exit 1
43 fi
44 if ! grep myhost $HOSTS_AUGNEW >/dev/null; then
45     echo "/etc/hosts does not contain the modification"
46     exit 1
47 fi
48
49 if [ -s $ATTACK_FILE ]; then
50     echo "/other/attack now contains data, should be blank"
51     exit 1
52 fi