/** * plugin_find - Find a plugin by name * @name: With or without path, or .so extension * * This function uses an opporunistic search for a suitable plugin and * returns the first match. Albeit with at least some measure of * heuristics. * * First it checks for an exact match. If no match is found and @name * starts with a slash the search ends. Otherwise a new search with the * plugin path prepended to @name is made. Also, if @name does not end * with .so it too is added to @name before searching. * * Returns: * On success the pointer to the matching &ddns_system_t is returned, * otherwise %NULL is returned. */ ddns_system_t *plugin_find(const char *name) { char *tmp, *ptr; ddns_system_t *p; if (!name) { errno = EINVAL; return NULL; } /* Check for multiple instances of plugin */ tmp = strdup(name); if (!tmp) return NULL; ptr = strchr(tmp, ':'); if (ptr) *ptr = 0; name = tmp; p = search_plugin(name); if (p) { free(tmp); return p; } if (plugpath && name[0] != '/') { int noext; char *path; size_t len = strlen(plugpath) + strlen(name) + 5; path = malloc(len); if (!path) { free(tmp); return NULL; } noext = strcmp(name + strlen(name) - 3, ".so"); snprintf(path, len, "%s%s%s%s", plugpath, plugpath[strlen(plugpath) - 1] == '/' ? "" : "/", name, noext ? ".so" : ""); p = search_plugin(path); free(path); if (p) { free(tmp); return p; } } free(tmp); errno = ENOENT; return NULL; }
void daemon_interface(void) { DEBUG_MSG("daemon_interface"); /* check if the plugin exists */ if (GBL_OPTIONS->plugin && search_plugin(GBL_OPTIONS->plugin) != ESUCCESS) FATAL_ERROR("%s plugin can not be found !", GBL_OPTIONS->plugin); /* build the list of active hosts */ build_hosts_list(); /* start the mitm attack */ mitm_start(); /* initialize the sniffing method */ EXECUTE(GBL_SNIFF->start); /* if we have to activate a plugin */ if (GBL_OPTIONS->plugin && plugin_init(GBL_OPTIONS->plugin) != PLUGIN_RUNNING) /* end the interface */ return; /* discard the messages */ LOOP { CANCELLATION_POINT(); sleep(1); ui_msg_flush(MSG_ALL); } /* NOT REACHED */ }