anastasis

Credential backup and recovery protocol and service
Log | Files | Refs | Submodules | README | LICENSE

commit 6001ed16db0bf99baa23abe100d5795c0831a867
parent 75053ed8d9646b68ddc1704ae6c6683fe1d7734f
Author: Christian Grothoff <christian@grothoff.org>
Date:   Fri, 15 Nov 2024 11:26:16 +0100

adapt Anastasis to GNUnet API changes

Diffstat:
Msrc/authorization/anastasis-helper-authorization-iban.c | 2+-
Msrc/authorization/anastasis_authorization_plugin.c | 75+++------------------------------------------------------------------------
Msrc/authorization/anastasis_authorization_plugin_email.c | 3++-
Msrc/authorization/anastasis_authorization_plugin_iban.c | 3++-
Msrc/authorization/anastasis_authorization_plugin_post.c | 3++-
Msrc/authorization/anastasis_authorization_plugin_sms.c | 3++-
Msrc/backend/anastasis-httpd.c | 8++------
Msrc/cli/anastasis-cli-discover.c | 8++------
Msrc/cli/anastasis-cli-redux.c | 8++------
Msrc/include/anastasis_util_lib.h | 9+--------
Msrc/reducer/anastasis_api_redux.c | 9++++++---
Msrc/stasis/anastasis-dbinit.c | 9+++------
Msrc/stasis/anastasis_db_plugin.c | 74+++-----------------------------------------------------------------------
Msrc/stasis/test_anastasis_db.c | 7+------
Msrc/testing/testing_api_helpers.c | 2+-
Msrc/util/anastasis-crypto-tvg.c | 6+++---
Msrc/util/os_installation.c | 17++---------------
17 files changed, 38 insertions(+), 208 deletions(-)

diff --git a/src/authorization/anastasis-helper-authorization-iban.c b/src/authorization/anastasis-helper-authorization-iban.c @@ -468,8 +468,8 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - ANASTASIS_OS_init (); ret = GNUNET_PROGRAM_run ( + ANASTASIS_project_data (), argc, argv, "anastasis-helper-authorization-iban", gettext_noop ( diff --git a/src/authorization/anastasis_authorization_plugin.c b/src/authorization/anastasis_authorization_plugin.c @@ -21,7 +21,7 @@ */ #include "platform.h" #include "anastasis_authorization_lib.h" -#include <ltdl.h> +#include "anastasis_util_lib.h" /** @@ -121,7 +121,8 @@ ANASTASIS_authorization_plugin_load ( GNUNET_asprintf (&lib_name, "libanastasis_plugin_authorization_%s", method); - authorization = GNUNET_PLUGIN_load (lib_name, + authorization = GNUNET_PLUGIN_load (ANASTASIS_project_data (), + lib_name, &ap->ac); if (NULL == authorization) { @@ -162,74 +163,4 @@ ANASTASIS_authorization_plugin_shutdown (void) } -/** - * Libtool search path before we started. - */ -static char *old_dlsearchpath; - - -/** - * Setup libtool paths. - */ -void __attribute__ ((constructor)) -anastasis_authorization_plugin_init (void); - -/* declaration to fix compiler warning */ -void __attribute__ ((constructor)) -anastasis_authorization_plugin_init (void) -{ - int err; - const char *opath; - char *path; - char *cpath; - - err = lt_dlinit (); - if (err > 0) - { - fprintf (stderr, - _ ("Initialization of plugin mechanism failed: %s!\n"), - lt_dlerror ()); - return; - } - opath = lt_dlgetsearchpath (); - if (NULL != opath) - old_dlsearchpath = GNUNET_strdup (opath); - path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR); - if (NULL != path) - { - if (NULL != opath) - { - GNUNET_asprintf (&cpath, "%s:%s", opath, path); - lt_dlsetsearchpath (cpath); - GNUNET_free (path); - GNUNET_free (cpath); - } - else - { - lt_dlsetsearchpath (path); - GNUNET_free (path); - } - } -} - - -/** - * Shutdown libtool. - */ -void __attribute__ ((destructor)) -anastasis_authorization_plugin_fini (void); - -/* declaration to fix compiler warning */ -void __attribute__ ((destructor)) -anastasis_authorization_plugin_fini (void) -{ - lt_dlsetsearchpath (old_dlsearchpath); - if (NULL != old_dlsearchpath) - { - GNUNET_free (old_dlsearchpath); - } - lt_dlexit (); -} - - /* end of anastasis_authorization_plugin.c */ diff --git a/src/authorization/anastasis_authorization_plugin_email.c b/src/authorization/anastasis_authorization_plugin_email.c @@ -554,7 +554,8 @@ libanastasis_plugin_authorization_email_init (void *cls) json_error_t err; char *tmp; - tmp = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + tmp = GNUNET_OS_installation_get_path (ANASTASIS_project_data (), + GNUNET_OS_IPK_DATADIR); GNUNET_asprintf (&fn, "%sauthorization-email-messages.json", tmp); diff --git a/src/authorization/anastasis_authorization_plugin_iban.c b/src/authorization/anastasis_authorization_plugin_iban.c @@ -689,7 +689,8 @@ libanastasis_plugin_authorization_iban_init (void *cls) json_error_t err; char *tmp; - tmp = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + tmp = GNUNET_OS_installation_get_path (ANASTASIS_project_data (), + GNUNET_OS_IPK_DATADIR); GNUNET_asprintf (&fn, "%sauthorization-iban-messages.json", tmp); diff --git a/src/authorization/anastasis_authorization_plugin_post.c b/src/authorization/anastasis_authorization_plugin_post.c @@ -609,7 +609,8 @@ libanastasis_plugin_authorization_post_init (void *cls) json_error_t err; char *tmp; - tmp = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + tmp = GNUNET_OS_installation_get_path (ANASTASIS_project_data (), + GNUNET_OS_IPK_DATADIR); GNUNET_asprintf (&fn, "%sauthorization-post-messages.json", tmp); diff --git a/src/authorization/anastasis_authorization_plugin_sms.c b/src/authorization/anastasis_authorization_plugin_sms.c @@ -544,7 +544,8 @@ libanastasis_plugin_authorization_sms_init (void *cls) json_error_t err; char *tmp; - tmp = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + tmp = GNUNET_OS_installation_get_path (ANASTASIS_project_data (), + GNUNET_OS_IPK_DATADIR); GNUNET_asprintf (&fn, "%sauthorization-sms-messages.json", tmp); diff --git a/src/backend/anastasis-httpd.c b/src/backend/anastasis-httpd.c @@ -986,12 +986,8 @@ main (int argc, GNUNET_GETOPT_OPTION_END }; - /* FIRST get the libtalerutil initialization out - of the way. Then throw that one away, and force - the ANASTASIS defaults to be used! */ - (void) TALER_project_data_default (); - GNUNET_OS_init (ANASTASIS_project_data_default ()); - res = GNUNET_PROGRAM_run (argc, argv, + res = GNUNET_PROGRAM_run (ANASTASIS_project_data (), + argc, argv, "anastasis-httpd", "Anastasis HTTP interface", options, &run, NULL); diff --git a/src/cli/anastasis-cli-discover.c b/src/cli/anastasis-cli-discover.c @@ -238,12 +238,8 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - /* FIRST get the libtalerutil initialization out - of the way. Then throw that one away, and force - the SYNC defaults to be used! */ - (void) TALER_project_data_default (); - GNUNET_OS_init (ANASTASIS_project_data_default ()); - ret = GNUNET_PROGRAM_run (argc, + ret = GNUNET_PROGRAM_run (ANASTASIS_project_data (), + argc, argv, "anastasis-discover", "This is an application for finding secrets that could be recovered.\n", diff --git a/src/cli/anastasis-cli-redux.c b/src/cli/anastasis-cli-redux.c @@ -370,12 +370,8 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - /* FIRST get the libtalerutil initialization out - of the way. Then throw that one away, and force - the SYNC defaults to be used! */ - (void) TALER_project_data_default (); - GNUNET_OS_init (ANASTASIS_project_data_default ()); - ret = GNUNET_PROGRAM_run (argc, + ret = GNUNET_PROGRAM_run (ANASTASIS_project_data (), + argc, argv, "anastasis-reducer", "This is an application for using Anastasis to handle the states.\n", diff --git a/src/include/anastasis_util_lib.h b/src/include/anastasis_util_lib.h @@ -44,14 +44,7 @@ * Return default project data used by Anastasis. */ const struct GNUNET_OS_ProjectData * -ANASTASIS_project_data_default (void); - - -/** - * Initialize libanastasisutil. - */ -void -ANASTASIS_OS_init (void); +ANASTASIS_project_data (void); /** diff --git a/src/reducer/anastasis_api_redux.c b/src/reducer/anastasis_api_redux.c @@ -434,7 +434,8 @@ ANASTASIS_redux_countries_init_ (void) { char *path; - path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + path = GNUNET_OS_installation_get_path (ANASTASIS_project_data (), + GNUNET_OS_IPK_DATADIR); if (NULL == path) { GNUNET_break (0); @@ -813,7 +814,8 @@ begin_provider_config_check (const char *cc, char *dn; char *path; - path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + path = GNUNET_OS_installation_get_path (ANASTASIS_project_data (), + GNUNET_OS_IPK_DATADIR); if (NULL == path) { GNUNET_break (0); @@ -981,7 +983,8 @@ redux_id_attr_init (const char *country_code) { char *path; - path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + path = GNUNET_OS_installation_get_path (ANASTASIS_project_data (), + GNUNET_OS_IPK_DATADIR); if (NULL == path) { GNUNET_break (0); diff --git a/src/stasis/anastasis-dbinit.c b/src/stasis/anastasis-dbinit.c @@ -20,6 +20,7 @@ * @author Dominik Meister */ #include "platform.h" +#include "anastasis_util_lib.h" #include "anastasis_database_lib.h" @@ -132,17 +133,13 @@ main (int argc, GNUNET_GETOPT_OPTION_END }; - /* force linker to link against libtalerutil; if we do - not do this, the linker may "optimize" libtalerutil - away and skip #TALER_OS_init(), which we do need */ - (void) TALER_project_data_default (); - GNUNET_OS_init (ANASTASIS_project_data_default ()); GNUNET_assert (GNUNET_OK == GNUNET_log_setup ("anastasis-dbinit", "INFO", NULL)); if (GNUNET_OK != - GNUNET_PROGRAM_run (argc, argv, + GNUNET_PROGRAM_run (ANASTASIS_project_data (), + argc, argv, "anastasis-dbinit", "Initialize anastasis database", options, diff --git a/src/stasis/anastasis_db_plugin.c b/src/stasis/anastasis_db_plugin.c @@ -21,6 +21,7 @@ */ #include "platform.h" #include "anastasis_database_lib.h" +#include "anastasis_util_lib.h" #include <ltdl.h> @@ -47,7 +48,8 @@ ANASTASIS_DB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg, "libanastasis_plugin_db_%s", plugin_name); GNUNET_free (plugin_name); - plugin = GNUNET_PLUGIN_load (lib_name, + plugin = GNUNET_PLUGIN_load (ANASTASIS_project_data (), + lib_name, (void *) cfg); if (NULL != plugin) plugin->library_name = lib_name; @@ -80,74 +82,4 @@ ANASTASIS_DB_plugin_unload (struct ANASTASIS_DatabasePlugin *plugin) } -/** - * Libtool search path before we started. - */ -static char *old_dlsearchpath; - - -/** - * Setup libtool paths. - */ -void __attribute__ ((constructor)) -plugin_init (void); - -/* declaration to fix compiler warning */ -void __attribute__ ((constructor)) -plugin_init () -{ - int err; - const char *opath; - char *path; - char *cpath; - - err = lt_dlinit (); - if (err > 0) - { - fprintf (stderr, - _ ("Initialization of plugin mechanism failed: %s!\n"), - lt_dlerror ()); - return; - } - opath = lt_dlgetsearchpath (); - if (NULL != opath) - old_dlsearchpath = GNUNET_strdup (opath); - path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBDIR); - if (NULL != path) - { - if (NULL != opath) - { - GNUNET_asprintf (&cpath, "%s:%s", opath, path); - lt_dlsetsearchpath (cpath); - GNUNET_free (path); - GNUNET_free (cpath); - } - else - { - lt_dlsetsearchpath (path); - GNUNET_free (path); - } - } -} - - -/** - * Shutdown libtool. - */ -void __attribute__ ((destructor)) -plugin_fini (void); - -/* declaration to fix compiler warning */ -void __attribute__ ((destructor)) -plugin_fini () -{ - lt_dlsetsearchpath (old_dlsearchpath); - if (NULL != old_dlsearchpath) - { - GNUNET_free (old_dlsearchpath); - } - lt_dlexit (); -} - - /* end of anastasis_db_plugin.c */ diff --git a/src/stasis/test_anastasis_db.c b/src/stasis/test_anastasis_db.c @@ -321,11 +321,6 @@ main (int argc, GNUNET_break (0); return -1; } - /* FIRST get the libtalerutil initialization out - of the way. Then throw that one away, and force - the SYNC defaults to be used! */ - (void) TALER_project_data_default (); - GNUNET_OS_init (ANASTASIS_project_data_default ()); GNUNET_log_setup (argv[0], "DEBUG", NULL); plugin_name++; GNUNET_asprintf (&testname, @@ -334,7 +329,7 @@ main (int argc, GNUNET_asprintf (&config_filename, "test_anastasis_db_%s.conf", testname); - cfg = GNUNET_CONFIGURATION_create (); + cfg = GNUNET_CONFIGURATION_create (ANASTASIS_project_data ()); if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, config_filename)) diff --git a/src/testing/testing_api_helpers.c b/src/testing/testing_api_helpers.c @@ -98,7 +98,7 @@ ANASTASIS_TESTING_prepare_anastasis (const char *config_filename) unsigned long code; char *base_url; - cfg = GNUNET_CONFIGURATION_create (); + cfg = GNUNET_CONFIGURATION_create (ANASTASIS_project_data ()); if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, config_filename)) diff --git a/src/util/anastasis-crypto-tvg.c b/src/util/anastasis-crypto-tvg.c @@ -13,8 +13,6 @@ You should have received a copy of the GNU General Public License along with Anastasis; see the file COPYING.GPL. If not, see <http://www.gnu.org/licenses/> */ - - /** * @file util/anastasis-crypto-tgv.c * @brief Generate test vectors for cryptographic operations. @@ -49,6 +47,7 @@ #include <jansson.h> #include <gcrypt.h> #include "anastasis_crypto_lib.h" +#include "anastasis_util_lib.h" /** @@ -588,7 +587,8 @@ main (int argc, "INFO", NULL)); if (GNUNET_OK != - GNUNET_PROGRAM_run (argc, argv, + GNUNET_PROGRAM_run (ANASTASIS_project_data (), + argc, argv, "anastasis-crypto-tvg", "Generate test vectors for cryptographic operations", options, diff --git a/src/util/os_installation.c b/src/util/os_installation.c @@ -1,6 +1,6 @@ /* This file is part of GNU Anastasis. - Copyright (C) 2019, 2021 Anastasis SARL + Copyright (C) 2019, 2021, 2024 Anastasis SARL Anastasis is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -48,24 +48,11 @@ static const struct GNUNET_OS_ProjectData anastasis_pd = { }; -/** - * Return default project data used by Anastasis. - */ const struct GNUNET_OS_ProjectData * -ANASTASIS_project_data_default (void) +ANASTASIS_project_data (void) { return &anastasis_pd; } -/** - * Initialize libanastasisutil. - */ -void __attribute__ ((constructor)) -ANASTASIS_OS_init () -{ - GNUNET_OS_init (&anastasis_pd); -} - - /* end of os_installation.c */