]> git.ipfire.org Git - thirdparty/krb5.git/commitdiff
Add test case to test that new mkey stash code is backward compat with old format... mkey_keytab
authorWill Fiveash <will.fiveash@oracle.com>
Thu, 7 Aug 2008 00:22:37 +0000 (00:22 +0000)
committerWill Fiveash <will.fiveash@oracle.com>
Thu, 7 Aug 2008 00:22:37 +0000 (00:22 +0000)
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/mkey_keytab@20627 dc483132-0cff-0310-8789-dd5450dbe970

src/configure.in
src/tests/Makefile.in
src/tests/mkeystash_compat/Makefile.in [new file with mode: 0644]
src/tests/mkeystash_compat/bigendian.c [new file with mode: 0644]
src/tests/mkeystash_compat/old_stash_bendian [new file with mode: 0644]
src/tests/mkeystash_compat/old_stash_lendian [new file with mode: 0644]

index 362df045971afdcbb2a1df837c29039495891bd6..30c7daa62dc69b1012d2eeb25ddab36c2cca5447 100644 (file)
@@ -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
 )
index a02346c4815eee56e52950b7c1aef43f6f1c7708..3c692b0e6b4c2a360a53733535e56b9c403df031 100644 (file)
@@ -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 (file)
index 0000000..7b8956e
--- /dev/null
@@ -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 (file)
index 0000000..bcdeeb5
--- /dev/null
@@ -0,0 +1,17 @@
+#include <stdio.h>
+
+/*
+ * 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 (file)
index 0000000..7d3761f
Binary files /dev/null and b/src/tests/mkeystash_compat/old_stash_bendian differ
diff --git a/src/tests/mkeystash_compat/old_stash_lendian b/src/tests/mkeystash_compat/old_stash_lendian
new file mode 100644 (file)
index 0000000..754c320
Binary files /dev/null and b/src/tests/mkeystash_compat/old_stash_lendian differ