From 15980ee476270bc0af4dc1327be0744ce1e6194e Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 14 Nov 2024 22:31:23 +0100 Subject: adaptations of merchant to GNUnet fix #8962 --- configure.ac | 1 + src/Makefile.am | 2 +- src/backend/Makefile.am | 7 +++ src/backend/taler-merchant-depositcheck.c | 3 +- src/backend/taler-merchant-exchangekeyupdate.c | 3 +- src/backend/taler-merchant-httpd.c | 14 ++--- src/backend/taler-merchant-httpd_spa.c | 4 +- src/backend/taler-merchant-httpd_statics.c | 4 +- src/backend/taler-merchant-kyccheck.c | 3 +- src/backend/taler-merchant-reconciliation.c | 3 +- src/backend/taler-merchant-webhook.c | 3 +- src/backend/taler-merchant-wirewatch.c | 3 +- src/backenddb/Makefile.am | 1 + src/backenddb/merchantdb_plugin.c | 75 ++------------------------ src/backenddb/test_merchantdb.c | 3 +- src/merchant-tools/Makefile.am | 3 ++ src/merchant-tools/taler-merchant-benchmark.c | 11 ++-- src/merchant-tools/taler-merchant-dbinit.c | 6 +-- src/merchant-tools/taler-merchant-passwd.c | 6 +-- 19 files changed, 56 insertions(+), 99 deletions(-) diff --git a/configure.ac b/configure.ac index e8042e50..4cce8d50 100644 --- a/configure.ac +++ b/configure.ac @@ -494,6 +494,7 @@ src/backenddb/Makefile src/include/Makefile src/lib/Makefile src/merchant-tools/Makefile +src/util/Makefile src/testing/Makefile ]) AC_OUTPUT diff --git a/src/Makefile.am b/src/Makefile.am index 23b34b38..baf7cea6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,3 +1,3 @@ # This Makefile is in the public domain AM_CPPFLAGS = -I$(top_srcdir)/src/include -SUBDIRS = include bank backenddb backend lib testing merchant-tools +SUBDIRS = include util bank backenddb backend lib testing merchant-tools diff --git a/src/backend/Makefile.am b/src/backend/Makefile.am index 23a11004..d5ddda41 100644 --- a/src/backend/Makefile.am +++ b/src/backend/Makefile.am @@ -28,6 +28,7 @@ taler_merchant_depositcheck_SOURCES = \ taler-merchant-depositcheck.c taler_merchant_depositcheck_LDADD = \ $(top_builddir)/src/backenddb/libtalermerchantdb.la \ + $(top_builddir)/src/util/libtalermerchantutil.la \ -ltalerexchange \ -ltalerjson \ -ltalerutil \ @@ -46,6 +47,7 @@ taler_merchant_exchangekeyupdate_SOURCES = \ taler-merchant-exchangekeyupdate.c taler_merchant_exchangekeyupdate_LDADD = \ $(top_builddir)/src/backenddb/libtalermerchantdb.la \ + $(top_builddir)/src/util/libtalermerchantutil.la \ -ltalerexchange \ -ltalerjson \ -ltalerutil \ @@ -204,6 +206,7 @@ taler_merchant_httpd_SOURCES = \ taler_merchant_httpd_LDADD = \ $(top_builddir)/src/backenddb/libtalermerchantdb.la \ $(top_builddir)/src/bank/libtalermerchantbank.la \ + $(top_builddir)/src/util/libtalermerchantutil.la \ -ltalerexchange \ -ltalertemplating \ -ltalermhd \ @@ -234,6 +237,7 @@ taler_merchant_kyccheck_SOURCES = \ taler-merchant-kyccheck.c taler_merchant_kyccheck_LDADD = \ $(top_builddir)/src/backenddb/libtalermerchantdb.la \ + $(top_builddir)/src/util/libtalermerchantutil.la \ -ltalerexchange \ -ltalerjson \ -ltalerutil \ @@ -251,6 +255,7 @@ taler_merchant_reconciliation_SOURCES = \ taler-merchant-reconciliation.c taler_merchant_reconciliation_LDADD = \ $(top_builddir)/src/backenddb/libtalermerchantdb.la \ + $(top_builddir)/src/util/libtalermerchantutil.la \ -ltalerexchange \ -ltalerjson \ -ltalerutil \ @@ -269,6 +274,7 @@ taler_merchant_webhook_SOURCES = \ taler-merchant-webhook.c taler_merchant_webhook_LDADD = \ $(top_builddir)/src/backenddb/libtalermerchantdb.la \ + $(top_builddir)/src/util/libtalermerchantutil.la \ -ltalertemplating \ -ltalermhd \ -ltalerjson \ @@ -289,6 +295,7 @@ taler_merchant_wirewatch_SOURCES = \ taler_merchant_wirewatch_LDADD = \ $(top_builddir)/src/bank/libtalermerchantbank.la \ $(top_builddir)/src/backenddb/libtalermerchantdb.la \ + $(top_builddir)/src/util/libtalermerchantutil.la \ -ltalermhd \ -ltalerjson \ -ltalerutil \ diff --git a/src/backend/taler-merchant-depositcheck.c b/src/backend/taler-merchant-depositcheck.c index c7452a30..ae15a9e7 100644 --- a/src/backend/taler-merchant-depositcheck.c +++ b/src/backend/taler-merchant-depositcheck.c @@ -22,6 +22,7 @@ #include #include #include +#include "taler_merchant_util.h" #include "taler_merchantdb_lib.h" #include "taler_merchantdb_plugin.h" #include @@ -1081,8 +1082,8 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - TALER_OS_init (); ret = GNUNET_PROGRAM_run ( + TALER_MERCHANT_project_data (), argc, argv, "taler-merchant-depositcheck", gettext_noop ( diff --git a/src/backend/taler-merchant-exchangekeyupdate.c b/src/backend/taler-merchant-exchangekeyupdate.c index 0945ad7e..9783f2a1 100644 --- a/src/backend/taler-merchant-exchangekeyupdate.c +++ b/src/backend/taler-merchant-exchangekeyupdate.c @@ -23,6 +23,7 @@ #include #include #include +#include "taler_merchant_util.h" #include "taler_merchant_bank_lib.h" #include "taler_merchantdb_lib.h" #include "taler_merchantdb_plugin.h" @@ -1008,8 +1009,8 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - TALER_OS_init (); ret = GNUNET_PROGRAM_run ( + TALER_MERCHANT_project_data (), argc, argv, "taler-merchant-exchangekeyupdate", gettext_noop ( diff --git a/src/backend/taler-merchant-httpd.c b/src/backend/taler-merchant-httpd.c index 8730c119..f14c2c7e 100644 --- a/src/backend/taler-merchant-httpd.c +++ b/src/backend/taler-merchant-httpd.c @@ -28,6 +28,7 @@ #include #include #include +#include "taler_merchant_util.h" #include "taler-merchant-httpd_config.h" #include "taler-merchant-httpd_exchanges.h" #include "taler-merchant-httpd_get-orders-ID.h" @@ -2444,12 +2445,13 @@ main (int argc, GNUNET_GETOPT_OPTION_END }; - TALER_OS_init (); - res = GNUNET_PROGRAM_run (argc, argv, - "taler-merchant-httpd", - "Taler merchant's HTTP backend interface", - options, - &run, NULL); + res = GNUNET_PROGRAM_run ( + TALER_MERCHANT_project_data (), + argc, argv, + "taler-merchant-httpd", + "Taler merchant's HTTP backend interface", + options, + &run, NULL); if (GNUNET_SYSERR == res) return EXIT_INVALIDARGUMENT; if (GNUNET_NO == res) diff --git a/src/backend/taler-merchant-httpd_spa.c b/src/backend/taler-merchant-httpd_spa.c index 2d97f931..6992f519 100644 --- a/src/backend/taler-merchant-httpd_spa.c +++ b/src/backend/taler-merchant-httpd_spa.c @@ -22,6 +22,7 @@ #include #include #include +#include "taler_merchant_util.h" #include "taler-merchant-httpd_statics.h" #include "taler-merchant-httpd_spa.h" #include @@ -307,7 +308,8 @@ TMH_spa_init () { char *path; - path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + path = GNUNET_OS_installation_get_path (TALER_MERCHANT_project_data (), + GNUNET_OS_IPK_DATADIR); if (NULL == path) { GNUNET_break (0); diff --git a/src/backend/taler-merchant-httpd_statics.c b/src/backend/taler-merchant-httpd_statics.c index a82dafba..a49a2e39 100644 --- a/src/backend/taler-merchant-httpd_statics.c +++ b/src/backend/taler-merchant-httpd_statics.c @@ -20,6 +20,7 @@ */ #include "platform.h" #include +#include "taler_merchant_util.h" #include #include #include @@ -284,7 +285,8 @@ TMH_statics_init () { char *path; - path = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_DATADIR); + path = GNUNET_OS_installation_get_path (TALER_MERCHANT_project_data (), + GNUNET_OS_IPK_DATADIR); if (NULL == path) { GNUNET_break (0); diff --git a/src/backend/taler-merchant-kyccheck.c b/src/backend/taler-merchant-kyccheck.c index 60b7d615..f40321fd 100644 --- a/src/backend/taler-merchant-kyccheck.c +++ b/src/backend/taler-merchant-kyccheck.c @@ -26,6 +26,7 @@ #include #include #include +#include "taler_merchant_util.h" #include "taler_merchant_bank_lib.h" #include "taler_merchantdb_lib.h" #include "taler_merchantdb_plugin.h" @@ -1456,8 +1457,8 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - TALER_OS_init (); ret = GNUNET_PROGRAM_run ( + TALER_MERCHANT_project_data (), argc, argv, "taler-merchant-kyccheck", gettext_noop ( diff --git a/src/backend/taler-merchant-reconciliation.c b/src/backend/taler-merchant-reconciliation.c index b08571c2..b82fda29 100644 --- a/src/backend/taler-merchant-reconciliation.c +++ b/src/backend/taler-merchant-reconciliation.c @@ -23,6 +23,7 @@ #include #include #include +#include "taler_merchant_util.h" #include "taler_merchant_bank_lib.h" #include "taler_merchantdb_lib.h" #include "taler_merchantdb_plugin.h" @@ -1252,8 +1253,8 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - TALER_OS_init (); ret = GNUNET_PROGRAM_run ( + TALER_MERCHANT_project_data (), argc, argv, "taler-merchant-reconciliation", gettext_noop ( diff --git a/src/backend/taler-merchant-webhook.c b/src/backend/taler-merchant-webhook.c index 12da345f..f8d4e7d3 100644 --- a/src/backend/taler-merchant-webhook.c +++ b/src/backend/taler-merchant-webhook.c @@ -22,6 +22,7 @@ #include #include #include +#include "taler_merchant_util.h" #include "taler_merchantdb_lib.h" #include "taler_merchantdb_plugin.h" #include @@ -567,8 +568,8 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - TALER_OS_init (); ret = GNUNET_PROGRAM_run ( + TALER_MERCHANT_project_data (), argc, argv, "taler-merchant-webhook", gettext_noop ( diff --git a/src/backend/taler-merchant-wirewatch.c b/src/backend/taler-merchant-wirewatch.c index e41dceee..09882528 100644 --- a/src/backend/taler-merchant-wirewatch.c +++ b/src/backend/taler-merchant-wirewatch.c @@ -23,6 +23,7 @@ #include #include #include +#include "taler_merchant_util.h" #include "taler_merchant_bank_lib.h" #include "taler_merchantdb_lib.h" #include "taler_merchantdb_plugin.h" @@ -725,10 +726,10 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - TALER_OS_init (); do { config_changed_flag = false; ret = GNUNET_PROGRAM_run ( + TALER_MERCHANT_project_data (), argc, argv, "taler-merchant-wirewatch", gettext_noop ( diff --git a/src/backenddb/Makefile.am b/src/backenddb/Makefile.am index a55941ff..8ade2260 100644 --- a/src/backenddb/Makefile.am +++ b/src/backenddb/Makefile.am @@ -231,6 +231,7 @@ test_merchantdb_postgres_LDFLAGS = \ $(XLIB) test_merchantdb_postgres_LDADD = \ + $(top_builddir)/src/util/libtalermerchantutil.la \ $(top_builddir)/src/backenddb/libtalermerchantdb.la TESTS = \ diff --git a/src/backenddb/merchantdb_plugin.c b/src/backenddb/merchantdb_plugin.c index 1207d499..99c2717e 100644 --- a/src/backenddb/merchantdb_plugin.c +++ b/src/backenddb/merchantdb_plugin.c @@ -21,6 +21,7 @@ */ #include "platform.h" #include +#include "taler_merchant_util.h" #include "taler_merchantdb_plugin.h" #include "taler_merchantdb_lib.h" #include @@ -48,7 +49,8 @@ TALER_MERCHANTDB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg) "libtaler_plugin_merchantdb_%s", plugin_name); GNUNET_free (plugin_name); - plugin = GNUNET_PLUGIN_load (lib_name, + plugin = GNUNET_PLUGIN_load (TALER_MERCHANT_project_data (), + lib_name, (void *) cfg); if (NULL == plugin) { @@ -74,75 +76,4 @@ TALER_MERCHANTDB_plugin_unload (struct TALER_MERCHANTDB_Plugin *plugin) } -/** - * Libtool search path before we started. - */ -static char *old_dlsearchpath; - - -/** - * Setup libtool paths. - */ -void __attribute__ ((constructor)) -plugin_init (void); - -/* Declaration to avoid compiler warning */ -void __attribute__ ((constructor)) -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)) -plugin_fini (void); - -/* Declaration to avoid compiler warning */ -void __attribute__ ((destructor)) -plugin_fini (void) -{ - lt_dlsetsearchpath (old_dlsearchpath); - if (NULL != old_dlsearchpath) - { - GNUNET_free (old_dlsearchpath); - old_dlsearchpath = NULL; - } - lt_dlexit (); -} - - /* end of merchantdb_plugin.c */ diff --git a/src/backenddb/test_merchantdb.c b/src/backenddb/test_merchantdb.c index 8671cfc5..5958742f 100644 --- a/src/backenddb/test_merchantdb.c +++ b/src/backenddb/test_merchantdb.c @@ -24,6 +24,7 @@ #include #include #include +#include "taler_merchant_util.h" #include "taler_merchantdb_lib.h" @@ -7363,7 +7364,7 @@ main (int argc, "%s.conf", testname); fprintf (stdout, "Using %s\n", config_filename); - cfg = GNUNET_CONFIGURATION_create (); + cfg = GNUNET_CONFIGURATION_create (TALER_MERCHANT_project_data ()); if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, config_filename)) diff --git a/src/merchant-tools/Makefile.am b/src/merchant-tools/Makefile.am index 21ddb89a..efa2fa7a 100644 --- a/src/merchant-tools/Makefile.am +++ b/src/merchant-tools/Makefile.am @@ -24,6 +24,7 @@ taler_merchant_benchmark_LDADD = \ $(top_srcdir)/src/backenddb/libtalermerchantdb.la \ $(top_srcdir)/src/lib/libtalermerchant.la \ $(top_srcdir)/src/testing/libtalermerchanttesting.la \ + $(top_srcdir)/src/util/libtalermerchantutil.la \ $(LIBGCRYPT_LIBS) \ -ltalertesting \ -ltalerfakebank \ @@ -42,6 +43,7 @@ taler_merchant_dbinit_SOURCES = \ taler_merchant_dbinit_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/backenddb/libtalermerchantdb.la \ + $(top_srcdir)/src/util/libtalermerchantutil.la \ -ltalerutil \ -ltalerpq \ -lgnunetutil \ @@ -52,6 +54,7 @@ taler_merchant_passwd_SOURCES = \ taler_merchant_passwd_LDADD = \ $(LIBGCRYPT_LIBS) \ $(top_builddir)/src/backenddb/libtalermerchantdb.la \ + $(top_srcdir)/src/util/libtalermerchantutil.la \ -ltalerutil \ -ltalerpq \ -lgnunetutil \ diff --git a/src/merchant-tools/taler-merchant-benchmark.c b/src/merchant-tools/taler-merchant-benchmark.c index 238b9f03..63a7a7f6 100644 --- a/src/merchant-tools/taler-merchant-benchmark.c +++ b/src/merchant-tools/taler-merchant-benchmark.c @@ -25,6 +25,7 @@ #include "platform.h" #include #include +#include "taler_merchant_util.h" #include "taler_merchant_testing_lib.h" @@ -407,6 +408,7 @@ main (int argc, &use_fakebank), GNUNET_GETOPT_option_version (PACKAGE_VERSION " " VCS_VERSION), GNUNET_GETOPT_option_help ( + TALER_MERCHANT_project_data (), "Runs benchmark logic against merchant backend. " "Must be used with either 'ordinary' or 'corner' sub-commands."), GNUNET_GETOPT_option_string ( @@ -431,7 +433,9 @@ main (int argc, "fakebank", "use fakebank for the banking system", &use_fakebank), - GNUNET_GETOPT_option_help ("Populate databases with corner case payments"), + GNUNET_GETOPT_option_help ( + TALER_MERCHANT_project_data (), + "Populate databases with corner case payments"), GNUNET_GETOPT_option_string ( 'l', "logfile", @@ -480,6 +484,7 @@ main (int argc, "use fakebank for the banking system", &use_fakebank), GNUNET_GETOPT_option_help ( + TALER_MERCHANT_project_data (), "Generate Taler ordinary payments" " to populate the databases"), GNUNET_GETOPT_option_string ( @@ -500,7 +505,7 @@ main (int argc, }; const char *default_config_file; - default_config_file = GNUNET_OS_project_data_get ()->user_config_file; + default_config_file = TALER_MERCHANT_project_data ()->user_config_file; options = root_options; if (NULL != argv[1]) { @@ -552,7 +557,7 @@ main (int argc, { struct GNUNET_CONFIGURATION_Handle *cfg; - cfg = GNUNET_CONFIGURATION_create (); + cfg = GNUNET_CONFIGURATION_create (TALER_MERCHANT_project_data ()); if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_filename)) diff --git a/src/merchant-tools/taler-merchant-dbinit.c b/src/merchant-tools/taler-merchant-dbinit.c index aaabdcbe..5fb2d3ab 100644 --- a/src/merchant-tools/taler-merchant-dbinit.c +++ b/src/merchant-tools/taler-merchant-dbinit.c @@ -22,6 +22,7 @@ #include "platform.h" #include #include +#include "taler_merchant_util.h" #include "taler_merchantdb_lib.h" @@ -106,11 +107,8 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - /* 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 (); ret = GNUNET_PROGRAM_run ( + TALER_MERCHANT_project_data (), argc, argv, "taler-merchant-dbinit", gettext_noop ("Initialize Taler merchant database"), diff --git a/src/merchant-tools/taler-merchant-passwd.c b/src/merchant-tools/taler-merchant-passwd.c index 5f061d89..f2ba9649 100644 --- a/src/merchant-tools/taler-merchant-passwd.c +++ b/src/merchant-tools/taler-merchant-passwd.c @@ -22,6 +22,7 @@ #include #include #include +#include "taler_merchant_util.h" #include "taler_merchantdb_lib.h" #include "taler_merchantdb_lib.h" @@ -171,11 +172,8 @@ main (int argc, }; enum GNUNET_GenericReturnValue ret; - /* 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 (); ret = GNUNET_PROGRAM_run ( + TALER_MERCHANT_project_data (), argc, argv, "taler-merchant-passwd", gettext_noop ("Reset instance password"), -- cgit v1.2.3