#! /bin/sh
set -e

dir=$(pwd)/debian/tests
. $dir/textutils.sh

frame "Here we are testing the patch" \
      "features/Make-crontab-SGID-crontab.patch"

cronfile=$(whereis crontab | awk '{print $2}')

permissions=$(ls -ld "$cronfile" | awk '{print $1}')
echo "Permissions for $cronfile: $permissions"

# should be -rwxr-sr-x

suid_bit=$(echo "$permissions" | cut -c4)

if [ "$suid_bit" = "s" ]; then
	abort "File should *not* have SUID bit set"
fi

sgid_bit=$(echo "$permissions" | cut -c7)

if [ "$sgid_bit" != "s" ]; then
	abort "File should have SGID bit set"
fi

echo "========== test ok ========================================="

