lib: Add global config namespace

laforge/swu
Tobias Brunner 9 years ago
parent 4f8bd6d404
commit 34d3bfcf14
  1. 2
      scripts/aes-test.c
  2. 2
      scripts/crypt_burn.c
  3. 2
      scripts/dh_speed.c
  4. 2
      scripts/dnssec.c
  5. 2
      scripts/fetch.c
  6. 2
      scripts/hash_burn.c
  7. 2
      scripts/key2keyid.c
  8. 2
      scripts/keyid2sql.c
  9. 2
      scripts/malloc_speed.c
  10. 2
      scripts/pubkey_speed.c
  11. 2
      scripts/tls_test.c
  12. 2
      src/_copyright/_copyright.c
  13. 2
      src/charon-cmd/charon-cmd.c
  14. 2
      src/charon-nm/charon-nm.c
  15. 2
      src/charon-tkm/src/charon-tkm.c
  16. 2
      src/charon/charon.c
  17. 2
      src/checksum/checksum_builder.c
  18. 2
      src/conftest/conftest.c
  19. 2
      src/dumm/ext/dumm.c
  20. 2
      src/dumm/main.c
  21. 2
      src/frontends/android/jni/libandroidbridge/charonservice.c
  22. 2
      src/frontends/osx/charon-xpc/charon-xpc.c
  23. 2
      src/libimcv/imcv.c
  24. 2
      src/libimcv/imv/imv_policy_manager.c
  25. 4
      src/libimcv/plugins/imv_os/pacman.c
  26. 2
      src/libpts/plugins/imv_attestation/attest.c
  27. 4
      src/libstrongswan/library.c
  28. 16
      src/libstrongswan/library.h
  29. 4
      src/libstrongswan/tests/test_runner.c
  30. 2
      src/manager/main.c
  31. 2
      src/medsrv/main.c
  32. 2
      src/openac/openac.c
  33. 2
      src/pki/pki.c
  34. 2
      src/pool/pool.c
  35. 2
      src/pt-tls-client/pt-tls-client.c
  36. 2
      src/scepclient/scepclient.c
  37. 2
      src/starter/starter.c
  38. 2
      src/stroke/stroke.c

@ -556,7 +556,7 @@ int main(int argc, char *argv[])
ctx.in = stdin;
ctx.out = stdout;
library_init(NULL);
library_init(NULL, "aes-test");
atexit(library_deinit);
while (true)

@ -26,7 +26,7 @@ int main(int argc, char *argv[])
int i = 0, limit = 0;
library_init(NULL);
library_init(NULL, "crypt_burn");
lib->plugins->load(lib->plugins, PLUGINS);
atexit(library_deinit);

@ -118,7 +118,7 @@ int main(int argc, char *argv[])
usage();
}
library_init(NULL);
library_init(NULL, "dh_speed");
lib->plugins->load(lib->plugins, argv[1]);
atexit(library_deinit);

@ -45,7 +45,7 @@ int main(int argc, char *argv[])
rr_set_t *rrset;
rr_t *rr;
library_init(NULL);
library_init(NULL, "dnssec");
atexit(library_deinit);
dbg = dbg_dnssec;

@ -35,7 +35,7 @@ int main(int argc, char *argv[])
{
chunk_t res;
library_init(NULL);
library_init(NULL, "fetch");
atexit(library_deinit);
lib->plugins->load(lib->plugins, PLUGINS);

@ -25,7 +25,7 @@ int main(int argc, char *argv[])
char buffer[1024];
int limit = 0, i = 0;
library_init(NULL);
library_init(NULL, "hash_burn");
lib->plugins->load(lib->plugins, PLUGINS);
atexit(library_deinit);

@ -30,7 +30,7 @@ int main(int argc, char *argv[])
char buf[8096];
int read;
library_init(NULL);
library_init(NULL, "key2keyid");
lib->plugins->load(lib->plugins, PLUGINS);
atexit(library_deinit);

@ -30,7 +30,7 @@ int main(int argc, char *argv[])
char buf[8096];
int read, n;
library_init(NULL);
library_init(NULL, "keyid2sql");
lib->plugins->load(lib->plugins, PLUGINS);
atexit(library_deinit);

@ -58,7 +58,7 @@ int main(int argc, char *argv[])
int sizes[16] = { 1, 13, 100, 1000, 16, 10000, 50, 17,
123, 32, 8, 64, 8096, 1024, 123, 9 };
library_init(NULL);
library_init(NULL, "malloc_speed");
atexit(library_deinit);
print_mallinfo();

@ -71,7 +71,7 @@ int main(int argc, char *argv[])
usage();
}
library_init(NULL);
library_init(NULL, "pubkey_speed");
lib->plugins->load(lib->plugins, argv[1]);
atexit(library_deinit);

@ -251,7 +251,7 @@ static void cleanup()
*/
static void init()
{
library_init(NULL);
library_init(NULL, "tls_test");
dbg = dbg_tls;

@ -76,7 +76,7 @@ main(int argc, char *argv[])
const char **notice = copyright;
const char **co;
library_init(NULL);
library_init(NULL, "_copyright");
atexit(library_deinit);
while ((opt = getopt_long(argc, argv, "", opts, NULL)) != EOF)

@ -322,7 +322,7 @@ int main(int argc, char *argv[])
dbg = dbg_stderr;
atexit(library_deinit);
if (!library_init(NULL))
if (!library_init(NULL, "charon-cmd"))
{
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
}

@ -161,7 +161,7 @@ int main(int argc, char *argv[])
dbg = dbg_syslog;
/* initialize library */
if (!library_init(NULL))
if (!library_init(NULL, "charon-nm"))
{
library_deinit();
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);

@ -250,7 +250,7 @@ int main(int argc, char *argv[])
dbg = dbg_syslog;
/* initialize library */
if (!library_init(NULL))
if (!library_init(NULL, dmn_name))
{
library_deinit();
exit(status);

@ -289,7 +289,7 @@ int main(int argc, char *argv[])
dbg = dbg_stderr;
/* initialize library */
if (!library_init(NULL))
if (!library_init(NULL, "charon"))
{
library_deinit();
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);

@ -136,7 +136,7 @@ int main(int argc, char* argv[])
/* avoid confusing leak reports in build process */
setenv("LEAK_DETECTIVE_DISABLE", "1", 0);
/* don't use a strongswan.conf, forces integrity check to disabled */
library_init("");
library_init("", "checksum_builder");
atexit(library_deinit);
integrity = integrity_checker_create(NULL);

@ -435,7 +435,7 @@ int main(int argc, char *argv[])
char *suite_file = "suite.conf", *test_file = NULL, *preload, *plugins;
file_logger_t *logger;
if (!library_init(NULL))
if (!library_init(NULL, "conftest"))
{
library_deinit();
return SS_RC_LIBSTRONGSWAN_INTEGRITY;

@ -774,7 +774,7 @@ void Init_dumm()
/* there are too many to report, rubyruby... */
setenv("LEAK_DETECTIVE_DISABLE", "1", 1);
library_init(NULL);
library_init(NULL, "dumm");
dumm = dumm_create(NULL);

@ -479,7 +479,7 @@ int main(int argc, char *argv[])
enumerator_t *enumerator;
guest_t *guest;
library_init(NULL);
library_init(NULL, "dumm");
gtk_init(&argc, &argv);
pages = linked_list_create();

@ -600,7 +600,7 @@ JNI_METHOD(CharonVpnService, initializeCharon, jboolean,
dbg = dbg_android;
/* initialize library */
if (!library_init(NULL))
if (!library_init(NULL, "charon"))
{
library_deinit();
return FALSE;

@ -133,7 +133,7 @@ int main(int argc, char *argv[])
dbg = dbg_stderr;
atexit(library_deinit);
if (!library_init(NULL))
if (!library_init(NULL, "charon-xpc"))
{
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
}

@ -109,7 +109,7 @@ bool libimcv_init(bool is_imv)
else
{
/* we are the first to initialize libstrongswan */
if (!library_init(NULL))
if (!library_init(NULL, "libimcv"))
{
return FALSE;
}

@ -288,7 +288,7 @@ int main(int argc, char *argv[])
atexit(library_deinit);
/* initialize library */
if (!library_init(NULL))
if (!library_init(NULL, "imv_policy_manager"))
{
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
}

@ -466,12 +466,12 @@ int main(int argc, char *argv[])
atexit(cleanup);
/* initialize library */
if (!library_init(NULL))
if (!library_init(NULL, "pacman"))
{
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
}
if (!lib->plugins->load(lib->plugins,
lib->settings->get_str(lib->settings, "attest.load", "sqlite")))
lib->settings->get_str(lib->settings, "pacman.load", "sqlite")))
{
exit(SS_RC_INITIALIZATION_FAILED);
}

@ -439,7 +439,7 @@ int main(int argc, char *argv[])
atexit(library_deinit);
/* initialize library */
if (!library_init(NULL))
if (!library_init(NULL, "attest"))
{
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
}

@ -145,6 +145,7 @@ void library_deinit()
threads_deinit();
backtrace_deinit();
free((void*)this->public.ns);
free(this);
lib = NULL;
}
@ -234,7 +235,7 @@ static bool check_memwipe()
/*
* see header file
*/
bool library_init(char *settings)
bool library_init(char *settings, const char *namespace)
{
private_library_t *this;
printf_hook_t *pfh;
@ -250,6 +251,7 @@ bool library_init(char *settings)
.public = {
.get = _get,
.set = _set,
.ns = strdup(namespace ?: "libstrongswan"),
},
.ref = 1,
);

@ -1,4 +1,5 @@
/*
* Copyright (C) 2010-2014 Tobias Brunner
* Copyright (C) 2008 Martin Willi
* Hochschule fuer Technik Rapperswil
*
@ -139,6 +140,12 @@ struct library_t {
*/
bool (*set)(library_t *this, char *name, void *object);
/**
* Namespace used for settings etc. (i.e. the name of the binary that uses
* the library)
*/
const char *ns;
/**
* Printf hook registering facility
*/
@ -239,12 +246,17 @@ struct library_t {
* Initialize library, creates "lib" instance.
*
* library_init() may be called multiple times in a single process, but each
* caller should call library_deinit() for each call to library_init().
* caller must call library_deinit() for each call to library_init().
*
* The settings and namespace arguments are only used on the first call.
*
* @param settings file to read settings from, may be NULL for default
* @param namespace name of the binary that uses the library, determines
* the first section name when reading config options.
* Defaults to libstrongswan if NULL.
* @return FALSE if integrity check failed
*/
bool library_init(char *settings);
bool library_init(char *settings, const char *namespace);
/**
* Deinitialize library, destroys "lib" instance.

@ -65,7 +65,7 @@ static array_t *load_suites(test_configuration_t configs[],
bool old = FALSE;
int i;
library_init(NULL);
library_init(NULL, "test-runner");
test_setup_handler();
@ -178,7 +178,7 @@ static bool call_fixture(test_case_t *tcase, bool up)
*/
static bool pre_test(test_runner_init_t init)
{
library_init(NULL);
library_init(NULL, "test-runner");
/* use non-blocking RNG to generate keys fast */
lib->settings->set_default_str(lib->settings,

@ -34,7 +34,7 @@ int main (int arc, char *argv[])
bool debug;
int threads, timeout;
library_init(NULL);
library_init(NULL, "manager");
if (!lib->plugins->load(lib->plugins,
lib->settings->get_str(lib->settings, "manager.load", PLUGINS)))
{

@ -33,7 +33,7 @@ int main(int arc, char *argv[])
char *uri;
int timeout, threads;
library_init(NULL);
library_init(NULL, "medsrv");
if (!lib->plugins->load(lib->plugins,
lib->settings->get_str(lib->settings, "medsrv.load", PLUGINS)))
{

@ -229,7 +229,7 @@ int main(int argc, char **argv)
/* initialize library */
atexit(library_deinit);
if (!library_init(NULL))
if (!library_init(NULL, "openac"))
{
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
}

@ -168,7 +168,7 @@ static void remove_callback()
int main(int argc, char *argv[])
{
atexit(library_deinit);
if (!library_init(NULL))
if (!library_init(NULL, "pki"))
{
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
}

@ -1212,7 +1212,7 @@ int main(int argc, char *argv[])
atexit(library_deinit);
/* initialize library */
if (!library_init(NULL))
if (!library_init(NULL, "pool"))
{
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);
}

@ -166,7 +166,7 @@ static void init()
PLUGIN_PROVIDE(CUSTOM, "pt-tls-client"),
PLUGIN_DEPENDS(CUSTOM, "tnccs-manager"),
};
library_init(NULL);
library_init(NULL, "pt-tls-client");
libtnccs_init();
dbg = dbg_pt_tls;

@ -487,7 +487,7 @@ int main(int argc, char **argv)
err_t ugh = NULL;
/* initialize library */
if (!library_init(NULL))
if (!library_init(NULL, "scepclient"))
{
library_deinit();
exit(SS_RC_LIBSTRONGSWAN_INTEGRITY);

@ -419,7 +419,7 @@ int main (int argc, char **argv)
bool attach_gdb = FALSE;
bool load_warning = FALSE;
library_init(NULL);
library_init(NULL, "starter");
atexit(library_deinit);
libhydra_init("starter");

@ -480,7 +480,7 @@ int main(int argc, char *argv[])
const stroke_token_t *token;
int res = 0;
library_init(NULL);
library_init(NULL, "stroke");
atexit(library_deinit);
if (argc < 2)

Loading…
Cancel
Save