added plugin load mechanism to pluto and scepclient and improved debug output
This commit is contained in:
+6
-3
@@ -87,10 +87,10 @@ u_int16_t cur_from_port; /* host order */
|
||||
static void pluto_dbg(int level, char *fmt, ...)
|
||||
{
|
||||
int priority = LOG_INFO;
|
||||
int debug_level;
|
||||
char buffer[8192];
|
||||
char *current = buffer, *next;
|
||||
va_list args;
|
||||
int debug_level;
|
||||
|
||||
if (cur_debugging & DBG_PRIVATE)
|
||||
{
|
||||
@@ -115,7 +115,10 @@ static void pluto_dbg(int level, char *fmt, ...)
|
||||
|
||||
if (log_to_stderr)
|
||||
{
|
||||
fprintf(stderr, "| ");
|
||||
if (level > 1)
|
||||
{
|
||||
fprintf(stderr, "| ");
|
||||
}
|
||||
vfprintf(stderr, fmt, args);
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
@@ -132,7 +135,7 @@ static void pluto_dbg(int level, char *fmt, ...)
|
||||
{
|
||||
*(next++) = '\0';
|
||||
}
|
||||
syslog(priority, "| %s\n", current);
|
||||
syslog(priority, "%s%s\n", (level > 1)? "| ":"", current);
|
||||
current = next;
|
||||
}
|
||||
}
|
||||
|
||||
+26
-2
@@ -40,6 +40,8 @@
|
||||
|
||||
#include <freeswan.h>
|
||||
#include <library.h>
|
||||
#include <debug.h>
|
||||
#include <utils/enumerator.h>
|
||||
|
||||
#include <pfkeyv2.h>
|
||||
#include <pfkey.h>
|
||||
@@ -223,6 +225,24 @@ bool pkcs11_proxy = FALSE;
|
||||
*/
|
||||
static const char *pkcs11_init_args = NULL;
|
||||
|
||||
/**
|
||||
* Log loaded plugins
|
||||
*/
|
||||
static void print_plugins()
|
||||
{
|
||||
char buf[BUF_LEN], *plugin;
|
||||
int len = 0;
|
||||
enumerator_t *enumerator;
|
||||
|
||||
enumerator = lib->plugins->create_plugin_enumerator(lib->plugins);
|
||||
while (len < BUF_LEN && enumerator->enumerate(enumerator, &plugin))
|
||||
{
|
||||
len += snprintf(&buf[len], BUF_LEN-len, "%s ", plugin);
|
||||
}
|
||||
enumerator->destroy(enumerator);
|
||||
DBG1("loaded plugins: %s", buf);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
bool fork_desired = TRUE;
|
||||
@@ -609,6 +629,11 @@ int main(int argc, char **argv)
|
||||
, ipsec_version_code()
|
||||
, compile_time_interop_options);
|
||||
|
||||
/* load plugins, further infrastructure may need it */
|
||||
lib->plugins->load(lib->plugins, IPSEC_PLUGINDIR,
|
||||
lib->settings->get_str(lib->settings, "pluto.load", ""));
|
||||
print_plugins();
|
||||
|
||||
init_nat_traversal(nat_traversal, keep_alive, force_keepalive, nat_t_spf);
|
||||
init_virtual_ip(virtual_private);
|
||||
scx_init(pkcs11_module_path, pkcs11_init_args); /* load and initialize PKCS #11 module */
|
||||
@@ -690,8 +715,7 @@ int main(int argc, char **argv)
|
||||
* 1 general discomfort
|
||||
* 10 lock file exists
|
||||
*/
|
||||
void
|
||||
exit_pluto(int status)
|
||||
void exit_pluto(int status)
|
||||
{
|
||||
reset_globals(); /* needed because we may be called in odd state */
|
||||
free_preshared_secrets();
|
||||
|
||||
Reference in New Issue
Block a user