svn rev #23902: branches/plugins/src/ config/ include/ lib/crypto/ lib/crypto/builtin/ ...

tsitkova@MIT.EDU tsitkova at MIT.EDU
Wed Apr 14 14:43:37 EDT 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=23902
Commit By: tsitkova
Log Message:
New plugin architecture code -  first draft.
This design provides the following advantages:

1. Simple and clear additions of new plugin APIs and new implementations of the existing plugins
2. Handle both static and dynamic plugins
3. Handle two types of plugins: Listener and Service
4. Uniform way to supply parameters for plugin configuration
5. Possible versioning of configuration
6. Potentially, configuration file  may contain hash values for the library validity verification
7. Tables of functions are created during make.

It was tested by implementing yarrow as PRNG plugin. (There is also a bogus plugin_prng_os implementation which uses system rand calls just for the demonstration purpose)
t_prng and all other tests in crypto_tests work (need to run "make check" from crypto_tests dir)
This particular version suggests using plugin configuration file in yaml format. It can be alternated by hardcoded or any other configuration.




Changed Files:
U   branches/plugins/src/Makefile.in
U   branches/plugins/src/config/pre.in
U   branches/plugins/src/configure.in
U   branches/plugins/src/include/k5-int.h
U   branches/plugins/src/lib/crypto/Makefile.in
U   branches/plugins/src/lib/crypto/builtin/Makefile.in
U   branches/plugins/src/lib/crypto/crypto_tests/Makefile.in
A   branches/plugins/src/lib/crypto/crypto_tests/plugin_conf.yml
U   branches/plugins/src/lib/crypto/crypto_tests/t_cksum.c
U   branches/plugins/src/lib/crypto/crypto_tests/t_encrypt.c
U   branches/plugins/src/lib/crypto/crypto_tests/t_prng.c
U   branches/plugins/src/lib/crypto/crypto_tests/t_short.c
U   branches/plugins/src/lib/crypto/krb/Makefile.in
U   branches/plugins/src/lib/crypto/krb/deps
U   branches/plugins/src/lib/crypto/krb/prng.c
D   branches/plugins/src/lib/crypto/krb/yarrow/
U   branches/plugins/src/lib/crypto/libk5crypto.exports
A   branches/plugins/src/plugin_core/
A   branches/plugins/src/plugin_core/Makefile.in
A   branches/plugins/src/plugin_core/deps
A   branches/plugins/src/plugin_core/impl/
A   branches/plugins/src/plugin_core/impl/Makefile.in
A   branches/plugins/src/plugin_core/impl/deps
A   branches/plugins/src/plugin_core/impl/plugin_default_factory.c
A   branches/plugins/src/plugin_core/impl/plugin_default_factory.h
A   branches/plugins/src/plugin_core/impl/plugin_default_manager.c
A   branches/plugins/src/plugin_core/impl/plugin_default_manager.h
A   branches/plugins/src/plugin_core/impl/plugin_impl.exports
A   branches/plugins/src/plugin_core/plugin_core.exports
A   branches/plugins/src/plugin_core/plugin_factory.c
A   branches/plugins/src/plugin_core/plugin_factory.h
A   branches/plugins/src/plugin_core/plugin_manager.c
A   branches/plugins/src/plugin_core/plugin_manager.h
A   branches/plugins/src/plugin_core/yaml_parser.c
A   branches/plugins/src/plugin_core/yaml_parser.h
A   branches/plugins/src/plugins/prng/
A   branches/plugins/src/plugins/prng/Makefile.in
A   branches/plugins/src/plugins/prng/deps
A   branches/plugins/src/plugins/prng/plugin_prng.c
A   branches/plugins/src/plugins/prng/plugin_prng.h
A   branches/plugins/src/plugins/prng/plugin_prng_os/
A   branches/plugins/src/plugins/prng/plugin_prng_os/Makefile.in
A   branches/plugins/src/plugins/prng/plugin_prng_os/deps
A   branches/plugins/src/plugins/prng/plugin_prng_os/os.exports
A   branches/plugins/src/plugins/prng/plugin_prng_os/plugin_prng_impl.c
A   branches/plugins/src/plugins/prng/plugin_prng_os/plugin_prng_impl.h
A   branches/plugins/src/plugins/prng/plugin_yarrow/
U   branches/plugins/src/plugins/prng/plugin_yarrow/Makefile.in
U   branches/plugins/src/plugins/prng/plugin_yarrow/deps
A   branches/plugins/src/plugins/prng/prng.exports
Modified: branches/plugins/src/Makefile.in
===================================================================
--- branches/plugins/src/Makefile.in	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/Makefile.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -7,7 +7,8 @@
 #	plugins/preauth/wpse
 #	plugins/preauth/cksum_body
 #	plugins/authdata/greet
-SUBDIRS=util include lib \
+SUBDIRS=util include plugins/prng   plugin_core  lib \
+	plugins/prng/plugin_yarrow   plugin_core/impl   \
 	@ldap_plugin_dir@ \
 	plugins/kdb/db2 \
 	plugins/preauth/pkinit \

Modified: branches/plugins/src/config/pre.in
===================================================================
--- branches/plugins/src/config/pre.in	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/config/pre.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -324,6 +324,8 @@
 GSS_DEPLIB	= $(TOPLIBD)/libgssapi_krb5$(DEPLIBEXT)
 KRB5_DEPLIB	= $(TOPLIBD)/libkrb5$(DEPLIBEXT)
 CRYPTO_DEPLIB	= $(TOPLIBD)/libk5crypto$(DEPLIBEXT)
+PLUGIN_CORE_DEPLIB	= $(TOPLIBD)/../plugin_core/plugin_core$(DEPLIBEXT)
+PLUGIN_PRNG_DEPLIB	= $(TOPLIBD)/../plugins/prng/plugin_prng$(DEPLIBEXT)
 COM_ERR_DEPLIB	= $(COM_ERR_DEPLIB- at COM_ERR_VERSION@)
 COM_ERR_DEPLIB-sys = # empty
 COM_ERR_DEPLIB-k5 = $(TOPLIBD)/libcom_err$(DEPLIBEXT)
@@ -337,7 +339,7 @@
 SS_DEPLIB-sys	=
 APPUTILS_DEPLIB	= $(TOPLIBD)/libapputils.a
 
-KRB5_BASE_DEPLIBS	= $(KRB5_DEPLIB) $(CRYPTO_DEPLIB) $(COM_ERR_DEPLIB) $(SUPPORT_DEPLIB)
+KRB5_BASE_DEPLIBS	= $(KRB5_DEPLIB)  $(PLUGIN_CORE_DEPLIB) $(CRYPTO_DEPLIB) $(COM_ERR_DEPLIB) $(SUPPORT_DEPLIB) $(PLUGIN_PRNG_DEPLIB)
 KDB5_DEPLIBS		= $(KDB5_DEPLIB) $(KDB5_PLUGIN_DEPLIBS)
 GSS_DEPLIBS		= $(GSS_DEPLIB)
 GSSRPC_DEPLIBS		= $(GSSRPC_DEPLIB) $(GSS_DEPLIBS)
@@ -379,7 +381,7 @@
 # HESIOD_LIBS is -lhesiod...
 HESIOD_LIBS	= @HESIOD_LIBS@
 
-KRB5_BASE_LIBS	= $(KRB5_LIB) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(GEN_LIB) $(LIBS) $(DL_LIB)
+KRB5_BASE_LIBS	= $(KRB5_LIB) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(GEN_LIB) $(LIBS) $(DL_LIB) $(PLUGIN_CORE_DEPLIB) $(PLUGIN_PRNG_DEPLIB)
 KDB5_LIBS	= $(KDB5_LIB) $(GSSRPC_LIBS)
 GSS_LIBS	= $(GSS_KRB5_LIB)
 # needs fixing if ever used on Mac OS X!

Modified: branches/plugins/src/configure.in
===================================================================
--- branches/plugins/src/configure.in	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/configure.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -169,7 +169,7 @@
 AC_PROG_LEX
 AC_C_CONST
 AC_HEADER_DIRENT
-AC_CHECK_FUNCS(strdup setvbuf inet_ntoa inet_aton seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strftime strptime geteuid setenv unsetenv getenv gmtime_r localtime_r bswap16 bswap64 mkstemp getusershell access getcwd srand48 srand srandom stat strchr strerror strerror_r)
+AC_CHECK_FUNCS(strdup setvbuf inet_ntoa inet_aton seteuid setresuid setreuid setegid setresgid setregid setsid flock fchmod chmod strftime strptime geteuid setenv unsetenv getenv gmtime_r localtime_r bswap16 bswap64 mkstemp getusershell lstat access getcwd srand48 srand srandom stat strchr strerror strerror_r)
 
 AC_CHECK_FUNC(mkstemp,
 [MKSTEMP_ST_OBJ=
@@ -1078,7 +1078,7 @@
 	lib/crypto/krb/prf lib/crypto/krb/rand2key
 	lib/crypto/$CRYPTO_IMPL lib/crypto/$CRYPTO_IMPL/md4 lib/crypto/$CRYPTO_IMPL/md5
 	lib/crypto/krb/old lib/crypto/krb/raw lib/crypto/$CRYPTO_IMPL/sha1
-	lib/crypto/krb/arcfour lib/crypto/krb/yarrow lib/crypto/$CRYPTO_IMPL/aes
+	lib/crypto/krb/arcfour lib/crypto/$CRYPTO_IMPL/aes
 	lib/crypto/crypto_tests
 
 	lib/krb5 lib/krb5/error_tables lib/krb5/asn.1 lib/krb5/ccache
@@ -1115,6 +1115,11 @@
 	plugins/authdata/greet_client
 	plugins/authdata/greet_server
 
+	plugins/prng
+	plugin_core/impl
+	plugins/prng/plugin_yarrow
+	plugin_core
+
 	clients clients/klist clients/kinit clients/kvno
 	clients/kdestroy clients/kpasswd clients/ksu
 

Modified: branches/plugins/src/include/k5-int.h
===================================================================
--- branches/plugins/src/include/k5-int.h	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/include/k5-int.h	2010-04-14 18:43:37 UTC (rev 23902)
@@ -1424,6 +1424,14 @@
 struct _kdb5_dal_handle;        /* private, in kdb5.h */
 typedef struct _kdb5_dal_handle kdb5_dal_handle;
 struct _kdb_log_context;
+
+/* Plugin API ----  PLUGIN HANDLE */
+typedef struct _plhandle{
+        void *api;
+    struct _plhandle *next;
+} plhandle;
+
+
 struct _krb5_context {
     krb5_magic      magic;
     krb5_enctype    *in_tkt_etypes;

Modified: branches/plugins/src/lib/crypto/Makefile.in
===================================================================
--- branches/plugins/src/lib/crypto/Makefile.in	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/Makefile.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -21,7 +21,7 @@
 STOBJLISTS=krb/crc32/OBJS.ST krb/dk/OBJS.ST @CRYPTO_IMPL@/enc_provider/OBJS.ST	\
 	@CRYPTO_IMPL@/hash_provider/OBJS.ST krb/checksum/OBJS.ST  		\
 	krb/prf/OBJS.ST krb/rand2key/OBJS.ST 		 			\
-	krb/old/OBJS.ST krb/raw/OBJS.ST krb/yarrow/OBJS.ST 			\
+	krb/old/OBJS.ST krb/raw/OBJS.ST  			\
 	@CRYPTO_IMPL@/md4/OBJS.ST @CRYPTO_IMPL@/md5/OBJS.ST @CRYPTO_IMPL@/sha1/OBJS.ST 		\
 	krb/arcfour/OBJS.ST  @CRYPTO_IMPL@/aes/OBJS.ST @CRYPTO_IMPL@/des/OBJS.ST	\
 	krb/OBJS.ST  @CRYPTO_IMPL@/OBJS.ST
@@ -29,7 +29,7 @@
 SUBDIROBJLISTS=krb/crc32/OBJS.ST krb/dk/OBJS.ST @CRYPTO_IMPL@/enc_provider/OBJS.ST 	\
 	@CRYPTO_IMPL@/hash_provider/OBJS.ST krb/checksum/OBJS.ST 		\
 	krb/prf/OBJS.ST krb/rand2key/OBJS.ST 		 			\
-	krb/old/OBJS.ST krb/raw/OBJS.ST  krb/yarrow/OBJS.ST 			\
+	krb/old/OBJS.ST krb/raw/OBJS.ST   			\
 	@CRYPTO_IMPL@/md4/OBJS.ST @CRYPTO_IMPL@/md5/OBJS.ST	@CRYPTO_IMPL@/sha1/OBJS.ST 		\
 	krb/arcfour/OBJS.ST @CRYPTO_IMPL@/aes/OBJS.ST @CRYPTO_IMPL@/des/OBJS.ST		\
 	krb/OBJS.ST @CRYPTO_IMPL@/OBJS.ST
@@ -38,7 +38,7 @@
 # link editor and loader support it.
 DEPLIBS=
 SHLIB_DIRS=-L$(TOPLIBD)
-SHLIB_EXPLIBS= $(SUPPORT_LIB) @CRYPTO_LIBS@ $(LIBS)
+SHLIB_EXPLIBS= $(SUPPORT_LIB) @CRYPTO_LIBS@ $(LIBS) -lyaml  $(PLUGIN_CORE_DEPLIB)  $(PLUGIN_PRNG_DEPLIB) 
 SHLIB_EXPDEPLIBS= $(SUPPORT_DEPLIB)
 SHLIB_LDFLAGS= $(LDFLAGS) @SHLIB_RPATH_DIRS@
 SHLIB_LIBDIRS= @SHLIB_LIBDIRS@

Modified: branches/plugins/src/lib/crypto/builtin/Makefile.in
===================================================================
--- branches/plugins/src/lib/crypto/builtin/Makefile.in	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/builtin/Makefile.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -62,7 +62,7 @@
 	diff t_cf2.output $(srcdir)/t_cf2.expected
 
 t_cf2$(EXEEXT): t_cf2.$(OBJEXT) $(SUPPORT_DEPLIB)
-	$(CC_LINK) -o $@ t_cf2.$(OBJEXT)  -lkrb5 -lk5crypto -lcom_err $(SUPPORT_LIB)
+	$(CC_LINK) -o $@ t_cf2.$(OBJEXT) -L$(BUILDTOP)/plugin_core -lkrb5 -lk5crypto -lcom_err $(SUPPORT_LIB) 
 
 clean::
 	$(RM)  t_cf2 t_cf2.o  t_cf2.output

Modified: branches/plugins/src/lib/crypto/crypto_tests/Makefile.in
===================================================================
--- branches/plugins/src/lib/crypto/crypto_tests/Makefile.in	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/crypto_tests/Makefile.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -3,16 +3,24 @@
 LOCALINCLUDES = -I$(srcdir)/../krb -I$(srcdir)/../@CRYPTO_IMPL@/enc_provider 		\
 	-I$(srcdir)/../@CRYPTO_IMPL@/hash_provider -I$(srcdir)/../krb/keyhash_provider 	\
 	-I$(srcdir)/../krb/dk -I$(srcdir)/../@CRYPTO_IMPL@/ 			\
-	-I$(srcdir)/../krb/yarrow 	\
 	-I$(srcdir)/../krb/crc32 -I$(srcdir)/../krb/old -I$(srcdir)/../krb/raw 	\
 	-I$(srcdir)/../@CRYPTO_IMPL@/aes -I$(srcdir)/../@CRYPTO_IMPL@/des 	\
 	-I$(srcdir)/../@CRYPTO_IMPL@/arcfour -I$(srcdir)/../@CRYPTO_IMPL@/sha1 	\
-	-I$(srcdir)/../@CRYPTO_IMPL@/md5 -I$(srcdir)/../@CRYPTO_IMPL@/md4 
+	-I$(srcdir)/../@CRYPTO_IMPL@/md5 -I$(srcdir)/../@CRYPTO_IMPL@/md4 \
+	-I$(srcdir)/../../../plugin_core/impl  -I$(srcdir)/../../../plugins/prng \
+	-I$(srcdir)/../../../plugins/prng/plugin_yarrow -I$(srcdir)/../../../plugin_core
 RUN_SETUP = @KRB5_RUN_ENV@
 PROG_LIBPATH=-L$(TOPLIBD)
 PROG_RPATH=$(KRB5_LIBDIR)
 DEFS=
 
+PLUGINS_LIBS = \
+	../../../plugin_core/impl/plugin_default_manager.so 	\
+	../../../plugin_core/impl/plugin_default_factory.so 	\ 
+	../../../plugins/prng/plugin_yarrow/plugin_prng_impl.so 	\ 
+	../../../plugins/prng/plugin_yarrow/yarrow.so 	\ 
+	../../../plugins/prng/plugin_yarrow/ycipher.so 	
+
 EXTRADEPSRCS=\
 	$(srcdir)/t_nfold.c	\
 	$(srcdir)/t_encrypt.c	\
@@ -41,15 +49,17 @@
 # NOTE: The t_cksum known checksum values are primarily for regression
 # testing.  They are not derived a priori, but are known to produce
 # checksums that interoperate.
-check-unix:: t_nfold t_encrypt t_prf t_prng t_hmac \
+#  check-unix:: t_nfold t_encrypt t_prf t_prng t_hmac \
+#
+check-unix:: t_prng t_nfold t_encrypt t_hmac t_prf\
 		t_cksum4 t_cksum5 \
 		aes-test  \
 		t_mddriver4 t_mddriver \
 		t_crc t_cts t_short
+	$(RUN_SETUP) $(VALGRIND) ./t_prng <$(srcdir)/t_prng.seed >t_prng.output && \
+	diff t_prng.output $(srcdir)/t_prng.expected
 	$(RUN_SETUP) $(VALGRIND) ./t_nfold
 	$(RUN_SETUP) $(VALGRIND) ./t_encrypt
-	$(RUN_SETUP) $(VALGRIND) ./t_prng <$(srcdir)/t_prng.seed >t_prng.output && \
-	diff t_prng.output $(srcdir)/t_prng.expected
 	$(RUN_SETUP) $(VALGRIND) ./t_hmac
 	$(RUN_SETUP) $(VALGRIND) ./t_prf <$(srcdir)/t_prf.in >t_prf.output
 	diff t_prf.output $(srcdir)/t_prf.expected
@@ -77,30 +87,31 @@
 	$(CC) -c $(ALL_CFLAGS) $(srcdir)/../krb/nfold.c
 
 t_encrypt$(EXEEXT): t_encrypt.$(OBJEXT) $(CRYPTO_DEPLIB) $(SUPPORT_DEPLIB)
-	$(CC_LINK) -o $@ t_encrypt.$(OBJEXT)  -lkrb5 -lk5crypto -lcom_err $(SUPPORT_LIB)
+	$(CC_LINK) -o $@ t_encrypt.$(OBJEXT)  -lkrb5 -lk5crypto -lcom_err $(SUPPORT_LIB) 	\
+	$(PLUGINS_LIBS)
 
 t_prf$(EXEEXT): t_prf.$(OBJEXT) $(SUPPORT_DEPLIB)
-	$(CC_LINK) -o $@ t_prf.$(OBJEXT)  -lkrb5 -lk5crypto -lcom_err $(SUPPORT_LIB)
+	$(CC_LINK) -o $@ t_prf.$(OBJEXT)  -lkrb5 -lk5crypto -lcom_err $(SUPPORT_LIB) $(PLUGINS_LIBS)
 
 t_prng$(EXEEXT): t_prng.$(OBJEXT) $(SUPPORT_DEPLIB)
-	$(CC_LINK) -o $@ t_prng.$(OBJEXT)  -lk5crypto -lcom_err $(SUPPORT_LIB)
+	$(CC_LINK) -o $@ t_prng.$(OBJEXT)  -lk5crypto -lcom_err $(SUPPORT_LIB)  $(PLUGINS_LIBS)
 
 t_hmac$(EXEEXT): t_hmac.$(OBJEXT) $(CRYPTO_DEPLIB) $(SUPPORT_DEPLIB)
-	$(CC_LINK) -o $@ t_hmac.$(OBJEXT) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB)
+	$(CC_LINK) -o $@ t_hmac.$(OBJEXT) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB)  $(PLUGINS_LIBS)
 
 #t_pkcs5$(EXEEXT): t_pkcs5.$(OBJEXT) $(CRYPTO_DEPLIB) $(SUPPORT_DEPLIB)
-#	$(CC_LINK) -o $@ t_pkcs5.$(OBJEXT) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB)
+#	$(CC_LINK) -o $@ t_pkcs5.$(OBJEXT) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(PLUGINS_LIBS)
 
 vectors$(EXEEXT): vectors.$(OBJEXT) $(CRYPTO_DEPLIB) $(SUPPORT_DEPLIB)
-	$(CC_LINK) -o $@ vectors.$(OBJEXT) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB)
+	$(CC_LINK) -o $@ vectors.$(OBJEXT) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(PLUGINS_LIBS)
 
- t_cts$(EXEEXT): t_cts.$(OBJEXT) $(CRYPTO_DEPLIB) $(SUPPORT_DEPLIB)
+t_cts$(EXEEXT): t_cts.$(OBJEXT) $(CRYPTO_DEPLIB) $(SUPPORT_DEPLIB)
 	$(CC_LINK) -o $@ t_cts.$(OBJEXT) \
-		$(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB)
+		$(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(PLUGINS_LIBS)
 
 t_short$(EXEEXT): t_short.$(OBJEXT) $(CRYPTO_DEPLIB) $(SUPPORT_DEPLIB)
 	$(CC_LINK) -o $@ t_short.$(OBJEXT) \
-		$(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB)
+		$(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(PLUGINS_LIBS)
 
 t_cksum4.o: $(srcdir)/t_cksum.c
 	$(CC) -DMD=4 $(ALL_CFLAGS) -o t_cksum4.o -c $(srcdir)/t_cksum.c
@@ -109,31 +120,31 @@
 	$(CC) -DMD=5 $(ALL_CFLAGS) -o t_cksum5.o -c $(srcdir)/t_cksum.c
 
 t_cksum4: t_cksum4.o $(CRYTPO_DEPLIB)
-	$(CC_LINK) -o t_cksum4 t_cksum4.o $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(LIBS)
+	$(CC_LINK) -o t_cksum4 t_cksum4.o $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(LIBS) $(PLUGINS_LIBS)
 
 t_cksum5: t_cksum5.o $(CRYPTO_DEPLIB)
-	$(CC_LINK) -o t_cksum5 t_cksum5.o $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(LIBS)
+	$(CC_LINK) -o t_cksum5 t_cksum5.o $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(LIBS) $(PLUGINS_LIBS)
 
 t_crc: t_crc.o $(CRYPTO_DEPLIB) $(SUPPORT_DEPLIB)
-	$(CC_LINK) -o $@ t_crc.o $(K5CRYPTO_LIB) $(SUPPORT_LIB)
+	$(CC_LINK) -o $@ t_crc.o $(K5CRYPTO_LIB) $(SUPPORT_LIB) $(PLUGINS_LIBS)
 
 aes-test: aes-test.$(OBJEXT) $(CRYPTO_DEPLIB)
-	$(CC_LINK) -o aes-test aes-test.$(OBJEXT) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB)
+	$(CC_LINK) -o aes-test aes-test.$(OBJEXT) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(PLUGINS_LIBS)
 
 t_mddriver4.o: $(srcdir)/t_mddriver.c
 	$(CC) -DMD=4 $(ALL_CFLAGS) -o t_mddriver4.o -c $(srcdir)/t_mddriver.c
 
-t_mddriver4: t_mddriver4.o  $(SUPPORT_DEPLIB) $(CRYPTO_DEPLIB)
-	$(CC_LINK) -DMD4  -o t_mddriver4 t_mddriver4.o -lk5crypto $(SUPPORT_LIB)
+t_mddriver4: t_mddriver4.o  $(SUPPORT_DEPLIB) $(CRYPTO_DEPLIB) 
+	$(CC_LINK) -DMD4  -o t_mddriver4 t_mddriver4.o -lk5crypto $(SUPPORT_LIB) $(PLUGINS_LIBS)
 
 t_mddriver: t_mddriver.o  $(SUPPORT_DEPLIB) $(CRYPTO_DEPLIB)
-	$(CC_LINK) -o t_mddriver t_mddriver.o -lk5crypto $(SUPPORT_LIB)
+	$(CC_LINK) -o t_mddriver t_mddriver.o -lk5crypto $(SUPPORT_LIB) $(PLUGINS_LIBS)
 
 t_kperf: t_kperf.o $(SUPPORT_DEPLIB) $(CRYPTO_DEPLIB)
-	$(CC_LINK) -o t_kperf t_kperf.o  $(SUPPORT_LIB) $(CRYPTO_DEPLIB)
+	$(CC_LINK) -o t_kperf t_kperf.o  $(SUPPORT_LIB) $(CRYPTO_DEPLIB) $(PLUGINS_LIBS)
 
 ytest: ytest.o shs.o $(SUPPORT_DEPLIB) $(CRYPTO_DEPLIB)
-	$(CC_LINK) -o ytest ytest.o  $(SUPPORT_LIB)  $(CRYPTO_DEPLIB)
+	$(CC_LINK) -o ytest ytest.o  $(SUPPORT_LIB)  $(CRYPTO_DEPLIB) $(PLUGINS_LIBS)
 
 
 
@@ -149,7 +160,7 @@
 		t_kperf.o t_kperf t_short t_short.o \
 		t_mddriver$(EXEEXT) $(OUTPRE)t_mddriver.$(OBJEXT)
 
-	-$(RM) t_prng.output
+# temp	-$(RM) t_prng.output
 	-$(RM) t_prf.output
 
 @lib_frag@

Added: branches/plugins/src/lib/crypto/crypto_tests/plugin_conf.yml
===================================================================
--- branches/plugins/src/lib/crypto/crypto_tests/plugin_conf.yml	                        (rev 0)
+++ branches/plugins/src/lib/crypto/crypto_tests/plugin_conf.yml	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,17 @@
+- !Plugin
+  api: plugin_prng
+  type: service
+  constructor:
+    factory_name: plugin_default_factory
+    factory_type: static
+    plugin_name: plugin_yarrow_prng
+  Properties: null
+
+- !Plugin
+  api: audit
+  type: listener
+  constructor: 
+    factory_name: plugin_default_factory
+    factory_type: shared
+    plugin_name: undef
+  Properties: null


Added: svn:executable
   + *

Modified: branches/plugins/src/lib/crypto/crypto_tests/t_cksum.c
===================================================================
--- branches/plugins/src/lib/crypto/crypto_tests/t_cksum.c	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/crypto_tests/t_cksum.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -31,7 +31,10 @@
  */
 
 #include "k5-int.h"
+#include <plugin_default_manager.h>
+#include <plugin_prng.h>
 
+
 #define MD5_K5BETA_COMPAT
 #define MD4_K5BETA_COMPAT
 
@@ -96,7 +99,15 @@
     krb5_error_code       kret=0;
     krb5_data             plaintext;
     krb5_checksum         checksum, knowncksum;
+    plugin_manager* default_manager;
+    const char conf_path[] = "plugin_conf.yml";
 
+    default_manager = plugin_default_manager_get_instance();
+    set_plugin_manager_instance(default_manager);
+
+    plugin_manager_configure(conf_path);
+    plugin_manager_start();
+
     /* this is a terrible seed, but that's ok for the test. */
 
     plaintext.length = 8;

Modified: branches/plugins/src/lib/crypto/crypto_tests/t_encrypt.c
===================================================================
--- branches/plugins/src/lib/crypto/crypto_tests/t_encrypt.c	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/crypto_tests/t_encrypt.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -34,7 +34,10 @@
 #include "k5-int.h"
 #include "etypes.h"
 #include <stdio.h>
+#include <plugin_default_manager.h>
+#include <plugin_prng.h>
 
+
 /* What enctypes should we test?*/
 krb5_enctype interesting_enctypes[] = {
     ENCTYPE_DES_CBC_CRC,
@@ -98,7 +101,15 @@
     krb5_enc_data enc_out, enc_out2;
     krb5_keyblock *keyblock;
     krb5_key key;
+    plugin_manager* default_manager;
+    const char conf_path[] = "plugin_conf.yml";
 
+        default_manager = plugin_default_manager_get_instance();
+        set_plugin_manager_instance(default_manager);
+
+        plugin_manager_configure(conf_path);
+        plugin_manager_start();
+
     memset(iov, 0, sizeof(iov));
 
     in.data = "This is a test.\n";

Modified: branches/plugins/src/lib/crypto/crypto_tests/t_prng.c
===================================================================
--- branches/plugins/src/lib/crypto/crypto_tests/t_prng.c	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/crypto_tests/t_prng.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -40,12 +40,23 @@
 
 #include "k5-int.h"
 #include <assert.h>
+#include <plugin_default_manager.h>
+#include <plugin_prng.h>
 
 int main () {
     krb5_error_code ret;
     krb5_data input, output;
     unsigned int source_id, seed_length;
     unsigned int i;
+    plugin_manager* default_manager;
+    const char conf_path[] = "plugin_conf.yml";
+
+        default_manager = plugin_default_manager_get_instance();
+        set_plugin_manager_instance(default_manager);
+
+        plugin_manager_configure(conf_path);
+        plugin_manager_start();
+
     while (1) {
         /* Read source*/
         if (scanf ("%u", &source_id ) == EOF )

Modified: branches/plugins/src/lib/crypto/crypto_tests/t_short.c
===================================================================
--- branches/plugins/src/lib/crypto/crypto_tests/t_short.c	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/crypto_tests/t_short.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -31,7 +31,10 @@
  */
 
 #include "k5-int.h"
+#include <plugin_default_manager.h>
+#include <plugin_prng.h>
 
+
 krb5_enctype interesting_enctypes[] = {
     ENCTYPE_DES_CBC_CRC,
     ENCTYPE_DES_CBC_MD4,
@@ -116,7 +119,15 @@
 {
     int i;
     krb5_data notrandom;
+    plugin_manager* default_manager;
+    const char conf_path[] = "plugin_conf.yml";
 
+        default_manager = plugin_default_manager_get_instance();
+        set_plugin_manager_instance(default_manager);
+
+        plugin_manager_configure(conf_path);
+        plugin_manager_start();
+
     notrandom.data = "notrandom";
     notrandom.length = 9;
     krb5_c_random_seed(NULL, &notrandom);

Modified: branches/plugins/src/lib/crypto/krb/Makefile.in
===================================================================
--- branches/plugins/src/lib/crypto/krb/Makefile.in	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/krb/Makefile.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -1,14 +1,15 @@
 mydir=lib/crypto/krb
 BUILDTOP=$(REL)..$(S)..$(S)..
 SUBDIRS= arcfour checksum crc32 dk \
-	prf rand2key old raw yarrow 
+	prf rand2key old raw 
 LOCALINCLUDES = -I$(srcdir) -I$(srcdir)/../@CRYPTO_IMPL@/enc_provider -I$(srcdir)/dk	\
 		-I$(srcdir)/../@CRYPTO_IMPL@/hash_provider				\
 		-I$(srcdir)/prf -I$(srcdir)/rand2key		 			\
-		-I$(srcdir)/old -I$(srcdir)/raw -I$(srcdir)/yarrow 			\
+		-I$(srcdir)/old -I$(srcdir)/raw  			\
 		-I$(srcdir)/../@CRYPTO_IMPL@/ -I$(srcdir)/../@CRYPTO_IMPL@/des		\
 		-I$(srcdir)/../@CRYPTO_IMPL@/aes -I$(srcdir)/arcfour 	\
-		-I$(srcdir)/../@CRYPTO_IMPL@/sha1 -I$(srcdir)/../@CRYPTO_IMPL@
+		-I$(srcdir)/../@CRYPTO_IMPL@/sha1 -I$(srcdir)/../@CRYPTO_IMPL@	\
+		-I$(BUILDTOP)/plugins/prng -I$(BUILDTOP)/plugin_core
 PROG_LIBPATH=-L$(TOPLIBD)
 PROG_RPATH=$(KRB5_LIBDIR)
 DEFS=
@@ -143,11 +144,11 @@
 
 STOBJLISTS=arcfour/OBJS.ST checksum/OBJS.ST crc32/OBJS.ST	\
 	dk/OBJS.ST prf/OBJS.ST rand2key/OBJS.ST			\
-	old/OBJS.ST raw/OBJS.ST  yarrow/OBJS.ST  OBJS.ST
+	old/OBJS.ST raw/OBJS.ST  OBJS.ST
 
 SUBDIROBJLISTS=arcfour/OBJS.ST checksum/OBJS.ST crc32/OBJS.ST	\
 	dk/OBJS.ST prf/OBJS.ST rand2key/OBJS.ST			\
-	old/OBJS.ST raw/OBJS.ST  yarrow/OBJS.ST 
+	old/OBJS.ST raw/OBJS.ST  
 
 ##DOS##LIBOBJS = $(OBJS)
 
@@ -183,9 +184,6 @@
 	cd ..\raw
 	@echo Making in crypto\raw
 	$(MAKE) -$(MFLAGS)
-	cd ..\yarrow
-	@echo Making in crypto\yarrow
-	$(MAKE) -$(MFLAGS)
 	cd ..
 
 clean-windows::
@@ -213,9 +211,6 @@
 	cd ..\raw
 	@echo Making clean in crypto\raw
 	$(MAKE) -$(MFLAGS) clean
-	cd ..\yarrow
-	@echo Making clean in crypto\yarrow
-	$(MAKE) -$(MFLAGS) clean
 	cd ..
 
 check-windows::
@@ -243,9 +238,6 @@
 	cd ..\raw
 	@echo Making check in crypto\raw
 	$(MAKE) -$(MFLAGS) check
-	cd ..\yarrow
-	@echo Making check in crypto\yarrow
-	$(MAKE) -$(MFLAGS) check
 	cd ..
 
 

Modified: branches/plugins/src/lib/crypto/krb/deps
===================================================================
--- branches/plugins/src/lib/crypto/krb/deps	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/krb/deps	2010-04-14 18:43:37 UTC (rev 23902)
@@ -338,8 +338,7 @@
   $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
   $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../builtin/enc_provider/enc_provider.h \
   $(srcdir)/../builtin/sha1/shs.h $(srcdir)/../builtin/yhash.h \
-  $(srcdir)/yarrow/yarrow.h $(srcdir)/yarrow/ycipher.h \
-  $(srcdir)/yarrow/ytypes.h $(top_srcdir)/include/k5-buf.h \
+  $(top_srcdir)/include/k5-buf.h \
   $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \
   $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \
   $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \

Modified: branches/plugins/src/lib/crypto/krb/prng.c
===================================================================
--- branches/plugins/src/lib/crypto/krb/prng.c	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/krb/prng.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -25,78 +25,24 @@
  */
 
 #include "k5-int.h"
-#include "enc_provider.h"
 #include <assert.h>
 #include "k5-thread.h"
 
-#include "yarrow.h"
-static Yarrow_CTX y_ctx;
-#define yarrow_lock krb5int_yarrow_lock
-k5_mutex_t yarrow_lock = K5_MUTEX_PARTIAL_INITIALIZER;
+#include <plugin_manager.h>
+#include <plugin_prng.h>
 
-/* Helper function to estimate entropy based on sample length
- * and where it comes from.
- */
 
-static size_t
-entropy_estimate(unsigned int randsource, size_t length)
-{
-    switch (randsource) {
-    case KRB5_C_RANDSOURCE_OLDAPI:
-        return 4 * length;
-    case KRB5_C_RANDSOURCE_OSRAND:
-        return 8 * length;
-    case KRB5_C_RANDSOURCE_TRUSTEDPARTY:
-        return 4 * length;
-    case KRB5_C_RANDSOURCE_TIMING:
-        return 2;
-    case KRB5_C_RANDSOURCE_EXTERNAL_PROTOCOL:
-        return 0;
-    default:
-        abort();
-    }
-    return 0;
-}
 
-int krb5int_prng_init(void)
-{
-    unsigned i, source_id;
-    int yerr;
-
-    yerr = k5_mutex_finish_init(&yarrow_lock);
-    if (yerr)
-        return yerr;
-
-    yerr = krb5int_yarrow_init (&y_ctx, NULL);
-    if (yerr != YARROW_OK && yerr != YARROW_NOT_SEEDED)
-        return KRB5_CRYPTO_INTERNAL;
-
-    for (i=0; i < KRB5_C_RANDSOURCE_MAX; i++ ) {
-        if (krb5int_yarrow_new_source(&y_ctx, &source_id) != YARROW_OK)
-            return KRB5_CRYPTO_INTERNAL;
-        assert (source_id == i);
-    }
-
-    return 0;
-}
-
 krb5_error_code KRB5_CALLCONV
 krb5_c_random_add_entropy(krb5_context context, unsigned int randsource,
                           const krb5_data *data)
 {
-    int yerr;
+    plhandle handle = plugin_manager_get_service("plugin_prng");
 
-    /* Make sure the mutex got initialized.  */
-    yerr = krb5int_crypto_init();
-    if (yerr)
-        return yerr;
-    /* Now, finally, feed in the data.  */
-    yerr = krb5int_yarrow_input(&y_ctx, randsource,
-                                data->data, data->length,
-                                entropy_estimate(randsource, data->length));
-    if (yerr != YARROW_OK)
-        return KRB5_CRYPTO_INTERNAL;
+    plugin_prng_seed(handle, context, randsource, data);
     return 0;
+
+
 }
 
 krb5_error_code KRB5_CALLCONV
@@ -106,110 +52,43 @@
 }
 
 krb5_error_code KRB5_CALLCONV
-krb5_c_random_make_octets(krb5_context context, krb5_data *data)
+krb5_c_random_os_entropy(krb5_context context, int strong, int *success)
 {
-    int yerr;
-    yerr = krb5int_yarrow_output(&y_ctx, data->data, data->length);
-    if (yerr == YARROW_NOT_SEEDED) {
-        yerr = krb5int_yarrow_reseed(&y_ctx, YARROW_SLOW_POOL);
-        if (yerr == YARROW_OK)
-            yerr = krb5int_yarrow_output(&y_ctx, data->data, data->length);
-    }
-    if (yerr != YARROW_OK)
-        return KRB5_CRYPTO_INTERNAL;
+    plhandle handle = plugin_manager_get_service("plugin_prng");
+
+    plugin_prng_os_seed(handle, context, strong, success);
+
     return 0;
 }
 
-void
-krb5int_prng_cleanup (void)
+krb5_error_code KRB5_CALLCONV
+krb5_c_random_make_octets(krb5_context context, krb5_data *data)
 {
-    krb5int_yarrow_final (&y_ctx);
-    k5_mutex_destroy(&yarrow_lock);
-}
+    plhandle handle = plugin_manager_get_service("plugin_prng");
 
+    plugin_prng_rand(handle, context,  data);
 
-/*
- * Routines to get entropy from the OS.  For UNIX we try /dev/urandom
- * and /dev/random.  Currently we don't do anything for Windows.
- */
-#if defined(_WIN32)
-
-krb5_error_code KRB5_CALLCONV
-krb5_c_random_os_entropy(krb5_context context, int strong, int *success)
-{
-    if (success)
-        *success = 0;
     return 0;
 }
 
-#else /*Windows*/
-#ifdef HAVE_UNISTD_H
-#include <unistd.h>
-#endif
-#ifdef HAVE_SYS_STAT_H
-#include <sys/stat.h>
-#endif
-
-/*
- * Helper function to read entropy from  a random device.  Takes the
- * name of a device, opens it, makes sure it is a device and if so,
- * reads entropy.  Returns  a boolean indicating whether entropy was
- * read.
- */
-
-static int
-read_entropy_from_device(krb5_context context, const char *device)
+int krb5int_prng_init(void)
 {
-    krb5_data data;
-    struct stat sb;
-    int fd;
-    unsigned char buf[YARROW_SLOW_THRESH/8], *bp;
-    int left;
+    int ret = 0;
+    plhandle handle = plugin_manager_get_service("plugin_prng");
 
-    fd = open (device, O_RDONLY);
-    if (fd == -1)
-        return 0;
-    set_cloexec_fd(fd);
-    if (fstat(fd, &sb) == -1 || S_ISREG(sb.st_mode)) {
-        close(fd);
-        return 0;
-    }
+    ret = plugin_prng_init(handle);
 
-    for (bp = buf, left = sizeof(buf); left > 0;) {
-        ssize_t count;
-        count = read(fd, bp, (unsigned) left);
-        if (count <= 0) {
-            close(fd);
-            return 0;
-        }
-        left -= count;
-        bp += count;
-    }
-    close(fd);
-    data.length = sizeof (buf);
-    data.data = (char *) buf;
-    return (krb5_c_random_add_entropy(context, KRB5_C_RANDSOURCE_OSRAND,
-                                      &data) == 0);
+    return ret;
 }
 
-krb5_error_code KRB5_CALLCONV
-krb5_c_random_os_entropy(krb5_context context, int strong, int *success)
+void
+krb5int_prng_cleanup(void)
 {
-    int unused;
-    int *oursuccess = success ? success : &unused;
+    plhandle handle = plugin_manager_get_service("plugin_prng");
 
-    *oursuccess = 0;
-    /* If we are getting strong data then try that first.  We are
-       guaranteed to cause a reseed of some kind if strong is true and
-       we have both /dev/random and /dev/urandom.  We want the strong
-       data included in the reseed so we get it first.*/
-    if (strong) {
-        if (read_entropy_from_device(context, "/dev/random"))
-            *oursuccess = 1;
-    }
-    if (read_entropy_from_device(context, "/dev/urandom"))
-        *oursuccess = 1;
-    return 0;
+    plugin_prng_cleanup(handle);
+
+    return;
 }
 
-#endif /*Windows or pre-OSX Mac*/
+

Modified: branches/plugins/src/lib/crypto/libk5crypto.exports
===================================================================
--- branches/plugins/src/lib/crypto/libk5crypto.exports	2010-04-14 14:40:16 UTC (rev 23901)
+++ branches/plugins/src/lib/crypto/libk5crypto.exports	2010-04-14 18:43:37 UTC (rev 23902)
@@ -1,3 +1,9 @@
+krb5_c_random_os_entropy
+krb5int_crypto_init
+shsUpdate
+shsInit
+shsFinal
+krb5int_enc_aes256
 krb5_c_make_random_key
 krb5_c_encrypt_length
 krb5_process_key
@@ -13,7 +19,6 @@
 krb5_init_random_key
 krb5_c_string_to_key_with_params
 krb5_c_random_make_octets
-krb5_c_random_os_entropy
 krb5_c_decrypt
 krb5_c_crypto_length
 krb5_c_block_size

Added: branches/plugins/src/plugin_core/Makefile.in
===================================================================
--- branches/plugins/src/plugin_core/Makefile.in	                        (rev 0)
+++ branches/plugins/src/plugin_core/Makefile.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,36 @@
+mydir=plugin_core
+BUILDTOP=$(REL)..
+PROG_LIBPATH=-L$(TOPLIBD)
+PROG_RPATH=$(KRB5_LIBDIR)
+DEFS=
+
+LOCALINCLUDES = -I$(srcdir)/include/krb5  -I$(srcdir)/. -I$(srcdir)/../plugins/prng
+
+LIBBASE=plugin_core
+LIBMAJOR=0
+LIBMINOR=0
+SO_EXT=.so
+
+LIBS_UTILS = -lyaml
+
+SHLIB_DIRS=-L$(TOPLIBD)
+SHLIB_RDIRS=$(KRB5_LIBDIR)
+STOBJLISTS=OBJS.ST ../plugins/prng/OBJS.SH  
+
+SHLIB_EXPLIBS=  $(LIBS_UTILS)
+ 
+STLIBOBJS= plugin_manager.o plugin_factory.o yaml_parser.o
+
+SRCS= plugin_manager.c plugin_factory.c yaml_parser.c
+
+# all-unix:: all-libobjs
+all-unix:: all-liblinks
+install-unix:: install-libs
+clean-unix:: clean-libs clean-libobjs
+
+clean::
+	$(RM) lib$(LIBBASE)$(SO_EXT)
+
+ at libnover_frag@
+ at libobj_frag@
+

Added: branches/plugins/src/plugin_core/deps
===================================================================
--- branches/plugins/src/plugin_core/deps	                        (rev 0)
+++ branches/plugins/src/plugin_core/deps	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,7 @@
+plugin_manager.so plugin_manager.po $(OUTPRE)plugin_manager.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/plugin_core/plugin_manager.h \
+  plugin_manager.c
+plugin_factory.so plugin_factory.po $(OUTPRE)plugin_factory.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/plugin_core/plugin_factory.h \
+  $(top_srcdir)/plugin_core/plugin_manager.h \
+  plugin_factory.c

Added: branches/plugins/src/plugin_core/impl/Makefile.in
===================================================================
--- branches/plugins/src/plugin_core/impl/Makefile.in	                        (rev 0)
+++ branches/plugins/src/plugin_core/impl/Makefile.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,29 @@
+mydir=impl
+BUILDTOP=$(REL)../..
+PROG_LIBPATH=-L$(TOPLIBD)
+PROG_RPATH=$(KRB5_LIBDIR)
+DEFS=
+
+LOCALINCLUDES = -I$(srcdir)/../../include/krb5  -I$(srcdir)/. 	\
+		-I$(srcdir)/../../plugins/prng/plugin_yarrow -I$(srcdir)/../../plugins/prng 	\
+		-I$(srcdir)/..
+
+ 
+STLIBOBJS= plugin_default_factory.o plugin_default_manager.o
+
+OBJS=\
+	$(OUTPRE)plugin_default_manager.$(OBJEXT) \
+	$(OUTPRE)plugin_default_factory.$(OBJEXT) 
+
+SRCS= plugin_default_factory.c plugin_default_manager.c
+
+all-unix:: all-libobjs
+
+includes:: depend
+
+depend:: $(SRCS)
+
+clean-unix:: clean-libobjs
+
+ at libobj_frag@
+

Added: branches/plugins/src/plugin_core/impl/deps
===================================================================
--- branches/plugins/src/plugin_core/impl/deps	                        (rev 0)
+++ branches/plugins/src/plugin_core/impl/deps	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,14 @@
+plugin_default_manager.so plugin_default_manager.po $(OUTPRE)plugin_default_manager.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/plugin_core/plugin_manager.h \
+  $(top_srcdir)/plugin_core/plugin_manager.h \
+  $(top_srcdir)/plugin_core/yaml_parser.h \
+  $(top_srcdir)/plugin_core/impl/plugin_default_manager.h \
+  $(top_srcdir)/plugin_core/impl/plugin_default_factory.h \
+  plugin_default_manager.c
+plugin_default_factory.so plugin_default_factory.po $(OUTPRE)plugin_default_factory.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/plugin_core/plugin_factory.h \
+  $(top_srcdir)/plugin_core/plugin_manager.h \
+  $(top_srcdir)/plugins/prng/plugin_yarrow/plugin_prng_impl.h \
+  $(top_srcdir)/plugin_core/impl/plugin_default_manager.h \
+  $(top_srcdir)/plugin_core/impl/plugin_default_factory.h \
+  plugin_default_factory.c

Added: branches/plugins/src/plugin_core/impl/plugin_default_factory.c
===================================================================
--- branches/plugins/src/plugin_core/impl/plugin_default_factory.c	                        (rev 0)
+++ branches/plugins/src/plugin_core/impl/plugin_default_factory.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,67 @@
+/*
+ * plugin_default_factory.c
+ *
+ */
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "plugin_manager.h"
+#include "plugin_factory.h"
+#include "plugin_prng_impl.h"
+#include "plugin_default_factory.h"
+
+static plugin_factory* _default_factory_instance = NULL;
+
+static plugin_descr _table[] = {
+        {"plugin_yarrow_prng", plugin_yarrow_prng_create},
+        //{"plugin_simple_prng", plugin_simple_prng_create},
+        {"plugin_ldap_audit", NULL},
+        {NULL,NULL}
+};
+
+
+/* Factory API implementation */
+static void
+_get_factory_content (const char* container[]) {
+    plugin_descr *ptr = NULL;
+    int i = 0;
+    for( ptr = _table; ptr->plugin_name != NULL; ptr++,i++) {
+        container[i] = ptr->plugin_name;
+    }
+}
+
+static plhandle
+_create_api (const char* plugin_name)
+{
+    plhandle handle;
+    plugin_descr *ptr = NULL;
+
+    handle.api = NULL;
+    for( ptr = _table; ptr->plugin_name != NULL; ptr++) {
+        if (strcmp(ptr->plugin_name, plugin_name) == 0) {
+            handle = ptr->plugin_creator();
+            break;
+        }
+    }
+    return handle;
+}
+
+
+FactoryHandle
+plugin_default_factory_get_instance()
+{
+    plugin_factory* instance = _default_factory_instance;
+    FactoryHandle handle;
+
+    if(_default_factory_instance == NULL) {
+        instance = (plugin_factory*) malloc(sizeof(plugin_factory));
+        memset(instance, 0, sizeof(plugin_factory));
+        instance->get_factory_content = _get_factory_content;
+        instance->create_api = _create_api;
+        _default_factory_instance = instance;
+    }
+    handle.api = instance;
+    return (handle);
+}
+

Added: branches/plugins/src/plugin_core/impl/plugin_default_factory.h
===================================================================
--- branches/plugins/src/plugin_core/impl/plugin_default_factory.h	                        (rev 0)
+++ branches/plugins/src/plugin_core/impl/plugin_default_factory.h	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,14 @@
+/*
+ * plugin_default_factory.h
+ *
+ */
+
+#ifndef SIMPLE_PLUGIN_FACTORY_H_
+#define SIMPLE_PLUGIN_FACTORY_H_
+
+#include <plugin_factory.h>
+
+FactoryHandle plugin_default_factory_get_instance(void);
+
+
+#endif /* SIMPLE_PLUGIN_FACTORY_H_ */

Added: branches/plugins/src/plugin_core/impl/plugin_default_manager.c
===================================================================
--- branches/plugins/src/plugin_core/impl/plugin_default_manager.c	                        (rev 0)
+++ branches/plugins/src/plugin_core/impl/plugin_default_manager.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,255 @@
+/*
+ * plugin_default_manager.c
+ *
+ */
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <plugin_manager.h>
+#include <plugin_factory.h>
+#include "plugin_default_manager.h"
+#include "plugin_default_factory.h"
+#include "yaml_parser.h"
+
+
+static plugin_manager* _instance = NULL;
+//static plhandle* _prng_instance = NULL;
+
+static plugin_factory_descr _table[] = {
+        {"plugin_default_factory", plugin_default_factory_get_instance},
+        {NULL, NULL}
+};
+
+static FactoryHandle
+_load_factory (const char* factory_name, const char* factory_type)
+{
+    FactoryHandle handle;
+    plugin_factory_descr *ptr = NULL;
+
+    handle.api = NULL;
+    for( ptr = _table; ptr->factory_name != NULL; ptr++) {
+        if (strcmp(ptr->factory_name, factory_name) == 0) {
+            handle = ptr->factory_creator();
+            break;
+        }
+    }
+    return handle;
+}
+
+static registry_data*
+_create_registry()
+{
+    registry_data* registry = (registry_data*) malloc(sizeof(registry_data));
+    memset(registry, 0, sizeof(registry_data));
+
+    return registry;
+}
+
+static void
+_extend_registry (registry_data* data, int ext_n)
+{
+    if(data->registry_max_size == 0) {
+        data->table = NULL;
+    }
+    data->table = (reg_entry*) realloc(data->table, ext_n * sizeof(reg_entry));
+    memset(data->table + data->registry_max_size, 0, ext_n * sizeof(reg_entry));
+    data->registry_max_size += ext_n;
+}
+
+static reg_entry*
+_search_registry (registry_data* data, const char* api_name)
+{
+    int i = 0;
+    reg_entry* ptr = data->table;
+
+    for(i = 0; i < data->registry_size; i++,ptr++) {
+        if(strcmp(api_name, ptr->api_name) == 0) {
+            return ptr;
+        }
+    }
+    return NULL;
+}
+
+static plhandle
+_create_api(const char* plugin_name, const char* factory_name,
+            const char* factory_type, config_node* properties)
+{
+    plhandle p_handle;
+    FactoryHandle f_handle = _load_factory(factory_name, factory_type);
+    p_handle = create_api(f_handle, plugin_name);
+
+    return(p_handle);
+}
+
+static int
+_register_api(registry_data* data, const char* api_name,
+              const char* plugin_type, plhandle handle)
+{
+    const int extension_size = 32;
+    reg_entry* entry = NULL;
+    plhandle* next;
+    int ret = 0;
+
+    if(data->registry_size == data->registry_max_size) {
+        _extend_registry(data, extension_size);
+    }
+    entry = _search_registry(data, api_name);
+    if(entry == NULL) {
+        entry = data->table + data->registry_size;
+        data->registry_size++;
+    }
+    if(entry->size && strcmp(plugin_type, "service") == 0) {
+        //printf("%s is already registered, only one plugin is allowed per service\n", api_name);
+        ret = 0;
+    } else {
+        strcpy(entry->api_name, api_name);
+        next = (plhandle*) malloc(sizeof(plhandle));
+        memset(next, 0, sizeof(plhandle));
+        next->api = handle.api;
+        if(entry->first == NULL) {
+            entry->first = next;
+            entry->last = next;
+        } else {
+            entry->last->next = next;
+            entry->last = next;
+        }
+        entry->size++;
+        ret = 1;
+    }
+    return ret;
+}
+
+static void
+_configure_plugin(manager_data* mdata, config_node* plugin_node)
+{
+    config_node* p = NULL;
+    config_node* properties = NULL;
+    const char* plugin_api = NULL;
+    const char* factory_name = NULL;
+    const char* factory_type = NULL;
+    const char* plugin_name = NULL;
+    const char* plugin_type = NULL;
+    plhandle handle;
+
+    for (p = plugin_node->node_value.seq_value.start; p != NULL; p = p->next) {
+        if(strcmp(p->node_name, "api") == 0) {
+            plugin_api = p->node_value.str_value;
+        } else if(strcmp(p->node_name, "type") == 0) {
+            plugin_type = p->node_value.str_value;
+        } else if(strcmp(p->node_name, "constructor") == 0) {
+            config_node* q = NULL;
+            for(q = p->node_value.seq_value.start; q != NULL; q = q->next) {
+                if(strcmp(q->node_name, "factory_name") == 0) {
+                    factory_name = q->node_value.str_value;
+                } else if(strcmp(q->node_name, "factory_type") == 0) {
+                    factory_type = q->node_value.str_value;
+                } else if(strcmp(q->node_name, "plugin_name") == 0) {
+                    plugin_name = q->node_value.str_value;
+                }
+            }
+        } else if(strcmp(p->node_name, "properties") == 0) {
+            properties = p;
+        }
+    }
+    /*printf("**Start**\n");
+    printf("api=%s\n", plugin_api);
+    printf("factory=%s\n", factory_name);
+    printf("factory_type=%s\n", factory_type);
+    printf("plugin_name=%s\n", plugin_name);
+    printf("plugin_type=%s\n", plugin_type);
+    printf("**End**\n");
+*/
+    handle = _create_api(plugin_name, factory_name, factory_type, properties);
+    if(handle.api != NULL) {
+        if(!(_register_api(mdata->registry,plugin_api, plugin_type, handle))) {
+         /*   printf("Failed to register %s for %s(factory=%s,plugin_type=%s)\n",
+                    plugin_name, plugin_api, factory_name, plugin_type);
+           */
+              exit(1);
+        }
+    } else {
+        /*printf("Failed to configure plugin: api=%s, plugin_name=%s,factory=%s\n",
+                plugin_api, plugin_name, factory_name);
+*/
+    }
+    return;
+}
+
+/* Plugin API implementation */
+static void
+_configure(void* data, const char* path)
+{
+    manager_data* mdata = (manager_data*) data;
+    config_node* stream = NULL;
+    config_node* p = NULL;
+    stream = parse_file(path);
+
+    for(p = stream->node_value.seq_value.start; p != NULL; p = p->next) {
+        config_node* q = NULL;
+        for(q = p->node_value.seq_value.start; q != NULL; q = q->next) {
+            if(strcmp(q->node_tag,"!Plugin") == 0) {
+                _configure_plugin(mdata, q);
+            } else {
+                printf("Failed to find plugin configuration\n");
+            }
+        }
+    }
+}
+
+static void
+_start(void* data)
+{
+    return;
+}
+
+static void
+_stop(void* data)
+{
+    return;
+}
+
+static plhandle
+_getService(void* data, const char* service_name)
+{
+    plhandle handle;
+    manager_data* mdata = (manager_data*) data;
+    reg_entry* entry = _search_registry(mdata->registry, service_name);
+
+    memset(&handle, 0, sizeof handle);
+    if(entry) {
+        handle = *(entry->first);
+    } else {
+        printf("service %s is not available\n", service_name);
+    }
+
+    return handle;
+}
+
+static manager_data*
+_init_data()
+{
+    manager_data* data = (manager_data*) malloc(sizeof(manager_data));
+    memset(data, 0, sizeof(manager_data));
+    data->registry = _create_registry();
+
+    return data;
+}
+
+plugin_manager*
+plugin_default_manager_get_instance()
+{
+    plugin_manager* instance = _instance;
+
+    if(_instance == NULL) {
+        instance = (plugin_manager*) malloc(sizeof(plugin_manager));
+        memset(instance, 0, sizeof(plugin_manager));
+        instance->data = _init_data();
+        instance->configure = _configure;
+        instance->start = _start;
+        instance->stop = _stop;
+        instance->getService = _getService;
+        _instance = instance;
+    }
+    return (instance);
+}
+

Added: branches/plugins/src/plugin_core/impl/plugin_default_manager.h
===================================================================
--- branches/plugins/src/plugin_core/impl/plugin_default_manager.h	                        (rev 0)
+++ branches/plugins/src/plugin_core/impl/plugin_default_manager.h	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,30 @@
+/*
+ * plugin_default_manager.h
+ *
+ */
+
+#ifndef PLUGIN_DEFAULT_MANAGER_H_
+#define PLUGIN_DEFAULT_MANAGER_H_
+
+#include <plugin_manager.h>
+
+typedef struct {
+    char api_name[512];
+    plhandle* first;
+    plhandle* last;
+    int size;
+} reg_entry;
+
+typedef struct {
+    reg_entry* table;
+    long registry_size;
+    long registry_max_size;
+} registry_data;
+
+typedef struct {
+    registry_data* registry;
+} manager_data;
+
+plugin_manager* plugin_default_manager_get_instance(void);
+
+#endif /* PLUGIN_DEFAULT_MANAGER_H_ */

Added: branches/plugins/src/plugin_core/impl/plugin_impl.exports
===================================================================
--- branches/plugins/src/plugin_core/impl/plugin_impl.exports	                        (rev 0)
+++ branches/plugins/src/plugin_core/impl/plugin_impl.exports	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,2 @@
+plugin_default_factory_get_instance
+plugin_default_manager_get_instance

Added: branches/plugins/src/plugin_core/plugin_core.exports
===================================================================
--- branches/plugins/src/plugin_core/plugin_core.exports	                        (rev 0)
+++ branches/plugins/src/plugin_core/plugin_core.exports	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,8 @@
+get_factory_content
+plugin_manager_configure
+plugin_manager_get_service
+set_plugin_manager_instance
+plugin_manager_start
+plugin_manager_stop
+create_api
+parse_file

Added: branches/plugins/src/plugin_core/plugin_factory.c
===================================================================
--- branches/plugins/src/plugin_core/plugin_factory.c	                        (rev 0)
+++ branches/plugins/src/plugin_core/plugin_factory.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,21 @@
+/*
+ * plugin_factory.c
+ *
+ */
+
+#include <string.h>
+#include "plugin_factory.h"
+
+void
+get_factory_content (FactoryHandle handle, const char* container[])
+{
+	plugin_factory* factory = (plugin_factory*) handle.api;
+	factory->get_factory_content(container);
+}
+
+plhandle
+create_api (FactoryHandle handle, const char* plugin_name)
+{
+	plugin_factory* factory = (plugin_factory*) handle.api;
+	return factory->create_api(plugin_name);
+}

Added: branches/plugins/src/plugin_core/plugin_factory.h
===================================================================
--- branches/plugins/src/plugin_core/plugin_factory.h	                        (rev 0)
+++ branches/plugins/src/plugin_core/plugin_factory.h	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,34 @@
+/*
+ * plugin_factory.h
+ *
+ */
+#ifndef PLUGIN_FACTORY_H_
+#define PLUGIN_FACTORY_H_
+
+#include "plugin_manager.h"
+
+/* Plugin factory API */
+typedef struct {
+	void *api;
+} FactoryHandle;
+
+typedef struct {
+	const char* factory_name;
+	FactoryHandle (*factory_creator)();
+} plugin_factory_descr;
+
+typedef struct {
+	const char* plugin_name;
+	plhandle (*plugin_creator)();
+} plugin_descr;
+
+typedef struct {
+	void (*get_factory_content)(const char* []);
+	plhandle (*create_api)(const char*);
+} plugin_factory;
+
+/* Utility functions */
+void get_factory_content(FactoryHandle handle, const char* container[]);
+plhandle create_api(FactoryHandle handle, const char* plugin_name);
+
+#endif /* PLUGIN_FACTORY_H_ */

Added: branches/plugins/src/plugin_core/plugin_manager.c
===================================================================
--- branches/plugins/src/plugin_core/plugin_manager.c	                        (rev 0)
+++ branches/plugins/src/plugin_core/plugin_manager.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,51 @@
+/*
+ * plugin_manager.c
+ *
+ */
+#include "plugin_manager.h"
+#include "string.h"
+
+
+static plugin_manager* _instance = NULL;
+
+void
+set_plugin_manager_instance(plugin_manager* manager) {
+	_instance = manager;
+}
+
+void
+plugin_manager_configure(const char* path)
+{
+	if(_instance != NULL) {
+		_instance->configure(_instance->data, path);
+	}
+}
+
+void plugin_manager_start()
+{
+	if(_instance != NULL) {
+		_instance->start(_instance->data);
+	}
+}
+
+void plugin_manager_stop()
+{
+	if(_instance != NULL) {
+		_instance->stop(_instance->data);
+	}
+}
+
+plhandle
+plugin_manager_get_service(const char* service_name)
+{
+	plhandle handle;
+	if(_instance != NULL) {
+		handle = _instance->getService(_instance->data, service_name);
+	} else {
+		handle.api = NULL;
+	}
+	return handle;
+}
+
+
+

Added: branches/plugins/src/plugin_core/plugin_manager.h
===================================================================
--- branches/plugins/src/plugin_core/plugin_manager.h	                        (rev 0)
+++ branches/plugins/src/plugin_core/plugin_manager.h	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,28 @@
+/*
+ * plugin_manager.h
+ *
+ */
+
+#ifndef PLUGIN_MANAGER_H_
+#define PLUGIN_MANAGER_H_
+
+#include <k5-int.h>
+
+
+typedef struct {
+	void* data;
+	void (*configure)(void* data, const char*);
+	void (*start)(void* data);
+	void (*stop)(void* data);
+	plhandle (*getService)(void* data, const char*);
+} plugin_manager;
+
+void set_plugin_manager_instance(plugin_manager*);
+
+/* Utility functions */
+void plugin_manager_configure(const char*);
+void plugin_manager_start();
+void plugin_manager_stop();
+plhandle plugin_manager_get_service(const char*);
+
+#endif /* PLUGIN_MANAGER_H_ */

Added: branches/plugins/src/plugin_core/yaml_parser.c
===================================================================
--- branches/plugins/src/plugin_core/yaml_parser.c	                        (rev 0)
+++ branches/plugins/src/plugin_core/yaml_parser.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,199 @@
+/*
+ * yaml_parser.c
+ *
+ */
+#include <assert.h>
+#include <stdio.h>
+#include <string.h>
+#include <yaml.h>
+#include "yaml_parser.h"
+
+static config_node*
+_create_new_node(const char* name, const char* type,
+                 const char* tag, config_node* parent)
+ {
+    config_node* anode = (config_node*) malloc(sizeof(config_node));
+    memset(anode, 0, sizeof(config_node));
+    if(name != NULL && strlen(name)) {
+        strcpy(anode->node_name, name);
+    }
+    if(type != NULL && strlen(type)) {
+        strcpy(anode->node_type, type);
+    }
+    if(tag != NULL && strlen(tag)) {
+        strcpy(anode->node_tag, tag);
+    }
+
+    anode->parent = parent;
+
+    return anode;
+ }
+
+static void
+_append_node(config_node* anode, config_node* achild)
+ {
+    if(anode->node_value.seq_value.start == NULL) {
+        anode->node_value.seq_value.start = achild;
+        anode->node_value.seq_value.end = achild;
+    } else {
+        anode->node_value.seq_value.end->next = achild;
+        anode->node_value.seq_value.end = achild;
+    }
+ }
+
+void
+walk (config_node* root)
+{
+    config_node* anode = root;
+    config_node* start = anode->node_value.seq_value.start;
+    config_node* ptr = NULL;
+    if(strcmp(root->node_type, "SCALAR") == 0) {
+        //printf("%s: %s=%s\n", root->node_type,
+          //     root->node_name, root->node_value.str_value);
+    } else {
+     //   printf("%s: %s: %s \n", root->node_name, root->node_type, root->node_tag);
+        for(ptr = start; ptr != NULL; ptr = ptr->next) {
+            walk(ptr);
+        }
+    }
+}
+
+static void
+_process_event(yaml_parser_t* parser, yaml_event_type_t parent_event_type,
+              config_node* parent_node)
+{
+    config_node* anode = NULL;
+    char* attribute = NULL;
+    yaml_event_t event;
+    int done = 0;
+    int error = 0;
+
+    while (!done) {
+        /* Get the next event. */
+        if (!yaml_parser_parse(parser, &event)) {
+            error = 1;
+            break;
+        }
+        switch(parent_event_type) {
+            case YAML_NO_EVENT:
+                if(event.type == YAML_STREAM_START_EVENT) {
+                    _process_event(parser, event.type, parent_node);
+                    done = 1;
+                } else {
+                    //printf("Error: unexpected event %d\n", event.type);
+                }
+                break;
+            case YAML_STREAM_START_EVENT:
+                if(event.type == YAML_DOCUMENT_START_EVENT) {
+                    anode = _create_new_node("document", "DOC",
+                                             (char*)event.data.scalar.tag, parent_node);
+                    _append_node(parent_node, anode);
+                    _process_event(parser, event.type, anode);
+                }  else if(event.type == YAML_STREAM_END_EVENT) {
+                    done = 1;
+                } else {
+                    //printf("Error: unexpected event %d\n", event.type);
+                }
+                break;
+            case YAML_DOCUMENT_START_EVENT:
+                if(event.type == YAML_SCALAR_EVENT) {
+                    strcpy(parent_node->node_type, "SCALAR");
+                    parent_node->node_value.str_value = strdup((char*)event.data.scalar.value);
+                } else if(event.type == YAML_SEQUENCE_START_EVENT) {
+                    strcpy(parent_node->node_type, "SEQ");
+                    _process_event(parser, event.type, parent_node);
+                } else if(event.type == YAML_MAPPING_START_EVENT) {
+                    strcpy(parent_node->node_type, "MAP");
+                    _process_event(parser, event.type, parent_node);
+                }  else if(event.type == YAML_DOCUMENT_END_EVENT) {
+                    done = 1;
+                } else {
+                    // printf("Error: unexpected event %d\n", event.type);
+                }
+            break;
+            case YAML_SEQUENCE_START_EVENT:
+                if(event.type == YAML_SCALAR_EVENT) {
+                    anode = _create_new_node("", "SCALAR",
+                                             (char*)event.data.scalar.tag, parent_node);
+                    anode->node_value.str_value = strdup((char*) event.data.scalar.value);
+                    _append_node(parent_node, anode);
+                } else if(event.type == YAML_SEQUENCE_START_EVENT) {
+                    anode = _create_new_node("", "SEQ",
+                                             (char*)event.data.scalar.tag, parent_node);
+                    _append_node(parent_node, anode);
+                    _process_event(parser, event.type, anode);
+                } else if(event.type == YAML_MAPPING_START_EVENT) {
+                    anode = _create_new_node("", "MAP",
+                                             (char*)event.data.scalar.tag, parent_node);
+                    _append_node(parent_node, anode);
+                    _process_event(parser, event.type, anode);
+                }  else if(event.type == YAML_SEQUENCE_END_EVENT) {
+                    done = 1;
+                } else {
+                    //printf("Error: unexpected event %d\n", event.type);
+                }
+            break;
+            case YAML_MAPPING_START_EVENT:
+                if(event.type == YAML_SCALAR_EVENT) {
+                    if(attribute) {
+                        anode = _create_new_node(attribute, "SCALAR",
+                                                 (char*)event.data.scalar.tag, parent_node);
+                        anode->node_value.str_value = strdup((char*)event.data.scalar.value);
+                        _append_node(parent_node, anode);
+                        free(attribute);
+                        attribute = NULL;
+                    } else {
+                        attribute = strdup((char*)event.data.scalar.value);
+                    }
+                } else if(event.type == YAML_SEQUENCE_START_EVENT) {
+                    assert(attribute);
+                    anode = _create_new_node(attribute, "SEQ",
+                                             (char*)event.data.scalar.tag, parent_node);
+                    _append_node(parent_node, anode);
+                    free(attribute);
+                    attribute = NULL;
+                    _process_event(parser, event.type, anode);
+                } else if(event.type == YAML_MAPPING_START_EVENT) {
+                    assert(attribute);
+                    anode = _create_new_node(attribute, "MAP",
+                                             (char*)event.data.scalar.tag, parent_node);
+                    _append_node(parent_node, anode);
+                    free(attribute);
+                    attribute = NULL;
+                    _process_event(parser, event.type, anode);
+                } else if(event.type == YAML_MAPPING_END_EVENT) {
+                    done = 1;
+                } else {
+                    //printf("Error: unexpected event %d\n", event.type);
+                }
+            break;
+            default:
+            break;
+                //printf("Unexpected event %d\n", event.type);
+        }
+        /* The application is responsible for destroying the event object. */
+        yaml_event_delete(&event);
+    }
+}
+
+config_node*
+parse_file(const char* path)
+{
+    yaml_parser_t parser;
+    FILE *infile;
+    config_node* stream_node = _create_new_node("all", "STREAM", "", NULL);
+
+    /* Create the Parser object. */
+    yaml_parser_initialize(&parser);
+    /* Set a file input. */
+    infile = fopen(path, "rb");
+    yaml_parser_set_input_file(&parser, infile);
+    /* Read the event sequence. */
+    _process_event(&parser, YAML_NO_EVENT, stream_node);
+    yaml_parser_delete(&parser);
+    fclose(infile);
+
+    return(stream_node);
+
+}
+

Added: branches/plugins/src/plugin_core/yaml_parser.h
===================================================================
--- branches/plugins/src/plugin_core/yaml_parser.h	                        (rev 0)
+++ branches/plugins/src/plugin_core/yaml_parser.h	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,35 @@
+/*
+ * yaml_parser.h
+ *
+ */
+
+#ifndef YAML_PARSER_H_
+#define YAML_PARSER_H_
+
+#include <yaml.h>
+
+typedef struct _node* p_node;
+
+typedef struct _sequence {
+	p_node start;
+	p_node end;
+} node_sequence;
+
+typedef struct _node {
+	char node_name[1024];
+	char node_type[16];
+	char node_tag[256];
+	union {
+		char* str_value;
+		node_sequence seq_value;
+	} node_value;
+	p_node parent;
+	p_node next;
+} config_node;
+
+config_node* parse_file(const char* path);
+
+void walk (config_node* root);
+
+#endif /* YAML_PARSER_H_ */
+

Added: branches/plugins/src/plugins/prng/Makefile.in
===================================================================
--- branches/plugins/src/plugins/prng/Makefile.in	                        (rev 0)
+++ branches/plugins/src/plugins/prng/Makefile.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,26 @@
+mydir=plugins/prng
+BUILDTOP=$(REL)../..
+KRB5_RUN_ENV = @KRB5_RUN_ENV@
+KRB5_CONFIG_SETUP =
+PROG_LIBPATH=-L$(TOPLIBD)
+PROG_RPATH=$(KRB5_LIBDIR)
+MODULE_INSTALL_DIR = 
+DEFS=@DEFS@
+
+LOCALINCLUDES = -I../../include/krb5 -I. -I../../plugin_core
+
+STLIBOBJS=  plugin_prng.o  
+OBJS= $(OUTPRE)plugin_prng.$(OBJEXT)
+SRCS=  plugin_prng.c  
+
+#all-unix:: all-liblinks
+all-unix:: all-libobjs
+
+includes:: depend
+
+depend:: $(SRCS)
+
+clean-unix::  clean-libobjs
+
+ at libobj_frag@
+

Added: branches/plugins/src/plugins/prng/deps
===================================================================
--- branches/plugins/src/plugins/prng/deps	                        (rev 0)
+++ branches/plugins/src/plugins/prng/deps	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,13 @@
+# 
+# Generated makefile dependencies follow.
+#
+plugin_prng.so plugin_prng.po $(OUTPRE)plugin_prng.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/plugins/prng/plugin_prng.h \
+  $(top_srcdir)/plugin_core/plugin_manager.h \
+  $(top_srcdir)/plugin_core/plugin_factory.h \
+  plugin_prng.c
+plugin_prng_impl.so plugin_prng_impl.po $(OUTPRE)plugin_prng_impl.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/plugins/prng/plugin_prng_impl.h \
+  $(top_srcdir)/plugin_core/plugin_manager.h \
+  $(top_srcdir)/plugin_core/plugin_factory.h \
+  plugin_prng_impl.c

Added: branches/plugins/src/plugins/prng/plugin_prng.c
===================================================================
--- branches/plugins/src/plugins/prng/plugin_prng.c	                        (rev 0)
+++ branches/plugins/src/plugins/prng/plugin_prng.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,47 @@
+/*
+ * plugin_prng.c
+ *
+ */
+#include <plugin_manager.h>
+#include "plugin_prng.h"
+
+krb5_error_code
+plugin_prng_seed(plhandle handle, krb5_context context, unsigned int randsource,
+                          const krb5_data *data)
+{
+    plugin_prng* api = (plugin_prng*) handle.api;
+    api->prng_seed(context, randsource, data);
+    return 0;
+}
+
+krb5_error_code
+plugin_prng_os_seed(plhandle handle, krb5_context context, int strong, int *success)
+{
+    plugin_prng* api = (plugin_prng*) handle.api;
+    api->prng_os_seed(context, strong, success);
+    return 0;
+}
+
+krb5_error_code
+plugin_prng_rand(plhandle handle, krb5_context context, krb5_data *data)
+{
+    plugin_prng* api = (plugin_prng*) handle.api;
+    api->prng_rand(context, data);
+    return 0;
+}
+
+krb5_error_code
+plugin_prng_init(plhandle handle)
+{
+    plugin_prng* api = (plugin_prng*) handle.api;
+    api->prng_init();
+    return 0;
+}
+
+void
+plugin_prng_cleanup(plhandle handle)
+{
+    plugin_prng* api = (plugin_prng*) handle.api;
+    api->prng_cleanup();
+    return 0;
+}

Added: branches/plugins/src/plugins/prng/plugin_prng.h
===================================================================
--- branches/plugins/src/plugins/prng/plugin_prng.h	                        (rev 0)
+++ branches/plugins/src/plugins/prng/plugin_prng.h	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,31 @@
+/*
+ * plugin_prng.h
+ *
+ */
+
+#ifndef PLUGIN_PRNG_H_
+#define PLUGIN_PRNG_H_
+
+#include <plugin_manager.h>
+#include <k5-int.h>
+
+/* PRNG API */
+typedef struct {
+	int version;
+	krb5_error_code (*prng_seed)(krb5_context, unsigned int, const krb5_data*);
+	krb5_error_code (*prng_os_seed)(krb5_context, int, int*);
+	krb5_error_code (*prng_rand)(krb5_context, krb5_data*);
+	krb5_error_code (*prng_init)(void);
+	void (*prng_cleanup)(void);
+} plugin_prng;
+
+/* Utility functions */
+krb5_error_code plugin_prng_seed(plhandle handle, krb5_context context, unsigned int randsource,
+                          const krb5_data *data); 
+krb5_error_code plugin_prng_os_seed(plhandle handle, krb5_context context, int strong, int *success);
+krb5_error_code plugin_prng_rand(plhandle handle, krb5_context context, krb5_data *data);
+
+krb5_error_code plugin_prng_init(plhandle handle);
+void plugin_prng_cleanup(plhandle handle);
+
+#endif /* PLUGIN_PRNG_H_ */

Added: branches/plugins/src/plugins/prng/plugin_prng_os/Makefile.in
===================================================================
--- branches/plugins/src/plugins/prng/plugin_prng_os/Makefile.in	                        (rev 0)
+++ branches/plugins/src/plugins/prng/plugin_prng_os/Makefile.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,36 @@
+mydir=plugins/prng/plugin_prng_os
+BUILDTOP=$(REL)../../..
+KRB5_RUN_ENV = @KRB5_RUN_ENV@
+KRB5_CONFIG_SETUP =
+PROG_LIBPATH=-L$(TOPLIBD)
+PROG_RPATH=$(KRB5_LIBDIR)
+MODULE_INSTALL_DIR = 
+DEFS=@DEFS@
+
+LOCALINCLUDES = -I../../../include/krb5 -I. -I../../../plugin_core -I..
+
+LIBBASE=plugin_prng_os
+LIBMAJOR=0
+LIBMINOR=0
+
+SO_EXT=.so
+
+SHLIB_DIRS=-L$(TOPLIBD)
+SHLIB_RDIRS=$(KRB5_LIBDIR)
+STOBJLISTS=OBJS.ST
+
+STLIBOBJS=  plugin_prng_impl.o  
+
+SRCS=  plugin_prng_impl.c
+
+all-unix:: all-liblinks
+#all-unix:: all-libobjs
+install-unix:: install-libs
+clean-unix:: clean-libs clean-libobjs
+
+clean::
+	$(RM) lib$(LIBBASE)$(SO_EXT)
+
+ at libnover_frag@
+ at libobj_frag@
+

Added: branches/plugins/src/plugins/prng/plugin_prng_os/deps
===================================================================
--- branches/plugins/src/plugins/prng/plugin_prng_os/deps	                        (rev 0)
+++ branches/plugins/src/plugins/prng/plugin_prng_os/deps	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,5 @@
+plugin_prng_impl.so plugin_prng_impl.po $(OUTPRE)plugin_prng_impl.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/plugins/prng/os/plugin_prng_impl.h \
+  $(top_srcdir)/plugin_core/plugin_manager.h \
+  $(top_srcdir)/plugin_core/plugin_factory.h \
+  plugin_prng_impl.c

Added: branches/plugins/src/plugins/prng/plugin_prng_os/os.exports
===================================================================
--- branches/plugins/src/plugins/prng/plugin_prng_os/os.exports	                        (rev 0)
+++ branches/plugins/src/plugins/prng/plugin_prng_os/os.exports	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1 @@
+plugin_simple_prng_create

Added: branches/plugins/src/plugins/prng/plugin_prng_os/plugin_prng_impl.c
===================================================================
--- branches/plugins/src/plugins/prng/plugin_prng_os/plugin_prng_impl.c	                        (rev 0)
+++ branches/plugins/src/plugins/prng/plugin_prng_os/plugin_prng_impl.c	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,67 @@
+/*
+ * plugins.c
+ *
+ */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include "plugin_prng.h"
+
+static krb5_error_code
+_plugin_prng_os_seed(krb5_context context, int strong, int *success)
+{
+    return 0;
+}
+static krb5_error_code
+_plugin_prng_seed(krb5_context context, unsigned int randsource,
+                          const krb5_data *data)
+{
+    long seed = (long)data->data;
+	printf("seeding prng...\n");
+	srand(seed);
+    return 0;
+}
+
+static krb5_error_code
+_plugin_prng_rand(krb5_context context, krb5_data *data)
+{
+	int number = rand();
+	printf("generating random number...\n");
+        memcpy(data->data, &number, data->length);
+	return 0;
+}
+
+static void
+_plugin_prng_cleanup(plugin_prng* api)
+{
+    return;
+/*	if (api != NULL) {
+		free(api);
+	}
+*/
+}
+
+static krb5_error_code
+_plugin_prng_init(void)
+{
+     return 0;
+}
+
+
+plhandle 
+plugin_simple_prng_create()
+{
+	plhandle handle;
+	plugin_prng* api = malloc(sizeof(plugin_prng));
+
+	memset(api, 0, sizeof(plugin_prng));
+	api->version = 0;
+	api->prng_rand = _plugin_prng_rand;
+	api->prng_seed = _plugin_prng_seed;
+        api->prng_os_seed = _plugin_prng_os_seed;
+        api->prng_init = _plugin_prng_init;
+        api->prng_cleanup = _plugin_prng_cleanup;
+	handle.api = api;
+
+	return handle;
+}

Added: branches/plugins/src/plugins/prng/plugin_prng_os/plugin_prng_impl.h
===================================================================
--- branches/plugins/src/plugins/prng/plugin_prng_os/plugin_prng_impl.h	                        (rev 0)
+++ branches/plugins/src/plugins/prng/plugin_prng_os/plugin_prng_impl.h	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,14 @@
+/*
+ * plugin_prng_impl.h
+ *
+ */
+
+#ifndef PLUGIN_PRNG_IMPL_H_
+#define PLUGIN_PRNG_IMPL_H_
+
+#include <plugin_manager.h>
+#include <plugin_prng.h>
+
+plhandle plugin_simple_prng_create();
+
+#endif /* PLUGIN_PRNG_IMPL_H_ */


Added: svn:mergeinfo
   + 

Modified: branches/plugins/src/plugins/prng/plugin_yarrow/Makefile.in
===================================================================
--- branches/plugins/src/lib/crypto/krb/yarrow/Makefile.in	2010-04-14 14:01:05 UTC (rev 23899)
+++ branches/plugins/src/plugins/prng/plugin_yarrow/Makefile.in	2010-04-14 18:43:37 UTC (rev 23902)
@@ -1,38 +1,34 @@
-mydir=lib/crypto/krb/yarrow
-BUILDTOP=$(REL)..$(S)..$(S)..$(S)..
-LOCALINCLUDES = -I$(srcdir)/.. \
-		-I$(srcdir)/../../@CRYPTO_IMPL@		\
-		-I$(srcdir)/../../@CRYPTO_IMPL@/sha1 	\
-		-I$(srcdir)/../../@CRYPTO_IMPL@/enc_provider
+mydir=plugins/prng/plugin_yarrow
+BUILDTOP=$(REL)../../..
+PROG_LIBPATH=-L$(TOPLIBD)
+PROG_RPATH=$(KRB5_LIBDIR)
 DEFS=
 
-##DOS##BUILDTOP = ..\..\..\..
-##DOS##PREFIXDIR=yarrow
-##DOS##OBJFILE=..\$(OUTPRE)yarrow.lst
+LOCALINCLUDES = -I../../../include/krb5 -I. -I../../../plugin_core -I..  -I$(srcdir)/.. \
+		-I$(srcdir)/../../../lib/crypto/@CRYPTO_IMPL@         \
+		-I$(srcdir)/../../../lib/crypto/@CRYPTO_IMPL@/sha1    \
+		-I$(srcdir)/../../../lib/crypto/@CRYPTO_IMPL@/enc_provider
 
-PROG_LIBPATH=-L$(TOPLIBD)
-PROG_RPATH=$(KRB5_LIBDIR)
 
+
 STLIBOBJS=\
 	yarrow.o \
-	ycipher.o
+	ycipher.o \
+	plugin_prng_impl.o
+
 OBJS=\
 	$(OUTPRE)yarrow.$(OBJEXT) \
-	$(OUTPRE)ycipher.$(OBJEXT)
+	$(OUTPRE)ycipher.$(OBJEXT) \
+	$(OUTPRE)plugin_prng_impl.$(OBJEXT)
 
 SRCS=\
 	$(srcdir)/yarrow.c \
-	$(srcdir)/ycipher.c 
+	$(srcdir)/ycipher.c \
+	$(srcdir)/plugin_prng_impl.c
 
-##DOS##LIBOBJS = $(OBJS)
-
 all-unix:: all-libobjs
 
-includes:: depend
-
 depend:: $(SRCS)
-
 clean-unix:: clean-libobjs
 
 @libobj_frag@
-

Modified: branches/plugins/src/plugins/prng/plugin_yarrow/deps
===================================================================
--- branches/plugins/src/lib/crypto/krb/yarrow/deps	2010-04-14 14:01:05 UTC (rev 23899)
+++ branches/plugins/src/plugins/prng/plugin_yarrow/deps	2010-04-14 18:43:37 UTC (rev 23902)
@@ -3,8 +3,8 @@
 #
 yarrow.so yarrow.po $(OUTPRE)yarrow.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
   $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
-  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../../builtin/sha1/shs.h \
-  $(srcdir)/../../builtin/yhash.h $(top_srcdir)/include/k5-buf.h \
+  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../../../lib/crypto/builtin/sha1/shs.h \
+  $(srcdir)/../../../lib/crypto/builtin/yhash.h $(top_srcdir)/include/k5-buf.h \
   $(top_srcdir)/include/k5-err.h $(top_srcdir)/include/k5-gmt_mktime.h \
   $(top_srcdir)/include/k5-int-pkinit.h $(top_srcdir)/include/k5-int.h \
   $(top_srcdir)/include/k5-platform.h $(top_srcdir)/include/k5-plugin.h \
@@ -15,8 +15,8 @@
   ycipher.h yexcep.h ylock.h ystate.h ytypes.h
 ycipher.so ycipher.po $(OUTPRE)ycipher.$(OBJEXT): $(BUILDTOP)/include/autoconf.h \
   $(BUILDTOP)/include/krb5/krb5.h $(BUILDTOP)/include/osconf.h \
-  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../../builtin/enc_provider/enc_provider.h \
-  $(srcdir)/../../builtin/sha1/shs.h $(srcdir)/../../builtin/yhash.h \
+  $(BUILDTOP)/include/profile.h $(COM_ERR_DEPS) $(srcdir)/../../../lib/crypto/builtin/enc_provider/enc_provider.h \
+  $(srcdir)/../../../lib/crypto/builtin/sha1/shs.h $(srcdir)/../../../lib/crypto/builtin/yhash.h \
   $(top_srcdir)/include/k5-buf.h $(top_srcdir)/include/k5-err.h \
   $(top_srcdir)/include/k5-gmt_mktime.h $(top_srcdir)/include/k5-int-pkinit.h \
   $(top_srcdir)/include/k5-int.h $(top_srcdir)/include/k5-platform.h \
@@ -25,3 +25,9 @@
   $(top_srcdir)/include/krb5/locate_plugin.h $(top_srcdir)/include/krb5/preauth_plugin.h \
   $(top_srcdir)/include/port-sockets.h $(top_srcdir)/include/socket-utils.h \
   yarrow.h ycipher.c ycipher.h ytypes.h
+plugin_prng_impl.so plugin_prng_impl.po $(OUTPRE)plugin_prng_impl.$(OBJEXT): \
+  $(BUILDTOP)/include/krb5/krb5.h $(COM_ERR_DEPS) $(top_srcdir)/plugins/prng/plugin_yarrow/plugin_prng_impl.h \
+  $(top_srcdir)/plugin_core/plugin_manager.h \
+  $(top_srcdir)/plugin_core/plugin_factory.h \
+  plugin_prng_impl.c
+

Added: branches/plugins/src/plugins/prng/prng.exports
===================================================================
--- branches/plugins/src/plugins/prng/prng.exports	                        (rev 0)
+++ branches/plugins/src/plugins/prng/prng.exports	2010-04-14 18:43:37 UTC (rev 23902)
@@ -0,0 +1,5 @@
+plugin_prng_seed
+plugin_prng_os_seed
+plugin_prng_rand
+plugin_prng_init
+plugin_prng_cleanup

Property changes on: branches/plugins/src/lib/crypto/crypto_tests/plugin_conf.yml
___________________________________________________________________
Property changes on: branches/plugins/src/plugins/prng/plugin_yarrow
___________________________________________________________________



More information about the cvs-krb5 mailing list