| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
set -e |
| 4 |
|
| 5 |
TESTNR="02" |
| 6 |
BASEDIR="$(pwd)/debian/tests" |
| 7 |
COMMONDIR="${BASEDIR}/common" |
| 8 |
DIR="${BASEDIR}/${TESTNR}" |
| 9 |
PATH="/bin:/usr/bin:/sbin:/usr/sbin" |
| 10 |
HOMEDIRA="/root" |
| 11 |
|
| 12 |
trap ' |
| 13 |
printf "\ntrap handler\n" |
| 14 |
if [ -e /etc/resolv.conf.disabled ]; then |
| 15 |
cp /etc/resolv.conf.disabled /etc/resolv.conf || true |
| 16 |
rm -f /etc/resolv.conf.disabled || true |
| 17 |
fi |
| 18 |
if [ -e /etc/hosts.disabled ]; then |
| 19 |
cp /etc/hosts.disabled /etc/hosts || true |
| 20 |
rm -f /etc/hosts.disabled || true |
| 21 |
fi |
| 22 |
' 0 INT QUIT ABRT PIPE TERM |
| 23 |
|
| 24 |
printf "========= test %s\.1: sudo to nobody\n" "${TESTNR}" |
| 25 |
if [ -e /etc/resolv.conf ]; then |
| 26 |
cp /etc/resolv.conf /etc/resolv.conf.disabled |
| 27 |
: >/etc/resolv.conf |
| 28 |
fi |
| 29 |
if [ -e /etc/hosts ]; then |
| 30 |
cp /etc/hosts /etc/hosts.disabled |
| 31 |
: >/etc/hosts |
| 32 |
fi |
| 33 |
RET=0 |
| 34 |
printf "trying sudo to nobody\n" |
| 35 |
cd "${HOMEDIRA}" |
| 36 |
${COMMONDIR}/asuser "" nobody || RET=$? |
| 37 |
printf "sudo to nobody, return value %s\n" "${RET}" |
| 38 |
STDERRLENGTH="$(cat ${HOMEDIRA}/stderr | grep -vE 'sudo: unable to resolve host [^:]+: Temporary failure in name resolution' | wc -l)" |
| 39 |
if [ "${STDERRLENGTH}" != "0" ]; then |
| 40 |
echo >&2 non-empty stderr |
| 41 |
printf >&2 "stdout:\n" |
| 42 |
cat >&2 ${HOMEDIRA}/stdout |
| 43 |
printf >&2 "stderr:\n" |
| 44 |
cat >&2 ${HOMEDIRA}/stderr |
| 45 |
printf >&2 "exit code %s\n" "${RET}" |
| 46 |
printf >&2 "exit 1\n" |
| 47 |
exit 1 |
| 48 |
fi |
| 49 |
|
| 50 |
printf "test series sucessful, exit 0\n" |
| 51 |
exit 0 |