From 5532539101656bb2816b8758d46444ec403eed31 Mon Sep 17 00:00:00 2001 From: Will Fiveash Date: Thu, 7 Aug 2008 00:22:37 +0000 Subject: [PATCH] Add test case to test that new mkey stash code is backward compat with old format stash file git-svn-id: svn://anonsvn.mit.edu/krb5/branches/mkey_keytab@20627 dc483132-0cff-0310-8789-dd5450dbe970 --- src/configure.in | 2 +- src/tests/Makefile.in | 2 +- src/tests/mkeystash_compat/Makefile.in | 49 +++++++++++++++++++ src/tests/mkeystash_compat/bigendian.c | 17 +++++++ src/tests/mkeystash_compat/old_stash_bendian | Bin 0 -> 67 bytes src/tests/mkeystash_compat/old_stash_lendian | Bin 0 -> 30 bytes 6 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 src/tests/mkeystash_compat/Makefile.in create mode 100644 src/tests/mkeystash_compat/bigendian.c create mode 100644 src/tests/mkeystash_compat/old_stash_bendian create mode 100644 src/tests/mkeystash_compat/old_stash_lendian diff --git a/src/configure.in b/src/configure.in index 362df04597..30c7daa62d 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1127,5 +1127,5 @@ V5_AC_OUTPUT_MAKEFILE(. tests tests/resolve tests/asn.1 tests/create tests/hammer tests/verify tests/gssapi tests/dejagnu tests/threads tests/shlib - tests/gss-threads tests/misc + tests/gss-threads tests/misc tests/mkeystash_compat ) diff --git a/src/tests/Makefile.in b/src/tests/Makefile.in index a02346c481..3c692b0e6b 100644 --- a/src/tests/Makefile.in +++ b/src/tests/Makefile.in @@ -3,7 +3,7 @@ mydir=tests myfulldir=tests BUILDTOP=$(REL).. LOCAL_SUBDIRS = resolve asn.1 create hammer verify gssapi dejagnu shlib \ - gss-threads misc + gss-threads misc mkeystash_compat RUN_SETUP = @KRB5_RUN_ENV@ KRB5_KDC_PROFILE=kdc.conf KRB5_CONFIG=krb5.conf KRB5_RUN_ENV= @KRB5_RUN_ENV@ diff --git a/src/tests/mkeystash_compat/Makefile.in b/src/tests/mkeystash_compat/Makefile.in new file mode 100644 index 0000000000..7b8956e43c --- /dev/null +++ b/src/tests/mkeystash_compat/Makefile.in @@ -0,0 +1,49 @@ +thisconfigdir=../.. +mydir=tests/mkeystash_compat +myfulldir=tests/mkeystash_compat +BUILDTOP=$(REL)..$(S).. + +RUN_SETUP = @KRB5_RUN_ENV@ KRB5_KDC_PROFILE=kdc.conf KRB5_CONFIG=krb5.conf +KRB5_RUN_ENV= @KRB5_RUN_ENV@ +PROG_LIBPATH=-L$(TOPLIBD) +PROG_RPATH=$(KRB5_LIBDIR) + +OBJS = bigendian.o +SRCS = $(srcdir)/bigendian.c + +TEST_DB = ./testdb +TEST_REALM = FOO.TEST.REALM +TEST_MKEY = footes + +KADMIN_OPTS= -d $(TEST_DB) -r $(TEST_REALM) +KDB_OPTS= $(KADMIN_OPTS) -P $(TEST_MKEY) + +check-unix:: mkeystash_check + +bigendian: $(OUTPRE)bigendian.$(OBJEXT) $(SUPPORT_DEPLIB) + $(CC_LINK) $(ALL_CFLAGS) -o bigendian $(OUTPRE)bigendian.$(OBJEXT) + +kdc.conf: Makefile + rm -rf kdc.conf + @echo "[realms]" > kdc.conf + @echo "$(TEST_REALM) = {" >> kdc.conf + @echo " key_stash_file = `pwd`/stash_file" >> kdc.conf + @echo "}" >> kdc.conf + +krb5.conf: Makefile + cat $(SRCTOP)/config-files/krb5.conf > krb5.new + +# Verify that the mkey stash code is backward compat with old/non-keytab stashfile format +mkeystash_check: kdc.conf krb5.conf bigendian + $(RM) $(TEST_DB)* stash_file + $(RUN_SETUP) $(VALGRIND) ../../kadmin/dbutil/kdb5_util $(KDB_OPTS) create -s + # overwrite keytab stash file with old format stash, depends on endianness of current test system + ./bigendian && cp $(srcdir)/old_stash_bendian stash_file || cp $(srcdir)/old_stash_lendian stash_file + # getprinc will fail if old stash file can not be read + $(RUN_SETUP) $(VALGRIND) ../../kadmin/cli/kadmin.local $(KADMIN_OPTS) -q 'getprinc K/M' + $(RUN_SETUP) $(VALGRIND) ../../kadmin/dbutil/kdb5_util $(KDB_OPTS) destroy -f + $(RM) $(TEST_DB)* stash_file + +clean:: + $(RM) kdc.conf + diff --git a/src/tests/mkeystash_compat/bigendian.c b/src/tests/mkeystash_compat/bigendian.c new file mode 100644 index 0000000000..bcdeeb5736 --- /dev/null +++ b/src/tests/mkeystash_compat/bigendian.c @@ -0,0 +1,17 @@ +#include + +/* + * Test to see if system is bigendian + * Returns 0 if it is big endian + * 1 if it is little endian + */ +int main() +{ + int int_var = 1; + unsigned char *char_array = (unsigned char*)&int_var; + + if (char_array[0] == 0) + return 0; /* big endian */ + else + return 1; /* little endian */ +} diff --git a/src/tests/mkeystash_compat/old_stash_bendian b/src/tests/mkeystash_compat/old_stash_bendian new file mode 100644 index 0000000000000000000000000000000000000000..7d3761fb7c903a3aa30b5a3812411d3a8acc8460 GIT binary patch literal 67 zc-muSVqjpfWng09bMyDt3vmq&(F<~Q^zmh2^k!i61nOo_H4tiP#PM?zd>=OW=U<|(i literal 0 Hc-jL100001 -- 2.47.2