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