Bump to 1.14.1
[platform/upstream/augeas.git] / tests / test-put-symlink-augsave.sh
1 #!/bin/sh
2
3 # Test that we don't follow .augsave symlinks
4
5 ROOT=$abs_top_builddir/build/test-put-symlink-augsave
6 LENSES=$abs_top_srcdir/lenses
7
8 HOSTS=$ROOT/etc/hosts
9 HOSTS_AUGSAVE=${HOSTS}.augsave
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 HOSTS_SUM=$(sum $HOSTS | cut -d ' ' -f 1)
21
22 touch $ATTACK_FILE
23 (cd $(dirname $HOSTS) && ln -s ../other/attack $(basename $HOSTS).augsave)
24
25 # Now ask for the original to be saved in .augsave
26 augtool --nostdinc -I $LENSES -r $ROOT --backup > /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 [ -h $HOSTS_AUGSAVE ] ; then
36     echo "/etc/hosts.augsave is still a symlink, should be unlinked"
37     exit 1
38 fi
39
40 if [ ! "x${HOSTS_SUM}" = "x$(sum $HOSTS_AUGSAVE | cut -d ' ' -f 1)" ]; then
41     echo "/etc/hosts.augsave has changed from the original /etc/hosts"
42     exit 1
43 fi
44 if ! grep myhost $HOSTS >/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