commit 565dd1f1cbdbf363e255e8b317e0ad3ee5a63463
parent f50bef5c73866363a48ce3200ef8402cc0c3fd18
Author: Christian Grothoff <christian@grothoff.org>
Date: Thu, 14 Nov 2024 22:19:36 +0100
adaptations of sync to GNUnet fix #8962
Diffstat:
9 files changed, 29 insertions(+), 135 deletions(-)
diff --git a/src/include/sync_util.h b/src/include/sync_util.h
@@ -27,7 +27,7 @@
* Return default project data used by Sync.
*/
const struct GNUNET_OS_ProjectData *
-SYNC_project_data_default (void);
+SYNC_project_data (void);
#endif
diff --git a/src/sync/sync-httpd.c b/src/sync/sync-httpd.c
@@ -729,12 +729,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 (SYNC_project_data_default ());
- ret = GNUNET_PROGRAM_run (argc, argv,
+ ret = GNUNET_PROGRAM_run (SYNC_project_data (),
+ argc, argv,
"sync-httpd",
"sync HTTP interface",
options,
diff --git a/src/syncdb/sync-dbinit.c b/src/syncdb/sync-dbinit.c
@@ -129,12 +129,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 (SYNC_project_data_default ());
- ret = GNUNET_PROGRAM_run (argc, argv,
+ ret = GNUNET_PROGRAM_run (SYNC_project_data (),
+ argc, argv,
"sync-dbinit",
"Initialize sync database",
options,
diff --git a/src/syncdb/sync_db_plugin.c b/src/syncdb/sync_db_plugin.c
@@ -20,6 +20,7 @@
* @author Sree Harsha Totakura <sreeharsha@totakura.in>
*/
#include "platform.h"
+#include "sync_util.h"
#include "sync_database_lib.h"
#include <ltdl.h>
@@ -47,7 +48,8 @@ SYNC_DB_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg,
"libsync_plugin_db_%s",
plugin_name);
GNUNET_free (plugin_name);
- plugin = GNUNET_PLUGIN_load (lib_name,
+ plugin = GNUNET_PLUGIN_load (SYNC_project_data (),
+ lib_name,
(void *) cfg);
if (NULL != plugin)
plugin->library_name = lib_name;
@@ -80,75 +82,4 @@ SYNC_DB_plugin_unload (struct SYNC_DatabasePlugin *plugin)
}
-/**
- * Libtool search path before we started.
- */
-static char *old_dlsearchpath;
-
-
-/**
- * Setup libtool paths.
- */
-void __attribute__ ((constructor))
-plugin_init (void);
-
-/* make compiler happy... */
-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);
-
-/* make compiler happy... */
-void __attribute__ ((destructor))
-plugin_fini ()
-{
- lt_dlsetsearchpath (old_dlsearchpath);
- if (NULL != old_dlsearchpath)
- {
- GNUNET_free (old_dlsearchpath);
- old_dlsearchpath = NULL;
- }
- lt_dlexit ();
-}
-
-
/* end of sync_db_plugin.c */
diff --git a/src/syncdb/test_sync_db.c b/src/syncdb/test_sync_db.c
@@ -279,8 +279,6 @@ main (int argc,
GNUNET_log_setup (argv[0],
"DEBUG",
NULL);
- (void) TALER_project_data_default ();
- GNUNET_OS_init (SYNC_project_data_default ());
plugin_name++;
(void) GNUNET_asprintf (&testname,
"%s",
@@ -288,7 +286,7 @@ main (int argc,
(void) GNUNET_asprintf (&config_filename,
"test_sync_db_%s.conf",
testname);
- cfg = GNUNET_CONFIGURATION_create ();
+ cfg = GNUNET_CONFIGURATION_create (SYNC_project_data ());
if (GNUNET_OK !=
GNUNET_CONFIGURATION_parse (cfg,
config_filename))
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
@@ -12,23 +12,19 @@ pkgcfgdir = $(prefix)/share/sync/config.d/
pkgcfg_DATA = \
paths.conf
-
-bin_SCRIPTS = \
+bin_PROGRAMS = \
sync-config
+sync_config_SOURCES = \
+ sync-config.c
+sync_config_LDADD = \
+ libsyncutil.la \
+ -lgnunetutil \
+ $(XLIB)
+
EXTRA_DIST = \
$(bin_SCRIPTS) \
- $(pkgcfg_DATA) \
- sync-config.in
-
-edit_script = $(SED) -e 's,%libdir%,$(libdir),'g $(NULL)
-
-sync-config: sync-config.in
- rm -f $@ $@.tmp && \
- $(edit_script) $< >$@.tmp && \
- chmod a-w+x $@.tmp && \
- mv $@.tmp $@
-
+ $(pkgcfg_DATA)
lib_LTLIBRARIES = \
libsyncutil.la
diff --git a/src/util/os_installation.c b/src/util/os_installation.c
@@ -53,24 +53,10 @@ static const struct GNUNET_OS_ProjectData sync_pd = {
* Return default project data used by Sync.
*/
const struct GNUNET_OS_ProjectData *
-SYNC_project_data_default (void)
+SYNC_project_data (void)
{
return &sync_pd;
}
-/**
- * Initialize libsyncutil.
- */
-void __attribute__ ((constructor))
-SYNC_OS_init (void);
-
-/* make compiler happy */
-void __attribute__ ((constructor))
-SYNC_OS_init ()
-{
- GNUNET_OS_init (&sync_pd);
-}
-
-
/* end of os_installation.c */
diff --git a/src/util/sync-config.c b/src/util/sync-config.c
@@ -24,7 +24,7 @@
* @author Christian Grothoff
*/
#include "platform.h"
-#include "taler_util_lib.h"
+#include "sync_util.h"
/**
@@ -43,16 +43,20 @@ main (int argc,
.global_ret = EXIT_SUCCESS
};
struct GNUNET_GETOPT_CommandLineOption options[] = {
+ GNUNET_GETOPT_option_help (SYNC_project_data (),
+ "sync-config [OPTIONS]"),
+ GNUNET_GETOPT_option_version (SYNC_project_data ()->version),
+ GNUNET_CONFIGURATION_CONFIG_OPTIONS (&cs),
GNUNET_GETOPT_OPTION_END
};
enum GNUNET_GenericReturnValue ret;
- TALER_OS_init ();
- ret = GNUNET_PROGRAM_run (argc,
+ ret = GNUNET_PROGRAM_run (SYNC_project_data (),
+ argc,
argv,
- "taler-config [OPTIONS]",
+ "sync-config [OPTIONS]",
gettext_noop (
- "Manipulate Taler configuration files"),
+ "Manipulate Sync configuration files"),
options,
&GNUNET_CONFIGURATION_config_tool_run,
&cs);
@@ -65,4 +69,4 @@ main (int argc,
}
-/* end of taler-config.c */
+/* end of sync-config.c */
diff --git a/src/util/sync-config.in b/src/util/sync-config.in
@@ -1,13 +0,0 @@
-#!/usr/bin/env bash
-
-set -eu
-
-if ! type gnunet-config >/dev/null; then
- echo "$0 needs gnunet-config to be installed"
- exit 1
-fi
-
-GC=$(which gnunet-config)
-SO=$(ls %libdir%/libsyncutil.so.* | sort -n | tail -n1)
-export LD_PRELOAD=${LD_PRELOAD:-}:${SO}
-exec gnunet-config "$@"