svn rev #23974: branches/plugins/src/ config/ kdc/ plugin_core/ plugin_core/impl/

tsitkova@MIT.EDU tsitkova at MIT.EDU
Fri May 7 11:15:17 EDT 2010


http://src.mit.edu/fisheye/changelog/krb5/?cs=23974
Commit By: tsitkova
Log Message:
Support plugin configuration in krb5 config format.
Example of plugin section in  krb5.conf:
[plugins]
        plugin_prng = {
                plugin_factory_name = plugin_default_factory
                plugin_factory_type = static
                plugin_name =  plugin_yarrow_prng
                plugin_type = service
        }
        plugin_pa = {
                plugin_factory_name = plugin_default_factory
                plugin_factory_type = static
                plugin_name = plugin_encrypted_challenge_pa
                plugin_type = service
        }




Changed Files:
U   branches/plugins/src/config/pre.in
U   branches/plugins/src/kdc/Makefile.in
U   branches/plugins/src/plugin_core/Makefile.in
U   branches/plugins/src/plugin_core/impl/deps
U   branches/plugins/src/plugin_core/impl/plugin_default_manager.c
A   branches/plugins/src/plugin_core/krb5_parser.c
A   branches/plugins/src/plugin_core/krb5_parser.h
U   branches/plugins/src/plugin_core/libplugin_core.exports
Modified: branches/plugins/src/config/pre.in
===================================================================
--- branches/plugins/src/config/pre.in	2010-05-05 17:11:39 UTC (rev 23973)
+++ branches/plugins/src/config/pre.in	2010-05-07 15:15:17 UTC (rev 23974)
@@ -326,6 +326,7 @@
 CRYPTO_DEPLIB	= $(TOPLIBD)/libk5crypto$(DEPLIBEXT)
 PLUGIN_CORE_DEPLIB	= $(TOPLIBD)/../plugin_core/libplugin_core$(DEPLIBEXT)
 PLUGIN_PRNG_DEPLIB	= $(TOPLIBD)/../plugins/prng/libplugin_prng.a
+LIBS_PROFILE = $(TOPLIBD)/../util/profile/libprofile$(DEPLIBEXT)
 COM_ERR_DEPLIB	= $(COM_ERR_DEPLIB- at COM_ERR_VERSION@)
 COM_ERR_DEPLIB-sys = # empty
 COM_ERR_DEPLIB-k5 = $(TOPLIBD)/libcom_err$(DEPLIBEXT)
@@ -339,7 +340,7 @@
 SS_DEPLIB-sys	=
 APPUTILS_DEPLIB	= $(TOPLIBD)/libapputils.a
 
-KRB5_BASE_DEPLIBS	= $(KRB5_DEPLIB)  $(PLUGIN_CORE_DEPLIB) $(CRYPTO_DEPLIB) $(COM_ERR_DEPLIB) $(SUPPORT_DEPLIB) $(PLUGIN_PRNG_DEPLIB)
+KRB5_BASE_DEPLIBS	= $(KRB5_DEPLIB)  $(PLUGIN_CORE_DEPLIB) $(LIBS_PROFILE) $(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)
@@ -381,7 +382,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) $(PLUGIN_CORE_DEPLIB) $(PLUGIN_PRNG_DEPLIB)
+KRB5_BASE_LIBS	= $(KRB5_LIB) $(K5CRYPTO_LIB) $(COM_ERR_LIB) $(SUPPORT_LIB) $(GEN_LIB) $(LIBS) $(DL_LIB)  $(LIBS_PROFILE) $(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/kdc/Makefile.in
===================================================================
--- branches/plugins/src/kdc/Makefile.in	2010-05-05 17:11:39 UTC (rev 23973)
+++ branches/plugins/src/kdc/Makefile.in	2010-05-07 15:15:17 UTC (rev 23974)
@@ -13,13 +13,15 @@
 PROG_RPATH=$(KRB5_LIBDIR)
 DEFS=-DLIBDIR=\"$(KRB5_LIBDIR)\"
 
+LIBS_PROFILE = $(BUILDTOP)/util/profile/libprofile.so
 
 
+
 all:: krb5kdc rtest
 
 # DEFINES = -DBACKWARD_COMPAT $(KRB4DEF)
 
-LOCALINCLUDES = -I. -I../plugins/pa/encrypted_challenge -I../plugin_core -I../plugins/pa
+LOCALINCLUDES = -I. -I../plugins/pa/encrypted_challenge -I../plugin_core -I../plugins/pa -I../plugin_core/impl -I../plugin_core -I../plugins/prng -I../plugins/prng/plugin_yarrow
 SRCS= \
 	kdc5_err.c \
 	$(srcdir)/dispatch.c \
@@ -64,10 +66,10 @@
 kdc5_err.o: kdc5_err.h
 
 krb5kdc: $(OBJS) $(KADMSRV_DEPLIBS) $(KRB5_BASE_DEPLIBS) $(APPUTILS_DEPLIB)
-	$(CC_LINK) -o krb5kdc $(OBJS) $(APPUTILS_LIB) $(KADMSRV_LIBS) $(KRB5_BASE_LIBS)  $(PLUGIN_PA)
+	$(CC_LINK) -o krb5kdc $(OBJS) $(APPUTILS_LIB) $(KADMSRV_LIBS) $(KRB5_BASE_LIBS)  $(PLUGIN_PA) $(LIBS_PROFILE)
 
 rtest: $(RT_OBJS) $(KDB5_DEPLIBS) $(KADM_COMM_DEPLIBS) $(KRB5_BASE_DEPLIBS)
-	$(CC_LINK) -o rtest $(RT_OBJS) $(KDB5_LIBS) $(KADM_COMM_LIBS) $(KRB5_BASE_LIBS)
+	$(CC_LINK) -o rtest $(RT_OBJS) $(KDB5_LIBS) $(KADM_COMM_LIBS) $(KRB5_BASE_LIBS)  $(LIBS_PROFILE)
 
 check-unix:: rtest
 	KRB5_CONFIG=$(top_srcdir)/config-files/krb5.conf ; export KRB5_CONFIG ; \

Modified: branches/plugins/src/plugin_core/Makefile.in
===================================================================
--- branches/plugins/src/plugin_core/Makefile.in	2010-05-05 17:11:39 UTC (rev 23973)
+++ branches/plugins/src/plugin_core/Makefile.in	2010-05-07 15:15:17 UTC (rev 23974)
@@ -5,24 +5,26 @@
 PROG_RPATH=$(KRB5_LIBDIR)
 DEFS=
 
-LOCALINCLUDES = -I$(srcdir)/include/krb5  -I$(srcdir)/. -I$(srcdir)/../plugins/prng
+LOCALINCLUDES = -I$(srcdir)/../include/krb5  -I$(srcdir)/. -I$(srcdir)/../plugins/prng -I$(srcdir)/../util/profile
 
 LIBBASE= plugin_core
 LIBMAJOR=0
 LIBMINOR=0
 SO_EXT=.so
 
-LIBS_UTILS = -lyaml
+# LIBS_UTILS = -lyaml
+# LIBS_UTILS = -lprofile
+LIBS_UTILS = $(BUILDTOP)/util/profile/libprofile.so
 
-SHLIB_DIRS=-L$(TOPLIBD)
+SHLIB_DIRS=-L$(TOPLIBD) 
 SHLIB_RDIRS=$(KRB5_LIBDIR)
 STOBJLISTS=OBJS.ST
 
 SHLIB_EXPLIBS=  $(LIBS_UTILS)
  
-STLIBOBJS= plugin_manager.o plugin_factory.o yaml_parser.o
+STLIBOBJS= plugin_manager.o plugin_factory.o krb5_parser.o	
 
-SRCS= plugin_manager.c plugin_factory.c yaml_parser.c
+SRCS= plugin_manager.c plugin_factory.c krb5_parser.c
 
 all-unix:: all-liblinks
 install-unix:: install-libs

Modified: branches/plugins/src/plugin_core/impl/deps
===================================================================
--- branches/plugins/src/plugin_core/impl/deps	2010-05-05 17:11:39 UTC (rev 23973)
+++ branches/plugins/src/plugin_core/impl/deps	2010-05-07 15:15:17 UTC (rev 23974)
@@ -1,7 +1,7 @@
 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/krb5_parser.h \
   $(top_srcdir)/plugin_core/impl/plugin_default_manager.h \
   $(top_srcdir)/plugin_core/impl/plugin_default_factory.h \
   plugin_default_manager.c

Modified: branches/plugins/src/plugin_core/impl/plugin_default_manager.c
===================================================================
--- branches/plugins/src/plugin_core/impl/plugin_default_manager.c	2010-05-05 17:11:39 UTC (rev 23973)
+++ branches/plugins/src/plugin_core/impl/plugin_default_manager.c	2010-05-07 15:15:17 UTC (rev 23974)
@@ -9,11 +9,14 @@
 #include <plugin_factory.h>
 #include "plugin_default_manager.h"
 #include "plugin_default_factory.h"
+#ifdef CONFIG_IN_YAML
 #include "yaml_parser.h"
+#else
+#include "krb5_parser.h"
+#endif
 
 
 static plugin_manager* _instance = NULL;
-//static plhandle* _prng_instance = NULL;
 
 static plugin_factory_descr _table[] = {
         {"plugin_default_factory", plugin_default_factory_get_instance},
@@ -72,7 +75,7 @@
 
 static plhandle
 _create_api(const char* plugin_name, const char* factory_name,
-            const char* factory_type, config_node* properties)
+            const char* factory_type/*, config_node* properties*/)
 {
     plhandle p_handle;
     factory_handle f_handle = _load_factory(factory_name, factory_type);
@@ -119,8 +122,9 @@
     return ret;
 }
 
+#ifdef CONFIG_IN_YAML
 static void
-_configure_plugin(manager_data* mdata, config_node* plugin_node)
+_configure_plugin_yaml(manager_data* mdata, config_node* plugin_node)
 {
     config_node* p = NULL;
     config_node* properties = NULL;
@@ -159,7 +163,7 @@
     printf("plugin_type=%s\n", plugin_type);
     printf("**End**\n");
 */
-    handle = _create_api(plugin_name, factory_name, factory_type, properties);
+    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",
@@ -177,7 +181,7 @@
 
 /* Plugin API implementation */
 static void
-_configure(void* data, const char* path)
+_configure_yaml(void* data, const char* path)
 {
     manager_data* mdata = (manager_data*) data;
     config_node* stream = NULL;
@@ -188,7 +192,7 @@
         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);
+                _configure_plugin_yaml(mdata, q);
             } else {
                 printf("Failed to find plugin configuration\n");
             }
@@ -196,7 +200,95 @@
     }
 }
 
+#else
+
+/* krb5.conf */
+
 static void
+_configure_krb5(void* data, const char* path)
+{
+    manager_data* mdata = (manager_data*) data;
+    krb5_error_code retval;
+    char *plugin;
+    void *iter;
+    profile_filespec_t *files = 0;
+    profile_t profile;
+    const char  *realm_srv_names[4];
+    char **factory_name, **factory_type, **plugin_name, **plugin_type;
+    plhandle handle;
+
+    retval = os_get_default_config_files(&files, FALSE); // TRUE - goes to /etc/krb5.conf
+    retval = profile_init((const_profile_filespec_t *) files, &profile);
+/*    if (files)
+        free_filespecs(files);
+
+    if (retval)
+        ctx->profile = 0;
+*/
+    if (retval == ENOENT)
+        return; // KRB5_CONFIG_CANTOPEN;
+
+
+    if ((retval = krb5_plugin_iterator_create(profile, &iter))) {
+        com_err("krb5_PLUGIN_iterator_create", retval, 0);
+        return;
+    }
+    while (iter) {
+        if ((retval = krb5_plugin_iterator(profile, &iter, &plugin))) {
+            com_err("krb5_PLUGIN_iterator", retval, 0);
+            krb5_plugin_iterator_free(profile, &iter);
+            return;
+        }
+        if (plugin) {
+            printf("PLUGIN: '%s'\n", plugin);
+            realm_srv_names[0] = "plugins";
+            realm_srv_names[1] = plugin;
+
+            /* plugin_name */
+            realm_srv_names[2] = "plugin_name";
+            realm_srv_names[3] = 0;
+
+            retval = profile_get_values(profile, realm_srv_names, &plugin_name);
+
+            /* plugin_type */
+            realm_srv_names[2] = "plugin_type";
+            realm_srv_names[3] = 0;
+
+            retval = profile_get_values(profile, realm_srv_names, &plugin_type);
+
+            /* factory_name */
+            realm_srv_names[2] = "plugin_factory_name";
+            realm_srv_names[3] = 0;
+
+            retval = profile_get_values(profile, realm_srv_names, &factory_name);
+
+            /* factory_type */
+            realm_srv_names[2] = "plugin_factory_type";
+            realm_srv_names[3] = 0;
+
+            retval = profile_get_values(profile, realm_srv_names, &factory_type);
+
+            handle = _create_api(*plugin_name, *factory_name, *factory_type/*, properties*/);
+            if(handle.api != NULL) {
+                if(!(_register_api(mdata->registry,plugin, *plugin_type, handle))) {
+                   printf("Failed to register %s for %s(factory=%s,plugin_type=%s)\n",
+                            *plugin_name, plugin, *factory_name, *plugin_type);
+                    exit(1);
+                }
+            } else {
+                printf("Failed to configure plugin: api=%s, plugin_name=%s,factory=%s\n",
+                         plugin, *plugin_name, *factory_name);
+            }
+
+            krb5_free_plugin_string(profile, plugin);
+        }
+    }
+
+}
+
+#endif
+
+static void
 _start(void* data)
 {
     return;
@@ -244,7 +336,11 @@
         instance = (plugin_manager*) malloc(sizeof(plugin_manager));
         memset(instance, 0, sizeof(plugin_manager));
         instance->data = _init_data();
-        instance->configure = _configure;
+#ifdef CONFIG_IN_YAML
+        instance->configure = _configure_yaml;
+#else
+        instance->configure = _configure_krb5;
+#endif
         instance->start = _start;
         instance->stop = _stop;
         instance->getService = _getService;

Added: branches/plugins/src/plugin_core/krb5_parser.c
===================================================================
--- branches/plugins/src/plugin_core/krb5_parser.c	                        (rev 0)
+++ branches/plugins/src/plugin_core/krb5_parser.c	2010-05-07 15:15:17 UTC (rev 23974)
@@ -0,0 +1,64 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * plugin_core/krb5_parser.c
+ *
+ * Copyright 1990,2000,2001,2002,2003,2004,2006,2008 Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ *   require a specific license from the United States Government.
+ *   It is the responsibility of any person or organization contemplating
+ *   export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission.  Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose.  It is provided "as is" without express
+ * or implied warranty.
+ *
+ * similar to  "lib/krb5/os/realm_iter.c  but for "plugins"
+ *
+ */
+
+#include "k5-int.h"
+#include <prof_int.h>
+#include "krb5_parser.h"
+
+
+krb5_error_code KRB5_CALLCONV
+krb5_plugin_iterator_create(profile_t profile,  void **iter_p)
+{
+    static const char *const names[] = { "plugins", 0 };
+
+    return profile_node_iterator_create(profile, names,
+                                   PROFILE_ITER_LIST_SECTION |
+                                   PROFILE_ITER_SECTIONS_ONLY,
+                                   iter_p);
+}
+
+krb5_error_code KRB5_CALLCONV
+krb5_plugin_iterator(profile_t profile, void **iter_p, char **ret_realm)
+{
+    return profile_iterator(iter_p, ret_realm, 0);
+}
+
+void KRB5_CALLCONV
+krb5_plugin_iterator_free(profile_t profile,  void **iter_p)
+{
+    profile_iterator_free(iter_p);
+}
+
+void KRB5_CALLCONV
+krb5_free_plugin_string(profile_t profile, char *str)
+{
+    profile_release_string(str);
+}
+

Added: branches/plugins/src/plugin_core/krb5_parser.h
===================================================================
--- branches/plugins/src/plugin_core/krb5_parser.h	                        (rev 0)
+++ branches/plugins/src/plugin_core/krb5_parser.h	2010-05-07 15:15:17 UTC (rev 23974)
@@ -0,0 +1,44 @@
+/* -*- mode: c; c-basic-offset: 4; indent-tabs-mode: nil -*- */
+/*
+ * plugin_core/krb5_parser.h
+ *
+ * Copyright 1990,2000,2001,2002,2003,2004,2006,2008 Massachusetts Institute of Technology.
+ * All Rights Reserved.
+ *
+ * Export of this software from the United States of America may
+ *   require a specific license from the United States Government.
+ *   It is the responsibility of any person or organization contemplating
+ *   export to obtain such a license before exporting.
+ *
+ * WITHIN THAT CONSTRAINT, permission to use, copy, modify, and
+ * distribute this software and its documentation for any purpose and
+ * without fee is hereby granted, provided that the above copyright
+ * notice appear in all copies and that both that copyright notice and
+ * this permission notice appear in supporting documentation, and that
+ * the name of M.I.T. not be used in advertising or publicity pertaining
+ * to distribution of the software without specific, written prior
+ * permission.  Furthermore if you modify this software you must label
+ * your software as modified software and not distribute it in such a
+ * fashion that it might be confused with the original M.I.T. software.
+ * M.I.T. makes no representations about the suitability of
+ * this software for any purpose.  It is provided "as is" without express
+ * or implied warranty.
+ *
+ */
+
+#include "k5-int.h"
+#include <stdio.h>
+#include <ctype.h>
+
+krb5_error_code KRB5_CALLCONV
+krb5_plugin_iterator_create(profile_t profile,  void **iter_p);
+
+krb5_error_code KRB5_CALLCONV
+krb5_plugin_iterator(profile_t profile, void **iter_p, char **ret_realm);
+
+void KRB5_CALLCONV
+krb5_plugin_iterator_free(profile_t profile,  void **iter_p);
+
+void KRB5_CALLCONV
+krb5_free_plugin_string(profile_t profile, char *str);
+

Modified: branches/plugins/src/plugin_core/libplugin_core.exports
===================================================================
--- branches/plugins/src/plugin_core/libplugin_core.exports	2010-05-05 17:11:39 UTC (rev 23973)
+++ branches/plugins/src/plugin_core/libplugin_core.exports	2010-05-07 15:15:17 UTC (rev 23974)
@@ -5,4 +5,7 @@
 plugin_manager_start
 plugin_manager_stop
 create_api
-parse_file
+krb5_plugin_iterator_create
+krb5_plugin_iterator
+krb5_plugin_iterator_free
+krb5_free_plugin_string




More information about the cvs-krb5 mailing list