1#!/bin/sh 2# 3# Copyright (c) 2010 Kungliga Tekniska Högskolan 4# (Royal Institute of Technology, Stockholm, Sweden). 5# All rights reserved. 6# 7# Portions Copyright (c) 2010 Apple Inc. All rights reserved. 8# 9# Redistribution and use in source and binary forms, with or without 10# modification, are permitted provided that the following conditions 11# are met: 12# 13# 1. Redistributions of source code must retain the above copyright 14# notice, this list of conditions and the following disclaimer. 15# 16# 2. Redistributions in binary form must reproduce the above copyright 17# notice, this list of conditions and the following disclaimer in the 18# documentation and/or other materials provided with the distribution. 19# 20# 3. Neither the name of the Institute nor the names of its contributors 21# may be used to endorse or promote products derived from this software 22# without specific prior written permission. 23# 24# THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 25# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27# ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 28# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34# SUCH DAMAGE. 35 36env_setup="@env_setup@" 37 38. ${env_setup} 39 40confdir="@confdir@" 41testdir="@testdir@" 42 43echo "dumping in different formats" 44 45conf="${confdir}/krb5-dump.conf" 46realm=LKDC:SHA1.58FCE36DBDBD86AE701093B4B1D79ADD0705D00B 47realm2=LKDC:SHA1.doesnotexists 48 49sf="cifs%LKDC:SHA1.58FCE36DBDBD86AE701093B4B1D79ADD0705D00B@LKDC:SHA1.58FCE36DBDBD86AE701093B4B1D79ADD0705D00B.plist" 50 51test -d "${testdir}" || mkdir "${testdir}" 52cd "${testdir}" 53 54rm -f file *.plist 55 56echo "dump" 57${kadmin} -r ${realm} -c ${conf} -l dump -d file || exit 1 58 59grep cifs/LKDC file > /dev/null || exit 1 60 61rm -f file 62 63echo "dump format=od" 64${kadmin} -r ${realm} -c ${conf} -l dump -d --format=od . || exit 1 65 66found=0 67for a in *.plist; do 68 if /usr/libexec/PlistBuddy -c 'print KerberosPrincipal' $a 2>&1 | grep 'cifs/LKDC' > /dev/null 2>&1 ; then 69 found=1 70 fi 71done 72if test $found != 1; then 73 echo "cifs@LKDC not found" 74 exit 1 75fi 76 77rm -f *.plist 78 79echo "mit-dump-file" 80${kadmin} -r ${realm} -c ${conf} -l dump -d --mit-dump-file="${confdir}/dumpfile" file || exit 1 81 82grep cifs/LKDC file > /dev/null || exit 1 83 84rm -rf file 85 86echo "mit-dump-file format=od" 87${kadmin} -r ${realm} -c ${conf} -l dump -d --mit-dump-file="${confdir}/dumpfile" --format=od . || exit 1 88 89found=0 90for a in *.plist; do 91 if /usr/libexec/PlistBuddy -c 'print KerberosPrincipal' $a 2>&1 | grep 'cifs/LKDC' > /dev/null 2>&1 ; then 92 found=1 93 fi 94done 95if test $found != 1; then 96 echo "cifs@LKDC not found" 97 exit 1 98fi 99 100rm -f *.plist file 101 102echo "check for database that doesn't exists" 103${kadmin} -r ${realm2} -c ${conf} -l dump file > /dev/null 2>/dev/null && exit 1 104 105exit 0 106