Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add test case to test that new mkey stash code is backward compat wit…

…h old format stash file.

git-svn-id: svn://anonsvn.mit.edu/krb5/branches/mkey_keytab@20627 dc483132-0cff-0310-8789-dd5450dbe970
  • Loading branch information...
commit bca875b90b040bd78c82a0335dc361d955536fb5 1 parent d256194
wfiveash authored
View
2  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
)
View
2  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@
View
49 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
+
View
17 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 */
+}
View
BIN  src/tests/mkeystash_compat/old_stash_bendian
Binary file not shown
View
BIN  src/tests/mkeystash_compat/old_stash_lendian
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.