Permalink
Browse files

Changed return types of the plugin related functions per "Plugin supp…

…ort improvements" Project Proposal review.

Introduced plugin_version and removed plugin_id config attr.



git-svn-id: svn://anonsvn.mit.edu/krb5/branches/plugins@24177 dc483132-0cff-0310-8789-dd5450dbe970
  • Loading branch information...
tsitkova
tsitkova committed Jul 8, 2010
1 parent f22df8e commit 003d83567a4fcc4e3eea75a2086af55c39acdebb
View
@@ -1426,8 +1426,9 @@ typedef struct _kdb5_dal_handle kdb5_dal_handle;
struct _kdb_log_context;
/* Plugin API ---- PLUGIN HANDLE */
+#define MAX_PL_NAME_LEN 64
typedef struct _plhandle{
- int plugin_id;
+ char plugin_name[MAX_PL_NAME_LEN];
void *api;
struct _plhandle *next;
} plhandle;
@@ -1454,7 +1455,7 @@ typedef struct {
void (*configure)(manager_data * data, const char*);
void (*start)(manager_data * data);
void (*stop)(manager_data * data);
- plhandle (*getService)(manager_data * data, const char*, const int pl_id);
+ plhandle (*getService)(manager_data * data, const char*, const char pl_id[MAX_PL_NAME_LEN]);
} plugin_manager;
/* Plugin API ---- PLUGIN HANDLE ----- END*/
View
@@ -10,7 +10,7 @@ int
preauth_flags(krb5_context context, krb5_preauthtype pa_type)
{
int flags = 0;
- plhandle handle = plugin_manager_get_service(context->pl_manager, "plugin_pa", 0);
+ plhandle handle;// = plugin_manager_get_service(context->pl_manager, "plugin_pa", 0);
flags = plugin_preauth_flags(handle, context, pa_type);
return flags;
@@ -30,7 +30,7 @@ process_preauth(krb5_context context, void *plugin_context,
krb5_pa_data ***out_padata)
{
krb5_error_code ret = 0;
- plhandle handle = plugin_manager_get_service(context->pl_manager, "plugin_pa", 0);
+ plhandle handle ;//= plugin_manager_get_service(context->pl_manager, "plugin_pa", 0);
ret = plugin_process_preauth(handle, context, plugin_context,
request_context, opt,
@@ -52,7 +52,7 @@ kdc_include_padata(krb5_context context, krb5_kdc_req *request,
void *pa_module_context, krb5_pa_data *data)
{
krb5_error_code retval = 0;
- plhandle handle = plugin_manager_get_service(context->pl_manager, "plugin_pa", 0);
+ plhandle handle;// = plugin_manager_get_service(context->pl_manager, "plugin_pa", 0);
retval = plugin_kdc_include_padata(handle, context, request,
client,
server,
@@ -69,7 +69,7 @@ kdc_verify_preauth(krb5_context context, struct _krb5_db_entry_new *client,
krb5_data **e_data, krb5_authdata ***authz_data)
{
krb5_error_code retval = 0;
- plhandle handle = plugin_manager_get_service(context->pl_manager, "plugin_pa", 0);
+ plhandle handle ;//= plugin_manager_get_service(context->pl_manager, "plugin_pa", 0);
retval = plugin_kdc_verify_preauth(handle, context, client,
req_pkt, request,
enc_tkt_reply, data,
@@ -89,7 +89,7 @@ kdc_return_preauth(krb5_context context, krb5_pa_data *padata,
void *pa_module_context, void **pa_request_context)
{
krb5_error_code retval = 0;
- plhandle handle = plugin_manager_get_service(context->pl_manager, "plugin_pa", 0);
+ plhandle handle;// = plugin_manager_get_service(context->pl_manager, "plugin_pa", 0);
retval = plugin_kdc_return_preauth(handle, context, padata,
client, req_pkt,
request, reply,
@@ -106,7 +106,7 @@ server_free_reqctx(krb5_context kcontext,
void **pa_request_context)
{
krb5_error_code retval = 0;
- plhandle handle = plugin_manager_get_service(kcontext->pl_manager, "plugin_pa", 0);
+ plhandle handle;// = plugin_manager_get_service(kcontext->pl_manager, "plugin_pa", 0);
retval = plugin_server_free_reqctx(handle, kcontext,
pa_module_context,
pa_request_context);
@@ -116,14 +116,14 @@ krb5_error_code
server_init(krb5_context kcontext, void **module_context, const char **realmnames)
{
krb5_error_code retval = 0;
- plhandle handle = plugin_manager_get_service(kcontext->pl_manager, "plugin_pa", 0);
+ plhandle handle;// = plugin_manager_get_service(kcontext->pl_manager, "plugin_pa", 0);
retval = plugin_server_init(handle, kcontext, module_context, realmnames);
return retval;
}
void
server_fini(krb5_context kcontext, void *module_context)
{
- plhandle handle = plugin_manager_get_service(kcontext->pl_manager, "plugin_pa", 0);
+ plhandle handle;// = plugin_manager_get_service(kcontext->pl_manager, "plugin_pa", 0);
plugin_server_fini(handle, kcontext, module_context);
return;
}
@@ -44,10 +44,6 @@ adb_policy_close(kadm5_server_handle_t handle)
/* some of this is stolen from gatekeeper ... */
/* passwd_check - returns KADM5_OK if password passes the validation.*/
-#define PWD_QLTY_KRB 0
-#define PWD_QLTY_X 1
-#define PWD_QLTY_DYN 33
-
kadm5_ret_t
passwd_check(kadm5_server_handle_t srv_handle,
char *password, int use_policy, kadm5_policy_ent_t pol,
@@ -59,20 +55,20 @@ passwd_check(kadm5_server_handle_t srv_handle,
if (srv_handle != NULL && srv_handle->context != NULL &&
srv_handle->context->pl_manager != NULL ){
- plugin_handle = plugin_manager_get_service(srv_handle->context->pl_manager,
- "plugin_pwd_qlty", PWD_QLTY_KRB);
+ ret = plugin_manager_get_service(srv_handle->context->pl_manager,
+ "plugin_pwd_qlty", PWD_QLTY_KRB, &plugin_handle);
ret = plugin_pwd_qlty_check(plugin_handle,
srv_handle, password, use_policy, pol, principal);
- plugin_handle = plugin_manager_get_service(srv_handle->context->pl_manager,
- "plugin_pwd_qlty", PWD_QLTY_X);
+ ret = plugin_manager_get_service(srv_handle->context->pl_manager,
+ "plugin_pwd_qlty", PWD_QLTY_X, &plugin_handle);
ret = plugin_pwd_qlty_check(plugin_handle,
srv_handle, password, use_policy, pol, principal);
- plugin_handle = plugin_manager_get_service(srv_handle->context->pl_manager,
- "plugin_pwd_qlty", PWD_QLTY_DYN);
+ ret = plugin_manager_get_service(srv_handle->context->pl_manager,
+ "plugin_pwd_qlty", PWD_QLTY_DYN, &plugin_handle);
ret = plugin_pwd_qlty_check(plugin_handle,
srv_handle, password, use_policy, pol, principal);
@@ -17,8 +17,6 @@ static plugin_loader* _default_loader_instance = NULL;
static plugin_descr plugin_default_loader_table[] = {
{"plugin_pwd_qlty_X", plugin_pwd_qlty_X_create},
{"plugin_pwd_qlty_krb", plugin_pwd_qlty_krb_create},
- {"plugin_encrypted_challenge_pa", plugin_encrypted_challenge_pa_create},
- {"plugin_ldap_audit", NULL},
{NULL,NULL}
};
@@ -122,7 +122,7 @@ _search_registry (registry_data* data, const char* api_name)
}
static plhandle
-_create_api(const char* plugin_name, const char* plugin_id,
+_create_api(const char* plugin_name,
const char* loader_name, const char* loader_type, const char* loader_path
/*, config_node* properties*/)
{
@@ -131,8 +131,7 @@ _create_api(const char* plugin_name, const char* plugin_id,
#ifdef DEBUG_PLUGINS
printf("plugins: _create_api\n");
#endif
- p_handle = create_api(f_handle, plugin_name);
- p_handle.plugin_id = atoi(plugin_id);
+ plugin_loader_create_api(f_handle, plugin_name, &p_handle);
return(p_handle);
}
@@ -181,7 +180,7 @@ _register_api(registry_data* data, const char* api_name,
next = (plhandle*) malloc(sizeof(plhandle));
memset(next, 0, sizeof(plhandle));
next->api = handle.api;
- next->plugin_id = handle.plugin_id;
+ strncpy(next->plugin_name, handle.plugin_name, strlen(handle.plugin_name));
if(entry->first == NULL) {
entry->first = next;
entry->last = next;
@@ -207,7 +206,6 @@ _configure_plugin_yaml(manager_data* mdata, config_node* plugin_node)
const char* loader_path = NULL;
const char* plugin_name = NULL;
const char* plugin_type = NULL;
- const char* plugin_id = NULL;
plhandle handle;
int ret = API_REGISTER_FAILED;
@@ -227,8 +225,6 @@ _configure_plugin_yaml(manager_data* mdata, config_node* plugin_node)
loader_path = q->node_value.str_value;
} else if(strcmp(q->node_name, "plugin_name") == 0) {
plugin_name = q->node_value.str_value;
- } else if(strcmp(q->node_name, "plugin_id") == 0) {
- plugin_id = q->node_value.str_value;
}
}
@@ -244,11 +240,10 @@ _configure_plugin_yaml(manager_data* mdata, config_node* plugin_node)
printf("plugin_name=%s\n", plugin_name);
printf("plugin_type=%s\n", plugin_type);
printf("plugin_path=%s\n", plugin_path);
- printf("plugin_id=%s\n", plugin_id);
printf("**End**\n");
#endif
- handle = _create_api(plugin_name, plugin_id,
+ handle = _create_api(plugin_name,
loader_name, loader_type, loader_path /*, properties*/);
if(handle.api != NULL) {
ret = _register_api(mdata->registry,plugin_api, plugin_type, handle);
@@ -302,26 +297,18 @@ _configure_krb5(manager_data* data, const char* path)
{
manager_data* mdata = (manager_data*) data;
krb5_error_code retval;
- char *plugin;
void *iter;
int i = 0;
profile_filespec_t *files = NULL;
profile_t profile;
const char *hierarchy[4];
- char **loader_name, **loader_type, **loader_path, **plugin_name, **plugin_type;
- char** plugin_id;
+ char **loader_name, **loader_type, **loader_path, **plugin_name, **plugin_type, **plugin_version;
char** plugin_api;
char *f_path = NULL;
plhandle handle;
char **pl_list, *pl_l;
retval = krb5_get_default_config_files(&files);
-#if 0
- if (files)
- free_filespecs(files);
- if (retval)
- ctx->profile = 0;
-#endif
if (retval == ENOENT)
return; // KRB5_CONFIG_CANTOPEN;
@@ -344,16 +331,6 @@ _configure_krb5(manager_data* data, const char* path)
return;
}
-#if 0
- while (iter && pl_list[i]) {
- if ((retval = krb5_plugin_iterator(profile, &iter, &plugin))) {
- com_err("krb5_PLUGIN_iterator", retval, 0);
- krb5_plugin_iterator_free(profile, &iter);
- return;
- }
- if (plugin) {
-#endif
-
i=0;
while ((pl_l = pl_list[i++])){
@@ -362,7 +339,6 @@ _configure_krb5(manager_data* data, const char* path)
#endif
hierarchy[0] = "plugins";
hierarchy[1] = pl_l;
- //hierarchy[1] = plugin;
/* plugin_name */
hierarchy[2] = "plugin_api";
@@ -379,10 +355,10 @@ _configure_krb5(manager_data* data, const char* path)
hierarchy[3] = 0;
retval = profile_get_values(profile, hierarchy, &plugin_type);
- /* plugin_id */
- hierarchy[2] = "plugin_id";
+ /* plugin_version */
+ hierarchy[2] = "plugin_version";
hierarchy[3] = 0;
- retval = profile_get_values(profile, hierarchy, &plugin_id);
+ retval = profile_get_values(profile, hierarchy, &plugin_version);
/* loader_name */
hierarchy[2] = "plugin_loader_name";
@@ -405,18 +381,17 @@ _configure_krb5(manager_data* data, const char* path)
#ifdef DEBUG_PLUGINS
- printf("ZH plugins: >>>\n");
+ printf("plugins: >>>\n");
printf("api=%s\n", *plugin_api);
printf("loader=%s\n", *loader_name);
printf("loader_type=%s\n", *loader_type);
if (f_path) printf("loader_path=%s\n", f_path);
printf("plugin_name=%s\n", *plugin_name);
printf("plugin_type=%s\n",*plugin_type);
- printf("plugin_id=%s\n", *plugin_id);
printf("<<< plugins\n");
#endif
- handle = _create_api(*plugin_name, *plugin_id,
+ handle = _create_api(*plugin_name,
*loader_name, *loader_type, f_path /*, properties*/);
if(handle.api != NULL) {
retval = _register_api(mdata->registry,*plugin_api, *plugin_type, handle);
@@ -456,7 +431,7 @@ _stop(manager_data* data)
}
static plhandle
-_getService(manager_data* data, const char* service_name, int plugin_id)
+_getService(manager_data* data, const char* service_name, const char* plugin_name)
{
plhandle *handle;
manager_data* mdata = (manager_data*) data;
@@ -465,12 +440,12 @@ _getService(manager_data* data, const char* service_name, int plugin_id)
memset(&handle, 0, sizeof handle);
if(entry) {
for(handle = entry->first; handle != NULL; handle = handle->next) {
- if (handle->plugin_id == plugin_id)
+ if (!strncmp(handle->plugin_name, plugin_name, strlen(plugin_name)))
break;
}
if (handle == NULL) {
#ifdef DEBUG_PLUGINS
- printf("service %s:%d is not registered \n", service_name, plugin_id);
+ printf("service %s:%s is not registered \n", service_name, plugin_name);
#endif
}
@@ -493,7 +468,7 @@ _init_data()
return data;
}
-plugin_manager*
+krb5_error_code
plugin_default_manager_get_instance(plugin_manager** plugin_mngr_instance)
{
plugin_manager* instance = NULL;
@@ -519,5 +494,5 @@ plugin_default_manager_get_instance(plugin_manager** plugin_mngr_instance)
instance->getService = _getService;
*plugin_mngr_instance = instance;
}
- return (*plugin_mngr_instance);
+ return 0;
}
@@ -8,6 +8,6 @@
#include <plugin_manager.h>
-plugin_manager* plugin_default_manager_get_instance(plugin_manager** plugin_mngr_instance);
+krb5_error_code plugin_default_manager_get_instance(plugin_manager** plugin_mngr_instance);
#endif /* PLUGIN_DEFAULT_MANAGER_H_ */
@@ -1,9 +1,8 @@
-get_loader_content
plugin_manager_configure
plugin_manager_get_service
plugin_manager_start
plugin_manager_stop
-create_api
+plugin_loader_create_api
krb5_plugin_iterator_create
krb5_plugin_iterator
krb5_plugin_iterator_free
@@ -6,22 +6,12 @@
#include <string.h>
#include "plugin_loader.h"
-void
-get_loader_content (loader_handle handle, const char* container[])
+krb5_error_code
+plugin_loader_create_api (loader_handle handle, const char* plugin_name, plhandle *pl_handle)
{
plugin_loader* loader = (plugin_loader*) handle.api;
if (loader != NULL) {
- return loader->get_loader_content(container);
+ *pl_handle = loader->create_api(plugin_name);
}
- return;
-}
-
-plhandle
-create_api (loader_handle handle, const char* plugin_name)
-{
- plugin_loader* loader = (plugin_loader*) handle.api;
- if (loader != NULL) {
- return loader->create_api(plugin_name);
- }
- return;
+ return 0;
}
@@ -27,8 +27,6 @@ typedef struct {
plhandle (*create_api)(const char*);
} plugin_loader;
-/* Utility functions */
-void get_loader_content(loader_handle handle, const char* container[]);
-plhandle create_api(loader_handle handle, const char* plugin_name);
+krb5_error_code plugin_loader_create_api(loader_handle handle, const char* plugin_name, plhandle *);
#endif /* PLUGIN_LOADER_H_ */
Oops, something went wrong.

0 comments on commit 003d835

Please sign in to comment.