summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Fiveash <will.fiveash@oracle.com>2008-08-07 00:22:37 +0000
committerWill Fiveash <will.fiveash@oracle.com>2008-08-07 00:22:37 +0000
commit5532539101656bb2816b8758d46444ec403eed31 (patch)
treeea6b86c36fa100429a7ebbc93f2689f0ab98524f
parent4075c43a9c48eef0db1a6555c389b7cd93082cad (diff)
downloadkrb5-mkey_keytab.tar.gz
Add test case to test that new mkey stash code is backward compat with old format stash filemkey_keytab
git-svn-id: svn://anonsvn.mit.edu/krb5/branches/mkey_keytab@20627 dc483132-0cff-0310-8789-dd5450dbe970
-rw-r--r--src/configure.in2
-rw-r--r--src/tests/Makefile.in2
-rw-r--r--src/tests/mkeystash_compat/Makefile.in49
-rw-r--r--src/tests/mkeystash_compat/bigendian.c17
-rw-r--r--src/tests/mkeystash_compat/old_stash_bendianbin0 -> 67 bytes
-rw-r--r--src/tests/mkeystash_compat/old_stash_lendianbin0 -> 30 bytes
6 files changed, 68 insertions, 2 deletions
diff --git a/src/configure.in b/src/configure.in
index 362df0459..30c7daa62 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 a02346c48..3c692b0e6 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 000000000..7b8956e43
--- /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 000000000..bcdeeb573
--- /dev/null
+++ b/src/tests/mkeystash_compat/bigendian.c
@@ -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
index 000000000..7d3761fb7
--- /dev/null
+++ b/src/tests/mkeystash_compat/old_stash_bendian
Binary files differ
diff --git a/src/tests/mkeystash_compat/old_stash_lendian b/src/tests/mkeystash_compat/old_stash_lendian
new file mode 100644
index 000000000..754c320a1
--- /dev/null
+++ b/src/tests/mkeystash_compat/old_stash_lendian
Binary files differ