From bcbcf005b4864ac5557c31da10521126d8880849 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 29 Oct 2012 16:14:03 +0000 Subject: installing all service, daemon and helper binaries to lib/gnunet/libexec/; updating code to run binaries from new location, which is no longer in PATH --- src/arm/Makefile.am | 6 ++- src/arm/do_start_process.c | 28 +++++++++- src/ats/Makefile.am | 4 +- src/chat/Makefile.am | 6 ++- src/chat/test_chat.c | 9 ++-- src/chat/test_chat_private.c | 18 +++---- src/core/Makefile.am | 6 ++- src/core/test_core_api.c | 13 +++-- src/core/test_core_api_reliability.c | 6 ++- src/core/test_core_api_start_only.c | 12 +++-- src/core/test_core_quota_compliance.c | 6 ++- src/datastore/Makefile.am | 4 +- src/dht/Makefile.am | 8 ++- src/dns/Makefile.am | 6 ++- src/dv/Makefile.am | 4 +- src/exit/Makefile.am | 10 ++-- src/fs/Makefile.am | 8 ++- src/gns/Makefile.am | 8 ++- src/hostlist/Makefile.am | 4 +- src/hostlist/test_gnunet_daemon_hostlist.c | 6 ++- .../test_gnunet_daemon_hostlist_learning.c | 11 +++- .../test_gnunet_daemon_hostlist_reconnect.c | 9 ++-- src/include/gnunet_os_lib.h | 19 ++++++- src/lockmanager/Makefile.am | 4 +- src/mesh/Makefile.am | 4 +- src/namestore/Makefile.am | 6 ++- src/nat/Makefile.am | 8 ++- src/nse/Makefile.am | 4 +- src/peerinfo/Makefile.am | 4 +- src/pt/Makefile.am | 6 ++- src/statistics/Makefile.am | 7 ++- src/statistics/test_statistics_api.c | 59 ++++++++++------------ src/statistics/test_statistics_api_loop.c | 47 ++++++----------- src/statistics/test_statistics_api_watch.c | 38 +++++--------- .../test_statistics_api_watch_zero_value.c | 50 ++++++------------ src/template/Makefile.am | 6 ++- src/testbed/Makefile.am | 6 ++- src/testing/testing.c | 7 ++- src/topology/Makefile.am | 4 +- src/transport/Makefile.am | 12 +++-- src/util/Makefile.am | 6 ++- src/util/helper.c | 24 ++++----- src/util/os_installation.c | 31 ++++++++++++ src/util/test_resolver_api.c | 16 +++--- src/vpn/Makefile.am | 10 +++- 45 files changed, 346 insertions(+), 224 deletions(-) diff --git a/src/arm/Makefile.am b/src/arm/Makefile.am index 76aec40b6..f91e4210f 100644 --- a/src/arm/Makefile.am +++ b/src/arm/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/src/include pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ arm.conf @@ -27,7 +29,9 @@ libgnunetarm_la_LDFLAGS = \ bin_PROGRAMS = \ - gnunet-arm \ + gnunet-arm + +libexec_PROGRAMS = \ gnunet-service-arm \ mockup-service diff --git a/src/arm/do_start_process.c b/src/arm/do_start_process.c index 1bc56d540..0687fa345 100644 --- a/src/arm/do_start_process.c +++ b/src/arm/do_start_process.c @@ -1,3 +1,23 @@ +/* + This file is part of GNUnet. + (C) 2011, 2012 Christian Grothoff (and other contributing authors) + + GNUnet is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GNUnet is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNUnet; see the file COPYING. If not, write to the + Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + /** * Actually start a process. All of the arguments given to this * function are strings that are used for the "argv" array. However, @@ -27,6 +47,7 @@ do_start_process (int pipe_control, unsigned int std_inheritance, char *cp; const char *last; struct GNUNET_OS_Process *proc; + char *binary_path; argv_size = 1; va_start (ap, first_arg); @@ -98,9 +119,14 @@ do_start_process (int pipe_control, unsigned int std_inheritance, /* *INDENT-ON* */ va_end (ap); argv[argv_size] = NULL; - proc = GNUNET_OS_start_process_v (pipe_control, std_inheritance, lsocks, argv[0], argv); + binary_path = GNUNET_OS_get_libexec_binary_path (argv[0]); + proc = GNUNET_OS_start_process_v (pipe_control, std_inheritance, lsocks, + binary_path, argv); while (argv_size > 0) GNUNET_free (argv[--argv_size]); GNUNET_free (argv); + GNUNET_free (binary_path); return proc; } + +/* end of do_start_process.c */ diff --git a/src/ats/Makefile.am b/src/ats/Makefile.am index 73d5382ca..27ddc542a 100644 --- a/src/ats/Makefile.am +++ b/src/ats/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/src/include pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ ats.conf @@ -36,7 +38,7 @@ libgnunetats_la_LDFLAGS = \ -version-info 2:0:2 -bin_PROGRAMS = \ +libexec_PROGRAMS = \ gnunet-service-ats gnunet_service_ats_SOURCES = \ diff --git a/src/chat/Makefile.am b/src/chat/Makefile.am index 213283684..af33a8bb0 100644 --- a/src/chat/Makefile.am +++ b/src/chat/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/src/include pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ chat.conf @@ -25,8 +27,10 @@ libgnunetchat_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ -version-info 0:0:0 +libexec_PROGRAMS = \ + gnunet-service-chat + bin_PROGRAMS = \ - gnunet-service-chat \ gnunet-chat gnunet_service_chat_SOURCES = \ diff --git a/src/chat/test_chat.c b/src/chat/test_chat.c index 5dcb87966..24a1e38da 100644 --- a/src/chat/test_chat.c +++ b/src/chat/test_chat.c @@ -116,17 +116,18 @@ static int is_auth; static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-arm", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", -#if VERBOSE - "-L", "DEBUG", -#endif "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); + GNUNET_free (binary); } diff --git a/src/chat/test_chat_private.c b/src/chat/test_chat_private.c index ec170a1dd..64150c107 100644 --- a/src/chat/test_chat_private.c +++ b/src/chat/test_chat_private.c @@ -124,23 +124,24 @@ static int bob_ready; static int is_p2p; -struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *bob_public_key = NULL; +static struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *bob_public_key; static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-arm", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", -#if VERBOSE - "-L", "DEBUG", -#endif "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); + GNUNET_free (binary); } @@ -614,9 +615,6 @@ main (int argc, char *argv[]) "test-chat", "-c", "test_chat_data.conf", -#if VERBOSE - "-L", "DEBUG", -#endif NULL }; struct GNUNET_GETOPT_CommandLineOption options[] = { @@ -624,11 +622,7 @@ main (int argc, char *argv[]) }; GNUNET_log_setup ("test_chat", -#if VERBOSE - "DEBUG", -#else "WARNING", -#endif NULL); if (strstr (argv[0], "p2p") != NULL) { diff --git a/src/core/Makefile.am b/src/core/Makefile.am index 4aa7a7c73..3091249f8 100644 --- a/src/core/Makefile.am +++ b/src/core/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/src/include pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ core.conf @@ -30,8 +32,10 @@ libgnunetcore_la_LDFLAGS = \ -version-info 0:0:0 +libexec_PROGRAMS = \ + gnunet-service-core + bin_PROGRAMS = \ - gnunet-service-core \ gnunet-core gnunet_service_core_SOURCES = \ diff --git a/src/core/test_core_api.c b/src/core/test_core_api.c index 0512c9617..11fd14504 100644 --- a/src/core/test_core_api.c +++ b/src/core/test_core_api.c @@ -316,20 +316,23 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", -#if VERBOSE - "-L", "DEBUG", -#endif + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, NULL, + binary, + "gnunet-service-arm", "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); GNUNET_assert (p->th != NULL); p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); + GNUNET_free (binary); } diff --git a/src/core/test_core_api_reliability.c b/src/core/test_core_api_reliability.c index d4afbc27d..dd70d438a 100644 --- a/src/core/test_core_api_reliability.c +++ b/src/core/test_core_api_reliability.c @@ -426,10 +426,13 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-arm", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", "-c", cfgname, NULL); #endif @@ -437,6 +440,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); GNUNET_assert (p->th != NULL); p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); + GNUNET_free (binary); } diff --git a/src/core/test_core_api_start_only.c b/src/core/test_core_api_start_only.c index a502fce6d..d9cb4150d 100644 --- a/src/core/test_core_api_start_only.c +++ b/src/core/test_core_api_start_only.c @@ -137,12 +137,18 @@ init_notify (void *cls, struct GNUNET_CORE_Handle *server, static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-arm", - "gnunet-service-arm", - "-c", cfgname, NULL); + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, NULL, + binary, + "gnunet-service-arm", + "-c", cfgname, NULL); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); + GNUNET_free (binary); } diff --git a/src/core/test_core_quota_compliance.c b/src/core/test_core_quota_compliance.c index 61fe21626..88a915095 100644 --- a/src/core/test_core_quota_compliance.c +++ b/src/core/test_core_quota_compliance.c @@ -570,10 +570,13 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-arm", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", "-c", cfgname, NULL); #endif @@ -583,6 +586,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) p->th = GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, NULL, NULL); GNUNET_assert (p->th != NULL); p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); + GNUNET_free (binary); } diff --git a/src/datastore/Makefile.am b/src/datastore/Makefile.am index 4000e9981..1b17fd3ed 100644 --- a/src/datastore/Makefile.am +++ b/src/datastore/Makefile.am @@ -4,6 +4,8 @@ plugindir = $(libdir)/gnunet pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ datastore.conf @@ -31,7 +33,7 @@ libgnunetdatastore_la_LDFLAGS = \ -version-info 1:0:0 -bin_PROGRAMS = \ +libexec_PROGRAMS = \ gnunet-service-datastore gnunet_service_datastore_SOURCES = \ diff --git a/src/dht/Makefile.am b/src/dht/Makefile.am index a7d22c0ed..a365c5e82 100644 --- a/src/dht/Makefile.am +++ b/src/dht/Makefile.am @@ -7,6 +7,8 @@ plugindir = $(libdir)/gnunet pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ dht.conf @@ -50,8 +52,10 @@ libgnunet_plugin_block_dht_la_DEPENDENCIES = \ -bin_PROGRAMS = \ - gnunet-service-dht \ +libexec_PROGRAMS = \ + gnunet-service-dht + +noinst_PROGRAMS = \ gnunet-dht-monitor \ gnunet-dht-get \ gnunet-dht-put diff --git a/src/dns/Makefile.am b/src/dns/Makefile.am index 42d0c5bd1..b9f262270 100644 --- a/src/dns/Makefile.am +++ b/src/dns/Makefile.am @@ -10,6 +10,8 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + plugindir = $(libdir)/gnunet pkgcfg_DATA = \ @@ -18,7 +20,7 @@ pkgcfg_DATA = \ if LINUX HIJACKBIN = gnunet-helper-dns install-exec-hook: - $(top_srcdir)/src/dns/install-dns-helper.sh $(bindir) $(GNUNETDNS_GROUP) $(SUDO_BINARY) || true + $(top_srcdir)/src/dns/install-dns-helper.sh $(libexecdir) $(GNUNETDNS_GROUP) $(SUDO_BINARY) || true else install-exec-hook: endif @@ -28,7 +30,7 @@ lib_LTLIBRARIES = \ libgnunetdnsstub.la \ libgnunetdns.la -bin_PROGRAMS = \ +libexec_PROGRAMS = \ gnunet-service-dns $(HIJACKBIN) noinst_PROGRAMS = \ diff --git a/src/dv/Makefile.am b/src/dv/Makefile.am index 3050f33cc..39e1d5833 100644 --- a/src/dv/Makefile.am +++ b/src/dv/Makefile.am @@ -11,6 +11,8 @@ endif plugindir = $(libdir)/gnunet +libexecdir= $(pkglibdir)/libexec/ + pkgcfgdir= $(pkgdatadir)/config.d/ pkgcfg_DATA = \ @@ -31,7 +33,7 @@ libgnunetdv_la_LDFLAGS = \ -version-info 0:0:0 -bin_PROGRAMS = \ +libexec_PROGRAMS = \ gnunet-service-dv gnunet_service_dv_SOURCES = \ diff --git a/src/exit/Makefile.am b/src/exit/Makefile.am index bc41e5c2c..dd030e7a4 100644 --- a/src/exit/Makefile.am +++ b/src/exit/Makefile.am @@ -10,6 +10,8 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + plugindir = $(libdir)/gnunet dist_pkgcfg_DATA = \ @@ -18,15 +20,15 @@ dist_pkgcfg_DATA = \ if LINUX EXITBIN = gnunet-helper-exit install-exec-hook: - $(top_srcdir)/src/exit/install-exit-helper.sh $(bindir) $(SUDO_BINARY) || true + $(top_srcdir)/src/exit/install-exit-helper.sh $(libexecdir) $(SUDO_BINARY) || true else install-exec-hook: endif -bin_PROGRAMS = \ - gnunet-daemon-exit $(EXITBIN) - +libexec_PROGRAMS = \ + gnunet-daemon-exit \ + $(EXITBIN) gnunet_helper_exit_SOURCES = \ gnunet-helper-exit.c diff --git a/src/fs/Makefile.am b/src/fs/Makefile.am index b4e493d2b..c5dba2d58 100644 --- a/src/fs/Makefile.am +++ b/src/fs/Makefile.am @@ -11,6 +11,8 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ fs.conf @@ -60,15 +62,17 @@ libgnunetfstest_a_LIBADD = \ $(top_builddir)/src/testing/libgnunettesting.la \ $(top_builddir)/src/testbed/libgnunettestbed.la +libexec_PROGRAMS = \ + gnunet-helper-fs-publish \ + gnunet-service-fs + bin_PROGRAMS = \ gnunet-auto-share \ gnunet-directory \ gnunet-download \ gnunet-publish \ - gnunet-helper-fs-publish \ gnunet-pseudonym \ gnunet-search \ - gnunet-service-fs \ gnunet-fs \ gnunet-unindex diff --git a/src/gns/Makefile.am b/src/gns/Makefile.am index 193d18f8f..038f9f4d3 100644 --- a/src/gns/Makefile.am +++ b/src/gns/Makefile.am @@ -28,6 +28,8 @@ endif pkgcfgdir = $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + plugindir = $(libdir)/gnunet pkgcfg_DATA = \ @@ -47,10 +49,12 @@ if HAVE_GNUTLS endif endif +libexec_PROGRAMS = \ + gnunet-service-gns + bin_PROGRAMS = \ - gnunet-service-gns \ $(DO_FCFSD) \ - $(DO_PROXY) \ + $(DO_PROXY) \ $(DO_W32_HELPER) \ $(DO_W32_NSPTOOLS) \ gnunet-gns \ diff --git a/src/hostlist/Makefile.am b/src/hostlist/Makefile.am index 1df537276..726251aec 100644 --- a/src/hostlist/Makefile.am +++ b/src/hostlist/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/src/include pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + dist_pkgcfg_DATA = \ hostlist.conf @@ -15,7 +17,7 @@ if HAVE_MHD endif if HAVE_LIBCURL -bin_PROGRAMS = \ +libexec_PROGRAMS = \ gnunet-daemon-hostlist endif diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c index 6e9f31a20..5602609ae 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist.c +++ b/src/hostlist/test_gnunet_daemon_hostlist.c @@ -131,9 +131,12 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-arm", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", "-c", cfgname, NULL); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); @@ -141,6 +144,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL); GNUNET_assert (p->th != NULL); p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); + GNUNET_free (binary); } diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c index 8a0992dda..b7199637e 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c @@ -382,10 +382,12 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname) { char *filename; unsigned int result; + char *binary; + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-arm", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", "-c", cfgname, NULL); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); @@ -408,20 +410,25 @@ setup_learn_peer (struct PeerContext *p, const char *cfgname) GNUNET_assert (NULL != p->core); p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg); GNUNET_assert (NULL != p->stats); + GNUNET_free (binary); } static void setup_adv_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-arm", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", "-c", cfgname, NULL); GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); p->stats = GNUNET_STATISTICS_create ("hostlist", p->cfg); GNUNET_assert (NULL != p->stats); + GNUNET_free (binary); } diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c index 1b1df9a3a..63baced46 100644 --- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c +++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c @@ -141,14 +141,14 @@ process_hello (void *cls, const struct GNUNET_MessageHeader *message) static void setup_peer (struct PeerContext *p, const char *cfgname) { + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); p->cfg = GNUNET_CONFIGURATION_create (); #if START_ARM p->arm_proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-arm", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, binary, "gnunet-service-arm", -#if VERBOSE - "-L", "DEBUG", -#endif "-c", cfgname, NULL); #endif GNUNET_assert (GNUNET_OK == GNUNET_CONFIGURATION_load (p->cfg, cfgname)); @@ -156,6 +156,7 @@ setup_peer (struct PeerContext *p, const char *cfgname) GNUNET_TRANSPORT_connect (p->cfg, NULL, p, NULL, ¬ify_connect, NULL); GNUNET_assert (p->th != NULL); p->ghh = GNUNET_TRANSPORT_get_hello (p->th, &process_hello, p); + GNUNET_free (binary); } diff --git a/src/include/gnunet_os_lib.h b/src/include/gnunet_os_lib.h index 1d4828f48..e4bbab8a9 100644 --- a/src/include/gnunet_os_lib.h +++ b/src/include/gnunet_os_lib.h @@ -151,7 +151,12 @@ enum GNUNET_OS_InstallationPathKind * Return the prefix of the path with documentation files, including the * license (share/doc/gnunet/). */ - GNUNET_OS_IPK_DOCDIR + GNUNET_OS_IPK_DOCDIR, + + /** + * Return the directory where helper binaries are installed (lib/gnunet/libexec/) + */ + GNUNET_OS_IPK_LIBEXECDIR }; @@ -200,6 +205,18 @@ char * GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind); +/** + * Given the name of a gnunet-helper, gnunet-service or gnunet-daemon + * binary, try to prefix it with the libexec/-directory to get the + * full path. + * + * @param progname name of the binary + * @return full path to the binary, if possible, otherwise copy of 'progname' + */ +char * +GNUNET_OS_get_libexec_binary_path (const char *progname); + + /** * Callback function invoked for each interface found. * diff --git a/src/lockmanager/Makefile.am b/src/lockmanager/Makefile.am index b1743e308..6a41fe5c1 100644 --- a/src/lockmanager/Makefile.am +++ b/src/lockmanager/Makefile.am @@ -11,10 +11,12 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ lockmanager.conf -bin_PROGRAMS = \ +libexec_PROGRAMS = \ gnunet-service-lockmanager lib_LTLIBRARIES = \ diff --git a/src/mesh/Makefile.am b/src/mesh/Makefile.am index 786747518..8b45dd736 100644 --- a/src/mesh/Makefile.am +++ b/src/mesh/Makefile.am @@ -11,6 +11,8 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ mesh.conf @@ -18,7 +20,7 @@ plugindir = $(libdir)/gnunet AM_CLFAGS = -g -bin_PROGRAMS = \ +libexec_PROGRAMS = \ gnunet-service-mesh lib_LTLIBRARIES = \ diff --git a/src/namestore/Makefile.am b/src/namestore/Makefile.am index 17b765707..04dd870b3 100644 --- a/src/namestore/Makefile.am +++ b/src/namestore/Makefile.am @@ -4,6 +4,8 @@ plugindir = $(libdir)/gnunet pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ namestore.conf @@ -63,8 +65,10 @@ libgnunetnamestore_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ -version-info 0:0:0 +libexec_PROGRAMS = \ + gnunet-service-namestore + bin_PROGRAMS = \ - gnunet-service-namestore \ gnunet-namestore diff --git a/src/nat/Makefile.am b/src/nat/Makefile.am index e4b36caa2..0394569fe 100644 --- a/src/nat/Makefile.am +++ b/src/nat/Makefile.am @@ -7,6 +7,8 @@ if MINGW NATCLIENT = gnunet-helper-nat-client-windows.c endif +libexecdir= $(pkglibdir)/libexec/ + pkgcfgdir= $(pkgdatadir)/config.d/ dist_pkgcfg_DATA = \ @@ -17,13 +19,15 @@ NATBIN = gnunet-helper-nat-server gnunet-helper-nat-client NATSERVER = gnunet-helper-nat-server.c NATCLIENT = gnunet-helper-nat-client.c install-exec-hook: - $(top_srcdir)/src/nat/install-nat-helper.sh $(bindir) $(SUDO_BINARY) || true + $(top_srcdir)/src/nat/install-nat-helper.sh $(libexecdir) $(SUDO_BINARY) || true else install-exec-hook: endif bin_PROGRAMS = \ - gnunet-nat-server \ + gnunet-nat-server + +libexec_PROGRAMS = \ $(NATBIN) gnunet_nat_server_SOURCES = \ diff --git a/src/nse/Makefile.am b/src/nse/Makefile.am index 2c5ed855f..a67ffeaf8 100644 --- a/src/nse/Makefile.am +++ b/src/nse/Makefile.am @@ -11,6 +11,8 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ nse.conf @@ -27,7 +29,7 @@ libgnunetnse_la_LDFLAGS = \ -version-info 0:0:0 -bin_PROGRAMS = \ +libexec_PROGRAMS = \ gnunet-service-nse noinst_PROGRAMS = \ diff --git a/src/peerinfo/Makefile.am b/src/peerinfo/Makefile.am index 192391d88..8387c4fc4 100644 --- a/src/peerinfo/Makefile.am +++ b/src/peerinfo/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/src/include pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ peerinfo.conf @@ -29,7 +31,7 @@ libgnunetpeerinfo_la_LDFLAGS = \ -version-info 0:0:0 -bin_PROGRAMS = \ +libexec_PROGRAMS = \ gnunet-service-peerinfo gnunet_service_peerinfo_SOURCES = \ diff --git a/src/pt/Makefile.am b/src/pt/Makefile.am index 3c71d6d76..b9a8e497c 100644 --- a/src/pt/Makefile.am +++ b/src/pt/Makefile.am @@ -10,13 +10,15 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + plugindir = $(libdir)/gnunet dist_pkgcfg_DATA = \ pt.conf -bin_PROGRAMS = \ - gnunet-daemon-pt $(PTBIN) +libexec_PROGRAMS = \ + gnunet-daemon-pt gnunet_daemon_pt_SOURCES = \ gnunet-daemon-pt.c diff --git a/src/statistics/Makefile.am b/src/statistics/Makefile.am index 5485a9c18..f4d0c3b99 100644 --- a/src/statistics/Makefile.am +++ b/src/statistics/Makefile.am @@ -11,6 +11,8 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ statistics.conf @@ -25,10 +27,11 @@ libgnunetstatistics_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ -version-info 1:1:1 +libexec_PROGRAMS = \ + gnunet-service-statistics bin_PROGRAMS = \ - gnunet-statistics \ - gnunet-service-statistics + gnunet-statistics gnunet_statistics_SOURCES = \ gnunet-statistics.c diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c index ddebfa356..5fb506ff7 100644 --- a/src/statistics/test_statistics_api.c +++ b/src/statistics/test_statistics_api.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2009 Christian Grothoff (and other contributing authors) + (C) 2009, 2012 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -20,17 +20,15 @@ /** * @file statistics/test_statistics_api.c * @brief testcase for statistics_api.c + * @author Christian Grothoff */ #include "platform.h" -#include "gnunet_common.h" -#include "gnunet_getopt_lib.h" -#include "gnunet_os_lib.h" -#include "gnunet_program_lib.h" -#include "gnunet_scheduler_lib.h" +#include "gnunet_util_lib.h" #include "gnunet_statistics_service.h" -#define START_SERVICE GNUNET_YES +static struct GNUNET_STATISTICS_Handle *h; + static int check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, @@ -45,6 +43,7 @@ check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, return GNUNET_OK; } + static int check_2 (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) @@ -58,6 +57,7 @@ check_2 (void *cls, const char *subsystem, const char *name, uint64_t value, return GNUNET_OK; } + static int check_3 (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) @@ -71,7 +71,6 @@ check_3 (void *cls, const char *subsystem, const char *name, uint64_t value, return GNUNET_OK; } -static struct GNUNET_STATISTICS_Handle *h; static void next_fin (void *cls, int success) @@ -83,6 +82,7 @@ next_fin (void *cls, int success) *ok = 0; } + static void next (void *cls, int success) { @@ -94,6 +94,7 @@ next (void *cls, int success) &check_2, cls)); } + static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -110,6 +111,7 @@ run (void *cls, char *const *args, const char *cfgfile, &check_1, cls)); } + static void run_more (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -121,8 +123,9 @@ run_more (void *cls, char *const *args, const char *cfgfile, &check_3, cls)); } -static int -check () + +int +main (int argc, char *argv_ign[]) { int ok = 1; @@ -135,18 +138,21 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; -#if START_SERVICE struct GNUNET_OS_Process *proc; + char *binary; + GNUNET_log_setup ("test_statistics_api", + "WARNING", + NULL); + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics"); proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, + binary, "gnunet-service-statistics", "-c", "test_statistics_api_data.conf", NULL); -#endif GNUNET_assert (NULL != proc); GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options, &run, &ok); -#if START_SERVICE if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); @@ -155,20 +161,20 @@ check () GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); proc = NULL; -#endif if (ok != 0) + { + GNUNET_free (binary); return ok; + } ok = 1; -#if START_SERVICE /* restart to check persistence! */ proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, + binary, "gnunet-service-statistics", "-c", "test_statistics_api_data.conf", NULL); -#endif GNUNET_PROGRAM_run (5, argv, "test-statistics-api", "nohelp", options, &run_more, &ok); -#if START_SERVICE if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); @@ -177,21 +183,8 @@ check () GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); proc = NULL; -#endif + GNUNET_free (binary); return ok; } -int -main (int argc, char *argv[]) -{ - int ret; - - GNUNET_log_setup ("test_statistics_api", - "WARNING", - NULL); - ret = check (); - - return ret; -} - /* end of test_statistics_api.c */ diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c index ae798b830..f9a3a3ba6 100644 --- a/src/statistics/test_statistics_api_loop.c +++ b/src/statistics/test_statistics_api_loop.c @@ -22,18 +22,13 @@ * @brief testcase for statistics_api.c */ #include "platform.h" -#include "gnunet_common.h" -#include "gnunet_getopt_lib.h" -#include "gnunet_os_lib.h" -#include "gnunet_program_lib.h" -#include "gnunet_scheduler_lib.h" +#include "gnunet_util_lib.h" #include "gnunet_statistics_service.h" -#define VERBOSE GNUNET_NO +#define ROUNDS (1024 * 1024) -#define START_SERVICE GNUNET_YES +static struct GNUNET_STATISTICS_Handle *h; -#define ROUNDS (1024 * 1024) static int check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, @@ -45,7 +40,6 @@ check_1 (void *cls, const char *subsystem, const char *name, uint64_t value, return GNUNET_OK; } -static struct GNUNET_STATISTICS_Handle *h; static void next (void *cls, int success) @@ -57,11 +51,12 @@ next (void *cls, int success) *ok = 0; } + static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - int i; + unsigned int i; char name[128]; h = GNUNET_STATISTICS_create ("test-statistics-api-loop", cfg); @@ -80,8 +75,8 @@ run (void *cls, char *const *args, const char *cfgfile, } -static int -check () +int +main (int argc, char *argv_ign[]) { int ok = 1; @@ -93,21 +88,19 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; -#if START_SERVICE struct GNUNET_OS_Process *proc; + char *binary; + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics"); proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", - "gnunet-service-statistics", -#if DEBUG_STATISTICS - "-L", "DEBUG", -#endif - "-c", "test_statistics_api_data.conf", NULL); -#endif + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, NULL, + binary, + "gnunet-service-statistics", + "-c", "test_statistics_api_data.conf", NULL); GNUNET_assert (NULL != proc); GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, &ok); -#if START_SERVICE if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); @@ -116,18 +109,8 @@ check () GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); proc = NULL; -#endif + GNUNET_free (binary); return ok; } -int -main (int argc, char *argv[]) -{ - int ret; - - ret = check (); - - return ret; -} - /* end of test_statistics_api_loop.c */ diff --git a/src/statistics/test_statistics_api_watch.c b/src/statistics/test_statistics_api_watch.c index f3524aa7c..1e7f27b3e 100644 --- a/src/statistics/test_statistics_api_watch.c +++ b/src/statistics/test_statistics_api_watch.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2009, 2011 Christian Grothoff (and other contributing authors) + (C) 2009, 2011, 2012 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -20,6 +20,7 @@ /** * @file statistics/test_statistics_api_watch.c * @brief testcase for statistics_api.c watch functions + * @author Christian Grothoff */ #include "platform.h" #include "gnunet_common.h" @@ -29,9 +30,6 @@ #include "gnunet_scheduler_lib.h" #include "gnunet_statistics_service.h" -#define VERBOSE GNUNET_NO - -#define START_SERVICE GNUNET_YES static int ok; @@ -112,8 +110,8 @@ run (void *cls, char *const *args, const char *cfgfile, } -static int -check () +int +main (int argc, char *argv_ign[]) { char *const argv[] = { "test-statistics-api", "-c", @@ -123,22 +121,19 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; -#if START_SERVICE struct GNUNET_OS_Process *proc; - + char *binary; + + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics"); proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", - "gnunet-service-statistics", -#if VERBOSE - "-L", "DEBUG", -#endif - "-c", "test_statistics_api_data.conf", NULL); -#endif + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, + binary, + "gnunet-service-statistics", + "-c", "test_statistics_api_data.conf", NULL); GNUNET_assert (NULL != proc); ok = 3; GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, NULL); -#if START_SERVICE if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); @@ -147,18 +142,9 @@ check () GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); proc = NULL; -#endif + GNUNET_free (binary); return ok; } -int -main (int argc, char *argv[]) -{ - int ret; - - ret = check (); - - return ret; -} /* end of test_statistics_api_watch.c */ diff --git a/src/statistics/test_statistics_api_watch_zero_value.c b/src/statistics/test_statistics_api_watch_zero_value.c index fe3974fc9..d78de9a9e 100644 --- a/src/statistics/test_statistics_api_watch_zero_value.c +++ b/src/statistics/test_statistics_api_watch_zero_value.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2009, 2011 Christian Grothoff (and other contributing authors) + (C) 2009, 2011, 2012 Christian Grothoff (and other contributing authors) GNUnet is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published @@ -22,21 +22,15 @@ * @brief testcase for statistics_api.c watch functions with initial 0 value */ #include "platform.h" -#include "gnunet_common.h" -#include "gnunet_getopt_lib.h" -#include "gnunet_os_lib.h" -#include "gnunet_program_lib.h" -#include "gnunet_scheduler_lib.h" +#include "gnunet_util_lib.h" #include "gnunet_statistics_service.h" -#define VERBOSE GNUNET_NO - -#define START_SERVICE GNUNET_YES - static int ok; + static int ok2; static struct GNUNET_STATISTICS_Handle *h; + static struct GNUNET_STATISTICS_Handle *h2; static GNUNET_SCHEDULER_TaskIdentifier shutdown_task; @@ -92,6 +86,7 @@ watch_1 (void *cls, const char *subsystem, const char *name, uint64_t value, return GNUNET_OK; } + static int watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, int is_persistent) @@ -121,6 +116,7 @@ watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, return GNUNET_OK; } + static void run (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -145,8 +141,8 @@ run (void *cls, char *const *args, const char *cfgfile, } -static int -check () +int +main (int argc, char *argv_ign[]) { char *const argv[] = { "test-statistics-api", "-c", @@ -156,23 +152,20 @@ check () struct GNUNET_GETOPT_CommandLineOption options[] = { GNUNET_GETOPT_OPTION_END }; -#if START_SERVICE struct GNUNET_OS_Process *proc; + char *binary; + binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-statistics"); proc = - GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, "gnunet-service-statistics", - "gnunet-service-statistics", -#if VERBOSE - "-L", "DEBUG", -#endif - "-c", "test_statistics_api_data.conf", NULL); -#endif + GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, + binary, + "gnunet-service-statistics", + "-c", "test_statistics_api_data.conf", NULL); GNUNET_assert (NULL != proc); ok = 3; ok2 = 1; GNUNET_PROGRAM_run (3, argv, "test-statistics-api", "nohelp", options, &run, NULL); -#if START_SERVICE if (0 != GNUNET_OS_process_kill (proc, SIGTERM)) { GNUNET_log_strerror (GNUNET_ERROR_TYPE_WARNING, "kill"); @@ -181,21 +174,10 @@ check () GNUNET_OS_process_wait (proc); GNUNET_OS_process_destroy (proc); proc = NULL; -#endif + GNUNET_free (binary); if ((0 == ok) && (0 == ok2)) return 0; - else - return 1; -} - -int -main (int argc, char *argv[]) -{ - int ret; - - ret = check (); - - return ret; + return 1; } /* end of test_statistics_api_watch_zero_value.c */ diff --git a/src/template/Makefile.am b/src/template/Makefile.am index 1769191e7..d1f87c8d8 100644 --- a/src/template/Makefile.am +++ b/src/template/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/src/include pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + dist_pkgcfg_DATA = \ template.conf @@ -14,7 +16,9 @@ if USE_COVERAGE endif bin_PROGRAMS = \ - gnunet-template \ + gnunet-template + +libexec_PROGRAMS = \ gnunet-service-template gnunet_template_SOURCES = \ diff --git a/src/testbed/Makefile.am b/src/testbed/Makefile.am index e37d0ce11..c5f920b39 100644 --- a/src/testbed/Makefile.am +++ b/src/testbed/Makefile.am @@ -9,13 +9,17 @@ if USE_COVERAGE XLIB = -lgcov endif +libexecdir= $(pkglibdir)/libexec/ + pkgcfgdir= $(pkgdatadir)/config.d/ pkgcfg_DATA = \ testbed.conf +libexec_PROGRAMS = \ + gnunet-service-testbed + bin_PROGRAMS = \ - gnunet-service-testbed \ gnunet-helper-testbed noinst_PROGRAMS = \ diff --git a/src/testing/testing.c b/src/testing/testing.c index e7c840ec9..577657897 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -926,7 +926,7 @@ GNUNET_TESTING_peer_configure (struct GNUNET_TESTING_System *system, } peer = GNUNET_malloc (sizeof (struct GNUNET_TESTING_Peer)); peer->cfgfile = config_filename; /* Free in peer_destroy */ - peer->main_binary = GNUNET_strdup ("gnunet-service-arm"); + peer->main_binary = GNUNET_OS_get_libexec_binary_path ("gnunet-service-arm"); peer->system = system; peer->key_number = key_number; return peer; @@ -1127,6 +1127,7 @@ GNUNET_TESTING_service_run (const char *testdir, struct GNUNET_TESTING_System *system; struct GNUNET_TESTING_Peer *peer; struct GNUNET_CONFIGURATION_Handle *cfg; + char *binary; GNUNET_log_setup (testdir, "WARNING", NULL); system = GNUNET_TESTING_system_create (testdir, "127.0.0.1", NULL); @@ -1150,7 +1151,9 @@ GNUNET_TESTING_service_run (const char *testdir, return 1; } GNUNET_free (peer->main_binary); - GNUNET_asprintf (&peer->main_binary, "gnunet-service-%s", service_name); + GNUNET_asprintf (&binary, "gnunet-service-%s", service_name); + peer->main_binary = GNUNET_OS_get_libexec_binary_path (binary); + GNUNET_free (binary); if (GNUNET_OK != GNUNET_TESTING_peer_start (peer)) { GNUNET_TESTING_peer_destroy (peer); diff --git a/src/topology/Makefile.am b/src/topology/Makefile.am index 91c21da12..91a5384f7 100644 --- a/src/topology/Makefile.am +++ b/src/topology/Makefile.am @@ -6,11 +6,13 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + dist_pkgcfg_DATA = \ topology.conf -bin_PROGRAMS = \ +libexec_PROGRAMS = \ gnunet-daemon-topology gnunet_daemon_topology_SOURCES = \ diff --git a/src/transport/Makefile.am b/src/transport/Makefile.am index b8d220e72..c89e6d42f 100644 --- a/src/transport/Makefile.am +++ b/src/transport/Makefile.am @@ -4,6 +4,8 @@ plugindir = $(libdir)/gnunet pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + pkgcfg_DATA = \ transport.conf @@ -59,7 +61,7 @@ endif if LINUX install-exec-hook: - $(top_srcdir)/src/transport/install-wlan-helper.sh $(bindir) $(SUDO_BINARY) || true + $(top_srcdir)/src/transport/install-wlan-helper.sh $(libexecdir) $(SUDO_BINARY) || true else install-exec-hook: endif @@ -107,11 +109,13 @@ libgnunettransport_la_LDFLAGS = \ $(GN_LIB_LDFLAGS) $(WINFLAGS) \ -version-info 1:0:0 -bin_PROGRAMS = \ - gnunet-transport \ +libexec_PROGRAMS = \ $(WLAN_BIN) \ $(WLAN_BIN_DUMMY) \ - gnunet-service-transport \ + gnunet-service-transport + +bin_PROGRAMS = \ + gnunet-transport \ gnunet-transport-certificate-creation #bin_SCRIPTS = \ diff --git a/src/util/Makefile.am b/src/util/Makefile.am index 7983d61db..6da3b8d27 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -2,6 +2,8 @@ INCLUDES = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include plugindir = $(libdir)/gnunet +libexecdir= $(pkglibdir)/libexec/ + pkgcfgdir= $(pkgdatadir)/config.d/ dist_pkgcfg_DATA = \ @@ -120,8 +122,10 @@ libgnunetutil_la_LDFLAGS = \ -version-info 8:0:0 +libexec_PROGRAMS = \ + gnunet-service-resolver + bin_PROGRAMS = \ - gnunet-service-resolver \ gnunet-resolver \ gnunet-config \ gnunet-ecc \ diff --git a/src/util/helper.c b/src/util/helper.c index 03e71585c..c0681c804 100644 --- a/src/util/helper.c +++ b/src/util/helper.c @@ -131,7 +131,7 @@ struct GNUNET_HELPER_Handle /** * Binary to run. */ - const char *binary_name; + char *binary_name; /** * NULL-terminated list of command-line arguments. @@ -411,18 +411,17 @@ GNUNET_HELPER_start (int with_control_pipe, void *cb_cls) { struct GNUNET_HELPER_Handle*h; - int c = 0; - h = GNUNET_malloc (sizeof (struct GNUNET_HELPER_Handle)); - h->with_control_pipe = with_control_pipe; - h->binary_name = GNUNET_strdup (binary_name); + unsigned int c; - for (c = 0; binary_argv[c] != NULL; c++) - c ++; - h->binary_argv = GNUNET_malloc (sizeof (char *[c + 1])); - for (c = 0; binary_argv[c] != NULL; c++) + h = GNUNET_malloc (sizeof (struct GNUNET_HELPER_Handle)); + h->with_control_pipe = with_control_pipe; + h->binary_name = GNUNET_OS_get_libexec_binary_path (binary_name); + for (c = 0; NULL != binary_argv[c]; c++) + c++; + h->binary_argv = GNUNET_malloc (sizeof (char *) * (c + 1)); + for (c = 0; NULL != binary_argv[c]; c++) h->binary_argv[c] = GNUNET_strdup (binary_argv[c]); h->binary_argv[c] = NULL; - h->cb_cls = cb_cls; h->mst = GNUNET_SERVER_mst_create (cb, h->cb_cls); h->exp_cb = exp_cb; @@ -440,7 +439,8 @@ void GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h) { struct GNUNET_HELPER_SendHandle *sh; - int c; + unsigned int c; + h->exp_cb = NULL; /* signal pending writes that we were stopped */ while (NULL != (sh = h->sh_head)) @@ -454,7 +454,7 @@ GNUNET_HELPER_stop (struct GNUNET_HELPER_Handle *h) } stop_helper (h); GNUNET_SERVER_mst_destroy (h->mst); - GNUNET_free ((char *) h->binary_name); + GNUNET_free (h->binary_name); for (c = 0; h->binary_argv[c] != NULL; c++) GNUNET_free (h->binary_argv[c]); GNUNET_free (h->binary_argv); diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 1e51c1327..43feba87b 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -452,6 +452,11 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) DIR_SEPARATOR_STR "share" DIR_SEPARATOR_STR "doc" DIR_SEPARATOR_STR \ "gnunet" DIR_SEPARATOR_STR; break; + case GNUNET_OS_IPK_LIBEXECDIR: + dirname = + DIR_SEPARATOR_STR "lib" DIR_SEPARATOR_STR "gnunet" DIR_SEPARATOR_STR \ + "libexec" DIR_SEPARATOR_STR; + break; default: GNUNET_free (execpath); return NULL; @@ -463,6 +468,32 @@ GNUNET_OS_installation_get_path (enum GNUNET_OS_InstallationPathKind dirkind) } +/** + * Given the name of a gnunet-helper, gnunet-service or gnunet-daemon + * binary, try to prefix it with the libexec/-directory to get the + * full path. + * + * @param progname name of the binary + * @return full path to the binary, if possible, otherwise copy of 'progname' + */ +char * +GNUNET_OS_get_libexec_binary_path (const char *progname) +{ + char *libexecdir; + char *binary; + + libexecdir = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_LIBEXECDIR); + if (NULL == libexecdir) + return GNUNET_strdup (progname); + GNUNET_asprintf (&binary, + "%s%s", + libexecdir, + progname); + GNUNET_free (libexecdir); + return binary; +} + + /** * Check whether an executable exists and possibly * if the suid bit is set on the file. diff --git a/src/util/test_resolver_api.c b/src/util/test_resolver_api.c index b9ca81b0f..ea18629f4 100644 --- a/src/util/test_resolver_api.c +++ b/src/util/test_resolver_api.c @@ -22,11 +22,7 @@ * @brief testcase for resolver_api.c */ #include "platform.h" -#include "gnunet_common.h" -#include "gnunet_getopt_lib.h" -#include "gnunet_os_lib.h" -#include "gnunet_program_lib.h" -#include "gnunet_scheduler_lib.h" +#include "gnunet_util_lib.h" #include "gnunet_resolver_service.h" #include "resolver.h" @@ -356,7 +352,6 @@ main (int argc, char *argv[]) { int ok = 1 + 2 + 4 + 8; char *fn; - char *pfx; struct GNUNET_OS_Process *proc; char *const argvx[] = { "test-resolver-api", "-c", "test_resolver_api_data.conf", NULL @@ -367,10 +362,11 @@ main (int argc, char *argv[]) GNUNET_log_setup ("test-resolver-api", "WARNING", NULL); - pfx = GNUNET_OS_installation_get_path (GNUNET_OS_IPK_BINDIR); - GNUNET_asprintf (&fn, "%s%cgnunet-service-resolver", pfx, DIR_SEPARATOR); - GNUNET_free (pfx); - proc = GNUNET_OS_start_process (GNUNET_YES, GNUNET_OS_INHERIT_STD_OUT_AND_ERR, NULL, NULL, fn, "gnunet-service-resolver", + fn = GNUNET_OS_get_libexec_binary_path ("gnunet-service-resolver"); + proc = GNUNET_OS_start_process (GNUNET_YES, + GNUNET_OS_INHERIT_STD_OUT_AND_ERR, + NULL, NULL, fn, + "gnunet-service-resolver", "-c", "test_resolver_api_data.conf", NULL); GNUNET_assert (NULL != proc); GNUNET_free (fn); diff --git a/src/vpn/Makefile.am b/src/vpn/Makefile.am index e7802bc9a..453b3b908 100644 --- a/src/vpn/Makefile.am +++ b/src/vpn/Makefile.am @@ -10,6 +10,8 @@ endif pkgcfgdir= $(pkgdatadir)/config.d/ +libexecdir= $(pkglibdir)/libexec/ + plugindir = $(libdir)/gnunet pkgcfg_DATA = \ @@ -18,7 +20,7 @@ pkgcfg_DATA = \ if LINUX VPNBIN = gnunet-helper-vpn install-exec-hook: - $(top_srcdir)/src/vpn/install-vpn-helper.sh $(bindir) $(SUDO_BINARY) || true + $(top_srcdir)/src/vpn/install-vpn-helper.sh $(libexecdir) $(SUDO_BINARY) || true else install-exec-hook: endif @@ -28,8 +30,12 @@ lib_LTLIBRARIES = \ libgnunetvpn.la +libexec_PROGRAMS = \ + $(VPNBIN) \ + gnunet-service-vpn + bin_PROGRAMS = \ - $(VPNBIN) gnunet-service-vpn gnunet-vpn + gnunet-vpn gnunet_helper_vpn_SOURCES = \ gnunet-helper-vpn.c -- cgit v1.2.3