char *password, int use_policy, kadm5_policy_ent_t pol,
krb5_principal principal)
{
+ plhandle plugin_handle;
+ int ret = KADM5_OK;
- int ret = 0;
+ if (srv_handle != NULL && srv_handle->context != NULL &&
+ srv_handle->context->pl_handle != NULL ){
- plhandle plugin_handle = plugin_manager_get_service(srv_handle->context->pl_handle, "plugin_pwd_qlty");
-
- ret = plugin_pwd_qlty_check(plugin_handle, srv_handle, password, use_policy, pol, principal);
+ plugin_handle = plugin_manager_get_service(srv_handle->context->pl_handle,
+ "plugin_pwd_qlty");
+ ret = plugin_pwd_qlty_check(plugin_handle,
+ srv_handle, password, use_policy, pol, principal);
+ }
return ret;
}
#include "plugin_manager.h"
#include "plugin_factory.h"
-//#include "plugin_prng_impl.h"
#include "plugin_pa_impl.h"
#include "plugin_pwd_qlty_impl.h"
#include "plugin_default_factory.h"
static plugin_factory* _default_factory_instance = NULL;
static plugin_descr plugin_default_factory_table[] = {
-// {"plugin_yarrow_prng", plugin_yarrow_prng_create},
{"plugin_pwd_qlty_krb", plugin_pwd_qlty_krb_create},
{"plugin_encrypted_challenge_pa", plugin_encrypted_challenge_pa_create},
{"plugin_ldap_audit", NULL},
#include "krb5_parser.h"
#endif
-
-//static plugin_manager* _instance = NULL;
-
static plugin_factory_descr _table[] = {
{"plugin_default_factory", plugin_default_factory_get_instance},
{NULL, NULL}
return(p_handle);
}
+#define API_REGISTER_OK 0
+#define API_REGISTER_FAILED 1
+#define API_ALREADY_REGISTERED 2
+
+/* _register_api - returns API_REGISTER_OK on success,
+ * API_REGISTER_FAILED - on failure,
+ * API_ALREADY_REGISTERED if api is already registered
+ */
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;
+ int ret = API_REGISTER_FAILED;
if(data->registry_size == data->registry_max_size) {
_extend_registry(data, extension_size);
#ifdef DEBUG_PLUGINS
printf("%s is already registered, only one plugin is allowed per service\n", api_name);
#endif
- ret = 2;
+ ret = API_ALREADY_REGISTERED;
} else {
strcpy(entry->api_name, api_name);
next = (plhandle*) malloc(sizeof(plhandle));
entry->last = next;
}
entry->size++;
- ret = 1;
+ ret = API_REGISTER_OK;
}
return ret;
}
#ifdef CONFIG_IN_YAML
-static void
+static int
_configure_plugin_yaml(manager_data* mdata, config_node* plugin_node)
{
config_node* p = NULL;
const char* plugin_name = NULL;
const char* plugin_type = NULL;
plhandle handle;
- int ret = 0;
+ int ret = API_REGISTER_FAILED;
for (p = plugin_node->node_value.seq_value.start; p != NULL; p = p->next) {
if(strcmp(p->node_name, "api") == 0) {
handle = _create_api(plugin_name, factory_name, factory_type/*, properties*/);
if(handle.api != NULL) {
ret = _register_api(mdata->registry,plugin_api, plugin_type, handle);
- if (ret != 1) {
+ if (ret != API_REGISTER_OK) {
#ifdef DEBUG_PLUGINS
printf("Failed to register %s for %s(factory=%s,plugin_type=%s)\n",
plugin_name, plugin_api, factory_name, plugin_type);
#endif
- if (ret == 0) exit(1);
}
} else {
#ifdef DEBUG_PLUGINS
printf("Failed to configure plugin: api=%s, plugin_name=%s,factory=%s\n",
plugin_api, plugin_name, factory_name);
#endif
-
}
- return;
+ return ret;
}
/* Plugin API implementation */
-static void
+static int
_configure_yaml(void* data, const char* path)
{
manager_data* mdata = (manager_data*) data;
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 = krb5_get_default_config_files(&files); // TRUE - goes to /etc/krb5.conf
- retval = profile_init((const_profile_filespec_t *) files, &profile);
-/* if (files)
+ 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;
+ retval = profile_init((const_profile_filespec_t *) files, &profile);
+ if (retval == ENOENT)
+ return;
if ((retval = krb5_plugin_iterator_create(profile, &iter))) {
com_err("krb5_PLUGIN_iterator_create", retval, 0);
handle = _create_api(*plugin_name, *factory_name, *factory_type/*, properties*/);
if(handle.api != NULL) {
retval = _register_api(mdata->registry,plugin, *plugin_type, handle);
- if( retval != 1) {
+ if( retval != API_REGISTER_OK) {
#ifdef DEBUG_PLUGINS
printf("Failed to register %s for %s(factory=%s,plugin_type=%s)\n",
*plugin_name, plugin, *factory_name, *plugin_type);
#endif
- if (retval == 0) exit(1);
}
} else {
#ifdef DEBUG_PLUGINS
krb5_free_plugin_string(profile, plugin);
}
}
-
}
#endif
#define PLUGIN_DEFAULT_MANAGER_H_
#include <plugin_manager.h>
-#if 0
-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;
-#endif
plugin_manager* plugin_default_manager_get_instance(plugin_manager** plugin_mngr_instance);
-//plugin_manager* plugin_default_manager_get_instance(void);
#endif /* PLUGIN_DEFAULT_MANAGER_H_ */
void
get_factory_content (factory_handle handle, const char* container[])
{
- plugin_factory* factory = (plugin_factory*) handle.api;
- factory->get_factory_content(container);
+ plugin_factory* factory = (plugin_factory*) handle.api;
+ if (factory != NULL) {
+ return factory->get_factory_content(container);
+ }
+ return;
}
plhandle
create_api (factory_handle handle, const char* plugin_name)
{
- plugin_factory* factory = (plugin_factory*) handle.api;
- return factory->create_api(plugin_name);
+ plugin_factory* factory = (plugin_factory*) handle.api;
+ if (factory != NULL) {
+ return factory->create_api(plugin_name);
+ }
+ return;
}
*/
#include "plugin_manager.h"
#include <k5-int.h>
-#include "string.h"
-
-
-//static plugin_manager* _instance = NULL;
void
-set_plugin_manager_instance(plugin_manager **_instance, plugin_manager* manager) {
- *_instance = manager;
+set_plugin_manager_instance(plugin_manager **_instance, plugin_manager* manager)
+{
+ *_instance = manager;
}
-void
+int
plugin_manager_configure(plugin_manager* _instance,const char* path)
{
- if(_instance != NULL) {
- _instance->configure(_instance->data, path);
- }
+ if (_instance != NULL) {
+ _instance->configure(_instance->data, path);
+ }
}
void plugin_manager_start(plugin_manager* _instance)
{
- if(_instance != NULL) {
- _instance->start(_instance->data);
- }
+ if (_instance != NULL) {
+ _instance->start(_instance->data);
+ }
}
void plugin_manager_stop(plugin_manager* _instance)
{
- if(_instance != NULL) {
- _instance->stop(_instance->data);
- }
+ if (_instance != NULL) {
+ _instance->stop(_instance->data);
+ }
}
plhandle
plugin_manager_get_service(plugin_manager* _instance, const char* service_name)
{
- plhandle handle;
- if(_instance != NULL) {
- handle = _instance->getService(_instance->data, service_name);
- } else {
- handle.api = NULL;
- }
- return handle;
+ plhandle handle;
+ if (_instance != NULL) {
+ handle = _instance->getService(_instance->data, service_name);
+ } else {
+ handle.api = NULL;
+ }
+ return handle;
}
void set_plugin_manager_instance(plugin_manager** _instance,plugin_manager*);
/* Utility functions */
-void plugin_manager_configure(plugin_manager* _instance,const char*);
+int plugin_manager_configure(plugin_manager* _instance,const char*);
void plugin_manager_start(plugin_manager* _instance);
void plugin_manager_stop(plugin_manager* _instance);
plhandle plugin_manager_get_service(plugin_manager* _instance,const char*);
{
kadm5_ret_t ret = KADM5_OK;
plugin_pwd_qlty* api = (plugin_pwd_qlty*) handle.api;
- ret = api->pwd_qlty_check(srv_handle, password, use_policy, pol, principal);
-
+ if (api != NULL) {
+ ret = api->pwd_qlty_check(srv_handle, password, use_policy, pol, principal);
+ }
return ret;
}
{
kadm5_ret_t ret = KADM5_OK;
plugin_pwd_qlty* api = (plugin_pwd_qlty*) handle.api;
- ret = api->pwd_qlty_init(srv_handle);
-
+ if (api != NULL) {
+ ret = api->pwd_qlty_init(srv_handle);
+ }
return ret;
}