Merge branch 'charon-conf-fallback'

Makes charon-systemd and charon-svc also load settings from the charon
section in strongswan.conf.

Fixes #1300.
This commit is contained in:
Tobias Brunner
2016-03-08 10:56:27 +01:00
4 changed files with 61 additions and 2 deletions
+9
View File
@@ -188,6 +188,15 @@ static int service_wait()
return 0; return 0;
} }
/**
* Add namespace alias
*/
static void __attribute__ ((constructor))register_namespace()
{
/* inherit settings from charon */
library_add_namespace("charon");
}
/** /**
* Initialize and run charon using a wait function * Initialize and run charon using a wait function
*/ */
+9
View File
@@ -324,6 +324,15 @@ static plugin_feature_t features[] = {
PLUGIN_PROVIDE(CUSTOM, "systemd-journal"), PLUGIN_PROVIDE(CUSTOM, "systemd-journal"),
}; };
/**
* Add namespace alias
*/
static void __attribute__ ((constructor))register_namespace()
{
/* inherit settings from charon */
library_add_namespace("charon");
}
/** /**
* Main function, starts the daemon. * Main function, starts the daemon.
*/ */
+32 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2009 Tobias Brunner * Copyright (C) 2009-2016 Tobias Brunner
* Copyright (C) 2008 Martin Willi * Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil * Hochschule fuer Technik Rapperswil
* *
@@ -61,6 +61,31 @@ struct private_library_t {
refcount_t ref; refcount_t ref;
}; };
#define MAX_NAMESPACES 5
/**
* Additional namespaces registered using __atrribute__((constructor))
*/
static char *namespaces[MAX_NAMESPACES];
static int ns_count;
/**
* Described in header
*/
void library_add_namespace(char *ns)
{
if (ns_count < MAX_NAMESPACES - 1)
{
namespaces[ns_count] = ns;
ns_count++;
}
else
{
fprintf(stderr, "failed to register additional namespace alias, please "
"increase MAX_NAMESPACES");
}
}
/** /**
* library instance * library instance
*/ */
@@ -248,6 +273,7 @@ bool library_init(char *settings, const char *namespace)
{ {
private_library_t *this; private_library_t *this;
printf_hook_t *pfh; printf_hook_t *pfh;
int i;
if (lib) if (lib)
{ /* already initialized, increase refcount */ { /* already initialized, increase refcount */
@@ -311,6 +337,11 @@ bool library_init(char *settings, const char *namespace)
(hashtable_equals_t)equals, 4); (hashtable_equals_t)equals, 4);
this->public.settings = settings_create(this->public.conf); this->public.settings = settings_create(this->public.conf);
/* add registered aliases */
for (i = 0; i < ns_count; ++i)
{
lib->settings->add_fallback(lib->settings, lib->ns, namespaces[i]);
}
/* all namespace settings may fall back to libstrongswan */ /* all namespace settings may fall back to libstrongswan */
lib->settings->add_fallback(lib->settings, lib->ns, "libstrongswan"); lib->settings->add_fallback(lib->settings, lib->ns, "libstrongswan");
+11 -1
View File
@@ -1,5 +1,5 @@
/* /*
* Copyright (C) 2010-2014 Tobias Brunner * Copyright (C) 2010-2016 Tobias Brunner
* Copyright (C) 2008 Martin Willi * Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil * Hochschule fuer Technik Rapperswil
* *
@@ -276,4 +276,14 @@ void library_deinit();
*/ */
extern library_t *lib; extern library_t *lib;
/**
* Add additional names used as alias for the namespace registered with
* library_init().
*
* To be called from __attribute__((constructor)) functions.
*
* @param ns additional namespace
*/
void library_add_namespace(char *ns);
#endif /** LIBRARY_H_ @}*/ #endif /** LIBRARY_H_ @}*/