testprogs: Add common kinit function
authorAndreas Schneider <asn@samba.org>
Tue, 13 Sep 2016 06:24:06 +0000 (08:24 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Sat, 29 Apr 2017 21:31:08 +0000 (23:31 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Andrew Bartlet <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
testprogs/blackbox/common_test_fns.inc

index f77879a..77c635b 100755 (executable)
@@ -88,3 +88,19 @@ test_rpcclient_expect_failure_grep() {
        fi
        return $status
 }
+
+kerberos_kinit() {
+       kinit_tool="${1}"
+       principal="${2}"
+       password="${3}"
+       shift 3
+       kbase=$(basename ${kinit_tool})
+       if [ "${kbase}" = "samba4kinit" ]; then
+               kpassfile=$(mktemp)
+               echo $password > ${kpassfile}
+               $kinit_tool --password-file=${kpassfile} $principal $@
+               rm -f ${kpassfile}
+       else
+               echo $password | $kinit_tool $principal $@
+       fi
+}