/usr/share/sadms-2.0.15/_test-auth.sh is in sadms 2.0.15.repack-0ubuntu2.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 | #!/bin/bash
# bbou@ac-toulouse.fr
# 2007-05-22 16:36:55
# _test-auth.sh
### P A R A M S
MYVERBOSE=
if [ "$1" = "-v" ]; then
MYVERBOSE="True"
shift
fi
MYUSER="$1"
MYPWD="$2"
MYDOMAIN="$3"
MYREALM="$4"
### I N C L U D E
. ./_include.sh
### S T A R T
sep=`testparm -sv 2> /dev/null | grep 'winbind separator' | awk '{print $4}'`
function auth()
{
if wbinfo -a "$1" > /dev/null 2> /dev/null; then
wbinfo -a "$1" | grep 'succeeded$'
return 0
fi
wbinfo -a "$1" | grep 'failed$'
return 1
}
function impersonate()
{
#su - "$1" -c "id" 2> /dev/null
expect session.expect "$2" su "$1" -c id 2> /dev/null
return $?
}
function getSid()
{
if wbinfo -n "$1" > /dev/null 2> /dev/null; then
wbinfo -n "$1" | awk '{print $1}'
return 0
fi
return 1
}
function getLogin()
{
if wbinfo -s "$1" > /dev/null 2> /dev/null; then
wbinfo -s "$1" | awk '{print $1}'
return 0
fi
return 1
}
echo "--------------------------------------------------------------------------------"
echo "AUTHENTICATION TEST"
echo "--------------------------------------------------------------------------------"
if [ "${MYUSER}" == "" ]; then
echo "No user selected (see Credentials)"
exit 1
fi
echo "+AUTHENTICATION"
echo "+authenticating ${MYUSER}"
if ! auth "${MYUSER}%${MYPWD}"; then
echo "authenticating ${MYUSER} failed" >&2
fi
echo "+authenticating ${MYDOMAIN}${sep}${MYUSER}"
if ! auth "${MYDOMAIN}${sep}${MYUSER}%${MYPWD}"; then
echo "authenticating ${MYDOMAIN}${sep}${MYUSER} failed" >&2
fi
echo "+authenticating ${MYREALM}${sep}${MYUSER}"
if ! auth "${MYREALM}${sep}${MYUSER}%${MYPWD}"; then
echo "authenticating ${MYREALM}${sep}${MYUSER} failed" >&2
fi
echo "+impersonating ${MYUSER}"
if impersonate "${MYUSER}" "${MYPWD}"; then
echo "ok"
else
echo "impersonating ${MYUSER} failed" >&2
fi
echo "+impersonating ${MYDOMAIN}${sep}${MYUSER}"
if impersonate "${MYDOMAIN}${sep}${MYUSER}" "${MYPWD}"; then
echo "ok"
else
echo "impersonating ${MYDOMAIN}${sep}${MYUSER} failed" >&2
fi
echo "+SID"
echo "+getting security id (sid) for ${MYDOMAIN}${sep}${MYUSER}"
if ! getSid "${MYDOMAIN}${sep}${MYUSER}"; then
echo "getting sid for ${MYDOMAIN}${sep}${MYUSER} failed" >&2
else
echo "+getting login from ${MYDOMAIN}${sep}${MYUSER} sid"
sid=`getSid "${MYUSER}"`
if ! getLogin "${sid}"; then
echo "getting login from ${MYUSER} sid failed" >&2
fi
fi
|