diff options
author | Tobias Brunner <tobias@strongswan.org> | 2016-03-08 10:56:27 +0100 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2016-03-08 10:56:27 +0100 |
commit | 819da83fccf99acf7af1ed2bf61a498425c375e1 (patch) | |
tree | 1d9c5c2c390aa9672a232519f4e5ae564d77dcb9 /src | |
parent | 101abed566099b5b9ac53a86a88e03af27bbf1d5 (diff) | |
parent | 2e190dca041a02877b9d639b92c00344c01c0743 (diff) | |
download | strongswan-819da83fccf99acf7af1ed2bf61a498425c375e1.tar.bz2 strongswan-819da83fccf99acf7af1ed2bf61a498425c375e1.tar.xz |
Merge branch 'charon-conf-fallback'
Makes charon-systemd and charon-svc also load settings from the charon
section in strongswan.conf.
Fixes #1300.
Diffstat (limited to 'src')
-rw-r--r-- | src/charon-svc/charon-svc.c | 9 | ||||
-rw-r--r-- | src/charon-systemd/charon-systemd.c | 9 | ||||
-rw-r--r-- | src/libstrongswan/library.c | 33 | ||||
-rw-r--r-- | src/libstrongswan/library.h | 12 |
4 files changed, 61 insertions, 2 deletions
diff --git a/src/charon-svc/charon-svc.c b/src/charon-svc/charon-svc.c index 522cd127e..823b366c0 100644 --- a/src/charon-svc/charon-svc.c +++ b/src/charon-svc/charon-svc.c @@ -189,6 +189,15 @@ static int service_wait() } /** + * 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 */ static void init_and_run(DWORD dwArgc, LPTSTR *lpszArgv, int (*wait)()) diff --git a/src/charon-systemd/charon-systemd.c b/src/charon-systemd/charon-systemd.c index a83db5ac4..5c7bbd779 100644 --- a/src/charon-systemd/charon-systemd.c +++ b/src/charon-systemd/charon-systemd.c @@ -325,6 +325,15 @@ static plugin_feature_t features[] = { }; /** + * Add namespace alias + */ +static void __attribute__ ((constructor))register_namespace() +{ + /* inherit settings from charon */ + library_add_namespace("charon"); +} + +/** * Main function, starts the daemon. */ int main(int argc, char *argv[]) diff --git a/src/libstrongswan/library.c b/src/libstrongswan/library.c index dc73ccc68..e130b93ee 100644 --- a/src/libstrongswan/library.c +++ b/src/libstrongswan/library.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2009 Tobias Brunner + * Copyright (C) 2009-2016 Tobias Brunner * Copyright (C) 2008 Martin Willi * Hochschule fuer Technik Rapperswil * @@ -61,6 +61,31 @@ struct private_library_t { 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 */ @@ -248,6 +273,7 @@ bool library_init(char *settings, const char *namespace) { private_library_t *this; printf_hook_t *pfh; + int i; if (lib) { /* already initialized, increase refcount */ @@ -311,6 +337,11 @@ bool library_init(char *settings, const char *namespace) (hashtable_equals_t)equals, 4); 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 */ lib->settings->add_fallback(lib->settings, lib->ns, "libstrongswan"); diff --git a/src/libstrongswan/library.h b/src/libstrongswan/library.h index 3a6dd1ba4..08316fd13 100644 --- a/src/libstrongswan/library.h +++ b/src/libstrongswan/library.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010-2014 Tobias Brunner + * Copyright (C) 2010-2016 Tobias Brunner * Copyright (C) 2008 Martin Willi * Hochschule fuer Technik Rapperswil * @@ -276,4 +276,14 @@ void library_deinit(); */ 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_ @}*/ |