From 2032baa561c7fefbe2605f5d6b979a295a61637d Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Wed, 9 Oct 2013 10:05:42 +0000 Subject: migrating towards XDG configuration specification (#3000) --- README | 1 + src/arm/arm.conf.in | 3 +- src/arm/gnunet-arm.c | 22 ++-- src/arm/test_arm_api_data.conf | 1 - src/ats/ats.conf.in | 1 - src/ats/test_ats_api.conf | 1 - src/ats/test_ats_mlp.conf | 1 - src/consensus/consensus.conf.in | 1 - src/consensus/test_consensus.conf | 1 - src/conversation/conversation.conf.in | 1 - src/core/core.conf.in | 3 +- src/core/test_core_api_send_to_self.conf | 1 - src/datastore/datastore.conf.in | 7 +- src/dht/dht.conf.in | 1 - src/dns/dns.conf.in | 1 - src/dv/dv.conf.in | 1 - src/experimentation/experimentation.conf.in | 3 +- src/fs/fs.conf.in | 16 ++- src/fs/test_pseudonym_data.conf | 1 - src/gns/gns.conf.in | 7 +- src/gns/test_gns_simple_lookup.conf | 2 - src/hostlist/hostlist.conf | 1 - src/identity/identity.conf.in | 5 +- src/include/gnunet_configuration_lib.h | 9 +- src/include/gnunet_crypto_lib.h | 2 +- src/include/gnunet_disk_lib.h | 19 --- src/mesh/mesh.conf.in | 1 - src/multicast/multicast.conf.in | 1 - src/namestore/namestore.conf.in | 6 +- src/nat/test_nat_data.conf | 4 - src/nse/nse.conf.in | 7 +- src/peerinfo/peerinfo.conf.in | 7 +- src/psyc/psyc.conf.in | 1 - src/psyc/test_psyc.conf | 1 - src/psycstore/psycstore.conf.in | 3 +- src/psycstore/test_psycstore.conf | 1 - src/regex/regex.conf.in | 1 - src/revocation/revocation.conf.in | 3 +- src/scalarproduct/scalarproduct.conf.in | 1 - src/set/set.conf.in | 1 - src/set/test_set.conf | 1 - src/statistics/gnunet-service-statistics.c | 36 ++++-- src/statistics/statistics.conf.in | 1 - src/template/template.conf | 1 - src/testbed/gnunet-daemon-testbed-blacklist.c | 2 +- src/testbed/test_testbed_api_barriers.conf.in | 3 - src/testbed/testbed.conf.in | 1 - src/testing/testing.c | 43 +++---- src/transport/plugin_transport_http_server.c | 58 ++++----- src/transport/transport.conf.in | 17 ++- src/util/configuration.c | 174 +++++++++++++++++++++----- src/util/disk.c | 72 ----------- src/util/os_installation.c | 21 ++-- src/util/resolver.conf.in | 1 - src/util/test_disk.c | 22 ---- src/util/util.conf | 31 ++++- src/vpn/vpn.conf.in | 1 - 57 files changed, 307 insertions(+), 328 deletions(-) diff --git a/README b/README index b9777f625..f3d57a4f3 100644 --- a/README +++ b/README @@ -46,6 +46,7 @@ These are the direct dependencies for running GNUnet: - libunistring >= 0.9.2 - gnutls >= 2.12.0 - libidn >= 1.0 +- libglpk >= 4.45 - openssl >= 1.0 (binary, used to generate X.509 certificate) - libltdl >= 2.2 (part of GNU libtool) - sqlite >= 3.8 (default database, required) diff --git a/src/arm/arm.conf.in b/src/arm/arm.conf.in index b9a33242f..1b079c98c 100644 --- a/src/arm/arm.conf.in +++ b/src/arm/arm.conf.in @@ -2,7 +2,6 @@ [arm] @UNIXONLY@ PORT = 2087 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-arm ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -16,7 +15,7 @@ UNIX_MATCH_GID = YES # service. Thus the following option would introduce per-service # logging with a new log file each day. Note that only the last 3 # log files are preserved. -# GLOBAL_POSTFIX = -l $SERVICEHOME/{}-%Y-%m-%d.log +# GLOBAL_POSTFIX = -l $GNUNET_CACHE_HOME/{}-%Y-%m-%d.log GLOBAL_PREFIX = @MONKEYPREFIX@ # USERNAME = # MAXBUF = diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index 80d3e9c03..a492fac5b 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c @@ -147,7 +147,7 @@ static unsigned int no_stderr; /** - * Attempts to delete configuration file and SERVICEHOME + * Attempts to delete configuration file and GNUNET_HOME * on ARM shutdown provided the end and delete options * were specified when gnunet-arm was run. */ @@ -158,15 +158,17 @@ delete_files () "Will attempt to remove configuration file %s and service directory %s\n", config_file, dir); - if (UNLINK (config_file) != 0) + if (0 != UNLINK (config_file)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Failed to remove configuration file %s\n"), config_file); + _("Failed to remove configuration file %s\n"), + config_file); } - if (GNUNET_DISK_directory_remove (dir) != GNUNET_OK) + if (GNUNET_OK != GNUNET_DISK_directory_remove (dir)) { GNUNET_log (GNUNET_ERROR_TYPE_WARNING, - _("Failed to remove servicehome directory %s\n"), dir); + _("Failed to remove servicehome directory %s\n"), + dir); } } @@ -192,8 +194,8 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) GNUNET_ARM_monitor_disconnect_and_free (m); m = NULL; } - if ((end == GNUNET_YES) && (delete == GNUNET_YES)) - delete_files (); + if ((GNUNET_YES == end) && (GNUNET_YES == delete)) + delete_files (); GNUNET_CONFIGURATION_destroy (cfg); cfg = NULL; } @@ -588,7 +590,7 @@ action_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) if (list) { GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, - "Going to list all running services controlled by ARM.\n"); + "Going to list all running services controlled by ARM.\n"); GNUNET_ARM_request_service_list (h, (0 == timeout.rel_value_us) ? LIST_TIMEOUT : timeout, &list_callback, &list); @@ -673,10 +675,10 @@ run (void *cls, cfg = GNUNET_CONFIGURATION_dup (c); config_file = cfgfile; if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "SERVICEHOME", &dir)) + GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", "GNUNET_HOME", &dir)) { GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, - "PATHS", "SERVICEHOME"); + "PATHS", "GNUNET_HOME"); return; } if (NULL != cfgfile) diff --git a/src/arm/test_arm_api_data.conf b/src/arm/test_arm_api_data.conf index 157a03027..1f1ac282f 100644 --- a/src/arm/test_arm_api_data.conf +++ b/src/arm/test_arm_api_data.conf @@ -16,7 +16,6 @@ PORT = 23355 AUTOSTART = NO PORT = 2223 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = /will/be/overwritten/by/test_exponential_backoff ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/ats/ats.conf.in b/src/ats/ats.conf.in index 457e86c65..d5116304f 100644 --- a/src/ats/ats.conf.in +++ b/src/ats/ats.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @UNIXONLY@ PORT = 2098 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-ats ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/ats/test_ats_api.conf b/src/ats/test_ats_api.conf index 5601a1227..8a1b6a14f 100644 --- a/src/ats/test_ats_api.conf +++ b/src/ats/test_ats_api.conf @@ -11,7 +11,6 @@ UNIXPATH = /tmp/test-ats-scheduling-arm.sock AUTOSTART = YES PORT = 12002 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-ats ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/ats/test_ats_mlp.conf b/src/ats/test_ats_mlp.conf index f64c783f6..05e444f09 100644 --- a/src/ats/test_ats_mlp.conf +++ b/src/ats/test_ats_mlp.conf @@ -11,7 +11,6 @@ UNIXPATH = /tmp/test-ats-scheduling-arm.sock AUTOSTART = YES PORT = 12002 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-ats ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/consensus/consensus.conf.in b/src/consensus/consensus.conf.in index 18e976deb..de526305c 100644 --- a/src/consensus/consensus.conf.in +++ b/src/consensus/consensus.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @UNIXONLY@ PORT = 2103 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-consensus ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/consensus/test_consensus.conf b/src/consensus/test_consensus.conf index bcfdaba0f..a59a1012a 100644 --- a/src/consensus/test_consensus.conf +++ b/src/consensus/test_consensus.conf @@ -2,7 +2,6 @@ AUTOSTART = YES PORT = 2110 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-consensus #PREFIX = gdbserver :12345 #PREFIX = valgrind --leak-check=full diff --git a/src/conversation/conversation.conf.in b/src/conversation/conversation.conf.in index f1efa03ba..b4386e80d 100644 --- a/src/conversation/conversation.conf.in +++ b/src/conversation/conversation.conf.in @@ -2,6 +2,5 @@ AUTOSTART = YES BINARY = gnunet-service-conversation UNIXPATH = /tmp/gnunet-service-conversation.sock -HOME = $SERVICEHOME @UNIXONLY@ PORT = 2106 diff --git a/src/core/core.conf.in b/src/core/core.conf.in index 839c21eeb..f8e71957a 100644 --- a/src/core/core.conf.in +++ b/src/core/core.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @JAVAPORT@PORT = 2092 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-core ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -21,4 +20,4 @@ UNIX_MATCH_GID = YES # Note: this MUST be set to YES in production, only set to NO for testing # for performance (testbed/cluster-scale use!). -USE_EPHEMERAL_KEYS = YES \ No newline at end of file +USE_EPHEMERAL_KEYS = YES diff --git a/src/core/test_core_api_send_to_self.conf b/src/core/test_core_api_send_to_self.conf index 704a2b6da..8df557226 100644 --- a/src/core/test_core_api_send_to_self.conf +++ b/src/core/test_core_api_send_to_self.conf @@ -20,7 +20,6 @@ UNIXPATH = /tmp/gnunet-p1-service-ats.sock AUTOSTART = YES PORT = 9252 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = test_core_api_send_to_self ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/datastore/datastore.conf.in b/src/datastore/datastore.conf.in index 7a92070d7..7d9efff6e 100644 --- a/src/datastore/datastore.conf.in +++ b/src/datastore/datastore.conf.in @@ -5,17 +5,16 @@ UNIX_MATCH_UID = NO UNIX_MATCH_GID = YES @UNIXONLY@ PORT = 2093 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-datastore ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; QUOTA = 5 GB -BLOOMFILTER = $SERVICEHOME/datastore/bloomfilter +BLOOMFILTER = $GNUNET_DATA_HOME/datastore/bloomfilter DATABASE = sqlite # DISABLE_SOCKET_FORWARDING = NO [datastore-sqlite] -FILENAME = $SERVICEHOME/datastore/sqlite.db +FILENAME = $GNUNET_DATA_HOME/datastore/sqlite.db [datastore-postgres] CONFIG = connect_timeout=10; dbname=gnunet @@ -24,7 +23,7 @@ CONFIG = connect_timeout=10; dbname=gnunet DATABASE = gnunet CONFIG = ~/.my.cnf # USER = gnunet -# PASSWORD = +# PASSWORD = # HOST = localhost # PORT = 3306 diff --git a/src/dht/dht.conf.in b/src/dht/dht.conf.in index 59c5bc1b7..7a9781a3a 100644 --- a/src/dht/dht.conf.in +++ b/src/dht/dht.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @JAVAPORT@PORT = 2095 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-dht ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/dns/dns.conf.in b/src/dns/dns.conf.in index 7944b410a..ee9a65302 100644 --- a/src/dns/dns.conf.in +++ b/src/dns/dns.conf.in @@ -1,7 +1,6 @@ [dns] AUTOSTART = YES HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-dns UNIXPATH = /tmp/gnunet-service-dns.sock diff --git a/src/dv/dv.conf.in b/src/dv/dv.conf.in index c0dc21bfd..65f54613a 100644 --- a/src/dv/dv.conf.in +++ b/src/dv/dv.conf.in @@ -3,7 +3,6 @@ AUTOSTART = YES ACCEPT_FROM6 = ::1; ACCEPT_FROM = 127.0.0.1; BINARY = gnunet-service-dv -HOME = $SERVICEHOME HOSTNAME = localhost @UNIXONLY@ PORT = 2571 UNIXPATH = /tmp/gnunet-service-dv.sock diff --git a/src/experimentation/experimentation.conf.in b/src/experimentation/experimentation.conf.in index 6597dd0c1..5bfffad86 100644 --- a/src/experimentation/experimentation.conf.in +++ b/src/experimentation/experimentation.conf.in @@ -2,11 +2,10 @@ AUTOSTART = NO # PORT = 2106 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-daemon-experimentation ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; UNIXPATH = /tmp/gnunet-daemon-experimentation.sock UNIX_MATCH_UID = YES UNIX_MATCH_GID = YES -ISSUERS = TFRM29O2RQNKLVBQIGODJ6GD58LSQ2NM9TNFBC6N48BRJHQO38Q73N2OM3V4CLKDM6CILQV4CU8PMJDRG0FNB0PDI057DBRANMLPLRG \ No newline at end of file +ISSUERS = TFRM29O2RQNKLVBQIGODJ6GD58LSQ2NM9TNFBC6N48BRJHQO38Q73N2OM3V4CLKDM6CILQV4CU8PMJDRG0FNB0PDI057DBRANMLPLRG diff --git a/src/fs/fs.conf.in b/src/fs/fs.conf.in index 2375dc7ec..bb4cae99a 100644 --- a/src/fs/fs.conf.in +++ b/src/fs/fs.conf.in @@ -1,13 +1,11 @@ [fs] AUTOSTART = YES -INDEXDB = $SERVICEHOME/fs/idxinfo.lst -RESPECT = $SERVICEHOME/fs/credit/ -IDENTITY_DIR = $SERVICEHOME/fs/identities/ -STATE_DIR = $SERVICEHOME/fs/persistence/ -UPDATE_DIR = $SERVICEHOME/fs/updates/ +INDEXDB = $GNUNET_DATA_HOME/fs/idxinfo.lst +RESPECT = $GNUNET_DATA_HOME/fs/credit/ +STATE_DIR = $GNUNET_DATA_HOME/fs/persistence/ +UPDATE_DIR = $GNUNET_DATA_HOME/fs/updates/ @UNIXONLY@ PORT = 2094 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-fs ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -24,7 +22,7 @@ CONTENT_PUSHING = YES UNIXPATH = /tmp/gnunet-service-fs.sock -# Do we require users that want to access file-sharing to run this process +# Do we require users that want to access file-sharing to run this process # (usually not a good idea) UNIX_MATCH_UID = NO @@ -40,7 +38,7 @@ MAX_PENDING_REQUESTS = 65536 DATASTORE_QUEUE_SIZE = 1024 # Maximum frequency we're allowed to poll the datastore -# for content for migration (can be used to reduce +# for content for migration (can be used to reduce # GNUnet's disk-IO rate) MIN_MIGRATION_DELAY = 100 ms @@ -65,4 +63,4 @@ BINARY = gnunet-auto-share # Note: MUST specify path to auto-share directory and CAN specify other options # to gnunet-auto-share here! -OPTIONS = $SERVICEHOME/fs/share/ +OPTIONS = $GNUNET_DATA_HOME/fs/share/ diff --git a/src/fs/test_pseudonym_data.conf b/src/fs/test_pseudonym_data.conf index 837908e51..5827721b8 100644 --- a/src/fs/test_pseudonym_data.conf +++ b/src/fs/test_pseudonym_data.conf @@ -1,6 +1,5 @@ # General settings [fs] -HOME = "/tmp/gnunet-pseudonym-test" [TESTING] WEAKRANDOM = YES diff --git a/src/gns/gns.conf.in b/src/gns/gns.conf.in index 5529db201..99f7dcc54 100644 --- a/src/gns/gns.conf.in +++ b/src/gns/gns.conf.in @@ -1,14 +1,11 @@ [gns] AUTOSTART = YES HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-gns UNIXPATH = /tmp/gnunet-service-gns.sock @UNIXONLY@PORT = 2102 -ZONE_DIR = $SERVICEHOME/gns/ - -# Do we require users that want to access GNS to run this process +# Do we require users that want to access GNS to run this process # (usually not a good idea) UNIX_MATCH_UID = NO @@ -28,7 +25,7 @@ BINARY = gnunet-gns-proxy AUTOSTART = NO # Where is the certificate for the GNS proxy stored? -PROXY_CACERT = $SERVICEHOME/gns/gnsCAcert.pem +PROXY_CACERT = $GNUNET_DATA_HOME/gns/gns_ca_cert.pem PROXY_UNIXPATH = /tmp/gnunet-gns-proxy.sock diff --git a/src/gns/test_gns_simple_lookup.conf b/src/gns/test_gns_simple_lookup.conf index 687dff71e..c7f9f7132 100644 --- a/src/gns/test_gns_simple_lookup.conf +++ b/src/gns/test_gns_simple_lookup.conf @@ -70,7 +70,6 @@ SHORTEN_ZONEKEY = zonefiles/188JSUMKEF25GVU8TTV0PBNNN8JVCPUEDFV1UHJJU884JD25V0T0 #ZONEKEY = $SERVICEHOME/gns/zonekey.zkey HIJACK_DNS = NO UNIXPATH = /tmp/gnunet-service-gns.sock -HOME = $SERVICEHOME AUTO_IMPORT_PKEY = YES MAX_PARALLEL_BACKGROUND_QUERIES = 10 DEFAULT_LOOKUP_TIMEOUT = 15 s @@ -89,7 +88,6 @@ UNIXPATH = /tmp/gnunet-service-namestore-default.sock UNIX_MATCH_UID = YES UNIX_MATCH_GID = YES HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-namestore ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/hostlist/hostlist.conf b/src/hostlist/hostlist.conf index 278c35f8c..40e7c7f7e 100644 --- a/src/hostlist/hostlist.conf +++ b/src/hostlist/hostlist.conf @@ -1,7 +1,6 @@ [hostlist] # port for hostlist http server HTTPPORT = 8080 -HOME = $SERVICEHOME HOSTLISTFILE = $SERVICEHOME/hostlist/learned.data BINARY = gnunet-daemon-hostlist # consider having "-e" as default as well once implemented diff --git a/src/identity/identity.conf.in b/src/identity/identity.conf.in index 621b601fb..1b68775b9 100644 --- a/src/identity/identity.conf.in +++ b/src/identity/identity.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @JAVAPORT@PORT = 2108 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-identity ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -11,7 +10,7 @@ UNIX_MATCH_UID = NO UNIX_MATCH_GID = YES # Directory where we store information about our egos -EGODIR = $SERVICEHOME/egos/ +EGODIR = $GNUNET_DATA_HOME/identity/egos/ # File where we store default identities for subsystems -SUBSYSTEM_CFG = $SERVICEHOME/subsystem_defaults.conf +SUBSYSTEM_CFG = $GNUNET_CONFIG_HOME/identity/subsystem_defaults.conf diff --git a/src/include/gnunet_configuration_lib.h b/src/include/gnunet_configuration_lib.h index 08cf1558a..6d0c04dbb 100644 --- a/src/include/gnunet_configuration_lib.h +++ b/src/include/gnunet_configuration_lib.h @@ -415,8 +415,13 @@ GNUNET_CONFIGURATION_get_value_yesno (const struct GNUNET_CONFIGURATION_Handle /** * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" - * where either in the "PATHS" section or the environtment - * "FOO" is set to "DIRECTORY". + * where either in the "PATHS" section or the environtment "FOO" is + * set to "DIRECTORY". We also support default expansion, + * i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is + * set in PATHS or the environment, and otherwise to "default". Note + * that "default" itself can also be a $-expression, thus + * "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined + * to VAR2. * * @param cfg configuration to use for path expansion * @param orig string to $-expand (will be freed!) diff --git a/src/include/gnunet_crypto_lib.h b/src/include/gnunet_crypto_lib.h index c9cae17a2..bd1a2f3bf 100644 --- a/src/include/gnunet_crypto_lib.h +++ b/src/include/gnunet_crypto_lib.h @@ -963,7 +963,7 @@ GNUNET_CRYPTO_ecc_key_get_anonymous (void); * configuration file (!). This function is used so that * at a later point code can be certain that reading a * hostkey is fast (for example in time-dependent testcases). - * +* * @param cfg_name name of the configuration file to use */ void diff --git a/src/include/gnunet_disk_lib.h b/src/include/gnunet_disk_lib.h index bf49b71f8..f6aa3d070 100644 --- a/src/include/gnunet_disk_lib.h +++ b/src/include/gnunet_disk_lib.h @@ -797,25 +797,6 @@ int GNUNET_DISK_file_change_owner (const char *filename, const char *user); -/** - * Construct full path to a file inside of the private - * directory used by GNUnet. Also creates the corresponding - * directory. If the resulting name is supposed to be - * a directory, end the last argument in '/' (or pass - * DIR_SEPARATOR_STR as the last argument before NULL). - * - * @param cfg configuration to use - * @param service_name name of the service asking - * @param ... is NULL-terminated list of - * path components to append to the - * private directory name. - * @return the constructed filename - */ -char * -GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *service_name, ...); - - /** * Opaque handle for a memory-mapping operation. */ diff --git a/src/mesh/mesh.conf.in b/src/mesh/mesh.conf.in index 504e2ecb1..39ede6750 100644 --- a/src/mesh/mesh.conf.in +++ b/src/mesh/mesh.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @JAVAPORT@PORT = 2096 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-mesh ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/multicast/multicast.conf.in b/src/multicast/multicast.conf.in index bd37cb474..65299cecf 100644 --- a/src/multicast/multicast.conf.in +++ b/src/multicast/multicast.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES PORT = 2109 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-multicast ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/namestore/namestore.conf.in b/src/namestore/namestore.conf.in index 2d92f2e7b..91dbaabad 100644 --- a/src/namestore/namestore.conf.in +++ b/src/namestore/namestore.conf.in @@ -5,15 +5,13 @@ UNIX_MATCH_UID = NO UNIX_MATCH_GID = YES @UNIXONLY@ PORT = 2099 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-namestore ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; DATABASE = sqlite -ZONEFILE_DIRECTORY = $SERVICEHOME/zones/ [namestore-sqlite] -FILENAME = $SERVICEHOME/namestore/sqlite.db +FILENAME = $GNUNET_DATA_HOME/namestore/sqlite.db [namestore-postgres] CONFIG = connect_timeout=10; dbname=gnunet @@ -31,6 +29,4 @@ AUTOSTART = NO # On what port does the FCFS daemon listen for HTTP clients? HTTPPORT = 18080 -# Where is the zone key for the FCFS zone stored? -ZONEKEY = $SERVICEHOME/fcfsd/zonekey.zkey diff --git a/src/nat/test_nat_data.conf b/src/nat/test_nat_data.conf index 9314e066a..03467d1e6 100644 --- a/src/nat/test_nat_data.conf +++ b/src/nat/test_nat_data.conf @@ -11,7 +11,6 @@ HOSTKEY = $SERVICEHOME/.hostkey WEAKRANDOM = NO [client] -HOME = $SERVICEHOME [nat] @@ -48,7 +47,6 @@ DISABLEV6 = NO [arm] PORT = 2087 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-arm ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -71,7 +69,6 @@ UNIX_MATCH_GID = YES AUTOSTART = YES PORT = 2088 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-statistics ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -92,7 +89,6 @@ UNIX_MATCH_GID = YES AUTOSTART = YES PORT = 2089 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-resolver ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/nse/nse.conf.in b/src/nse/nse.conf.in index c96830c42..fbc272235 100644 --- a/src/nse/nse.conf.in +++ b/src/nse/nse.conf.in @@ -2,19 +2,18 @@ AUTOSTART = YES @JAVAPORT@PORT = 2097 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-nse ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; UNIXPATH = /tmp/gnunet-service-nse.unix UNIX_MATCH_UID = NO UNIX_MATCH_GID = YES -PROOFFILE = $SERVICEHOME/.nse-proof +PROOFFILE = $GNUNET_DATA_HOME/nse/proof.dat -# The directory where the NSE services logs timestamps everytime +# The directory where the NSE services logs timestamps everytime # a size estime flooding message is received # This option is only used for benchmarking, not in production. -HISTOGRAM_DIR = $SERVICEHOME +HISTOGRAM_DIR = $GNUNET_CACHE_HOME/nse/histogram/ # How 'slowly' should the proof-of-work be constructed (delay # between rounds); sane values between 0 and ~1000. diff --git a/src/peerinfo/peerinfo.conf.in b/src/peerinfo/peerinfo.conf.in index 11302211d..560400498 100644 --- a/src/peerinfo/peerinfo.conf.in +++ b/src/peerinfo/peerinfo.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @JAVAPORT@PORT = 2090 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-peerinfo ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -10,15 +9,15 @@ UNIXPATH = /tmp/gnunet-service-peerinfo.sock UNIX_MATCH_UID = NO UNIX_MATCH_GID = YES # DISABLE_SOCKET_FORWARDING = NO -# USERNAME = +# USERNAME = # MAXBUF = # TIMEOUT = # DISABLEV6 = -# BINDTO = +# BINDTO = # REJECT_FROM = # REJECT_FROM6 = # PREFIX = -HOSTS = $SERVICEHOME/peerinfo/ +HOSTS = $GNUNET_DATA_HOME/peerinfo/hosts/ # Option to disable all disk IO; only useful for testbed runs # (large-scale experiments); disables persistence of HELLOs! diff --git a/src/psyc/psyc.conf.in b/src/psyc/psyc.conf.in index 5a1eebf61..7dfeb0d97 100644 --- a/src/psyc/psyc.conf.in +++ b/src/psyc/psyc.conf.in @@ -1,6 +1,5 @@ [psyc] AUTOSTART = YES -HOME = $SERVICEHOME BINARY = gnunet-service-psyc UNIXPATH = /tmp/gnunet-service-psyc.sock UNIX_MATCH_UID = NO diff --git a/src/psyc/test_psyc.conf b/src/psyc/test_psyc.conf index b5d3fd3fc..da2dde680 100644 --- a/src/psyc/test_psyc.conf +++ b/src/psyc/test_psyc.conf @@ -4,7 +4,6 @@ DEFAULTSERVICES = psyc [psyc] AUTOSTART = YES -HOME = $SERVICEHOME BINARY = gnunet-service-psyc UNIXPATH = /tmp/test-gnunet-service-psyc.sock UNIX_MATCH_UID = NO diff --git a/src/psycstore/psycstore.conf.in b/src/psycstore/psycstore.conf.in index c43c5158e..98c6aeda8 100644 --- a/src/psycstore/psycstore.conf.in +++ b/src/psycstore/psycstore.conf.in @@ -1,6 +1,5 @@ [psycstore] AUTOSTART = YES -HOME = $SERVICEHOME BINARY = gnunet-service-psycstore UNIXPATH = /tmp/gnunet-service-psycstore.sock @UNIXONLY@PORT = 2111 @@ -9,4 +8,4 @@ UNIX_MATCH_GID = YES DATABASE = sqlite [psycstore-sqlite] -FILENAME = $SERVICEHOME/psycstore/sqlite.db +FILENAME = $GNUNET_DATA_HOME/psycstore/sqlite.db diff --git a/src/psycstore/test_psycstore.conf b/src/psycstore/test_psycstore.conf index a7d334617..c524f2ae6 100644 --- a/src/psycstore/test_psycstore.conf +++ b/src/psycstore/test_psycstore.conf @@ -4,7 +4,6 @@ DEFAULTSERVICES = psycstore [psycstore] AUTOSTART = YES -HOME = $SERVICEHOME BINARY = gnunet-service-psycstore UNIXPATH = /tmp/test-gnunet-service-psycstore.sock UNIX_MATCH_UID = NO diff --git a/src/regex/regex.conf.in b/src/regex/regex.conf.in index 2ff48c5ae..59376a61e 100644 --- a/src/regex/regex.conf.in +++ b/src/regex/regex.conf.in @@ -3,7 +3,6 @@ AUTOSTART = YES @UNIXONLY@ PORT = 2107 UNIXPATH = /tmp/gnunet-service-regex.sock HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-regex ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/revocation/revocation.conf.in b/src/revocation/revocation.conf.in index d179c1629..6e84b84d6 100644 --- a/src/revocation/revocation.conf.in +++ b/src/revocation/revocation.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @JAVAPORT@PORT = 2112 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-revocation ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; @@ -15,4 +14,4 @@ UNIX_MATCH_GID = YES # DO NOT CHANGE THIS VALUE, doing so will break the protocol! WORKBITS = 25 -DATABASE = $SERVICEHOME/revocation.db +DATABASE = $GNUNET_DATA_HOME/revocation.dat diff --git a/src/scalarproduct/scalarproduct.conf.in b/src/scalarproduct/scalarproduct.conf.in index e47af6f6a..064b7fd8c 100644 --- a/src/scalarproduct/scalarproduct.conf.in +++ b/src/scalarproduct/scalarproduct.conf.in @@ -1,7 +1,6 @@ [vectorproduct] BINARY = gnunet-service-vectorproduct UNIXPATH = /tmp/gnunet-service-vectorproduct.sock -HOME = $SERVICEHOME # PORT = 2106 @UNIXONLY@ PORT = 2087 diff --git a/src/set/set.conf.in b/src/set/set.conf.in index 2dc1c21d2..81e11cff0 100644 --- a/src/set/set.conf.in +++ b/src/set/set.conf.in @@ -2,7 +2,6 @@ AUTOSTART = NO @UNIXONLY@PORT = 2106 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-set ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/set/test_set.conf b/src/set/test_set.conf index 6bac3a55e..0eeb1cb72 100644 --- a/src/set/test_set.conf +++ b/src/set/test_set.conf @@ -6,7 +6,6 @@ SERVICEHOME = /tmp/test-gnunet-set/ AUTOSTART = YES PORT = 2106 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-set #PREFIX = valgrind #PREFIX = gdbserver :1234 diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index acf2a965f..6c3d173c4 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c @@ -241,11 +241,20 @@ load (struct GNUNET_SERVER_Handle *server) struct GNUNET_SERVER_MessageStreamTokenizer *mst; char *emsg; - fn = GNUNET_DISK_get_home_filename (cfg, "statistics", "statistics.data", - NULL); - if (fn == NULL) + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "STATISTICS", + "DATABASE", + &fn)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "STATISTICS", + "DATABASE"); return; - if ((GNUNET_OK != GNUNET_DISK_file_size (fn, &fsize, GNUNET_NO, GNUNET_YES)) || (fsize == 0)) + } + if ( (GNUNET_OK != + GNUNET_DISK_file_size (fn, &fsize, GNUNET_NO, GNUNET_YES)) || + (0 == fsize) ) { GNUNET_free (fn); return; @@ -291,15 +300,22 @@ save () struct StatsEntry *pos; char *fn; struct GNUNET_BIO_WriteHandle *wh; - uint16_t size; unsigned long long total; - wh = NULL; - fn = GNUNET_DISK_get_home_filename (cfg, "statistics", "statistics.data", - NULL); - if (fn != NULL) - wh = GNUNET_BIO_write_open (fn); + if (GNUNET_OK != + GNUNET_CONFIGURATION_get_value_filename (cfg, + "STATISTICS", + "DATABASE", + &fn)) + { + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + "STATISTICS", + "DATABASE"); + return; + } + (void) GNUNET_DISK_directory_create_for_file (fn); + wh = GNUNET_BIO_write_open (fn); total = 0; while (NULL != (pos = start)) { diff --git a/src/statistics/statistics.conf.in b/src/statistics/statistics.conf.in index 669e89bd7..b08c737f2 100644 --- a/src/statistics/statistics.conf.in +++ b/src/statistics/statistics.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @JAVAPORT@PORT = 2088 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-statistics ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/template/template.conf b/src/template/template.conf index 439bbd2e6..ac1479b48 100644 --- a/src/template/template.conf +++ b/src/template/template.conf @@ -2,7 +2,6 @@ AUTOSTART = NO PORT = 9999 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-template ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/testbed/gnunet-daemon-testbed-blacklist.c b/src/testbed/gnunet-daemon-testbed-blacklist.c index 6be43999c..55cd35e10 100644 --- a/src/testbed/gnunet-daemon-testbed-blacklist.c +++ b/src/testbed/gnunet-daemon-testbed-blacklist.c @@ -215,7 +215,7 @@ run (void *cls, char *const *args, const char *cfgfile, char fname[PATH_MAX]; if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_string (c, "PATHS", - "SERVICEHOME", + "GNUNET_HOME", &shome)) { GNUNET_break (0); diff --git a/src/testbed/test_testbed_api_barriers.conf.in b/src/testbed/test_testbed_api_barriers.conf.in index 5dd0dadcd..8255ba152 100644 --- a/src/testbed/test_testbed_api_barriers.conf.in +++ b/src/testbed/test_testbed_api_barriers.conf.in @@ -52,9 +52,6 @@ USE_EPHEMERAL_KEYS = NO TIMEOUT = 300 s PORT = 12368 -[gnunetd] -HOSTKEY = $SERVICEHOME/.hostkey - [PATHS] SERVICEHOME = /tmp/test-testbed/ diff --git a/src/testbed/testbed.conf.in b/src/testbed/testbed.conf.in index 40bdae16d..108142d5e 100644 --- a/src/testbed/testbed.conf.in +++ b/src/testbed/testbed.conf.in @@ -2,7 +2,6 @@ AUTOSTART = NO @JAVAPORT@ PORT = 2101 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-testbed # How long should operations wait? diff --git a/src/testing/testing.c b/src/testing/testing.c index c2033935d..a0d8e261b 100644 --- a/src/testing/testing.c +++ b/src/testing/testing.c @@ -103,7 +103,8 @@ struct GNUNET_TESTING_System { /** * Prefix (i.e. "/tmp/gnunet-testing/") we prepend to each - * SERVICEHOME. */ + * GNUNET_HOME. + */ char *tmppath; /** @@ -747,7 +748,7 @@ struct UpdateContext /** * The customized service home path for this peer */ - char *service_home; + char *gnunet_home; /** * Array of ports currently allocated to this peer. These ports will be @@ -839,7 +840,7 @@ update_config (void *cls, const char *section, const char *option, single_variable)) { GNUNET_snprintf (uval, sizeof (uval), "%s/%s.sock", - uc->service_home, section); + uc->gnunet_home, section); value = uval; } else if ((GNUNET_YES == @@ -970,7 +971,7 @@ associate_shared_service (struct GNUNET_TESTING_System *system, { struct SharedServiceInstance *i; struct GNUNET_CONFIGURATION_Handle *temp; - char *service_home; + char *gnunet_home; uint32_t port; ss->n_peers++; @@ -979,25 +980,25 @@ associate_shared_service (struct GNUNET_TESTING_System *system, ( (0 != ss->share) && (ss->n_instances < ((ss->n_peers + ss->share - 1) / ss->share)) ) ) { - i = GNUNET_malloc (sizeof (struct SharedServiceInstance)); + i = GNUNET_new (struct SharedServiceInstance); i->ss = ss; - (void) GNUNET_asprintf (&service_home, "%s/shared/%s/%u", + (void) GNUNET_asprintf (&gnunet_home, "%s/shared/%s/%u", system->tmppath, ss->sname, ss->n_instances); - (void) GNUNET_asprintf (&i->unix_sock, "%s/sock", service_home); + (void) GNUNET_asprintf (&i->unix_sock, "%s/sock", gnunet_home); port = GNUNET_TESTING_reserve_port (system); if (0 == port) { - GNUNET_free (service_home); + GNUNET_free (gnunet_home); cleanup_shared_service_instance (i); return NULL; } GNUNET_array_append (ss->instances, ss->n_instances, i); temp = GNUNET_CONFIGURATION_dup (ss->cfg); (void) GNUNET_asprintf (&i->port_str, "%u", port); - (void) GNUNET_asprintf (&i->cfg_fn, "%s/config", service_home); - GNUNET_CONFIGURATION_set_value_string (temp, "PATHS", "SERVICEHOME", - service_home); - GNUNET_free (service_home); + (void) GNUNET_asprintf (&i->cfg_fn, "%s/config", gnunet_home); + GNUNET_CONFIGURATION_set_value_string (temp, "PATHS", "GNUNET_HOME", + gnunet_home); + GNUNET_free (gnunet_home); GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "UNIXPATH", i->unix_sock); GNUNET_CONFIGURATION_set_value_string (temp, ss->sname, "PORT", @@ -1029,9 +1030,9 @@ associate_shared_service (struct GNUNET_TESTING_System *system, * Create a new configuration using the given configuration as a template; * ports and paths will be modified to select available ports on the local * system. The default configuration will be available in PATHS section under - * the option DEFAULTCONFIG after the call. SERVICE_HOME is also set in PATHS + * the option DEFAULTCONFIG after the call. GNUNET_HOME is also set in PATHS * section to the temporary directory specific to this configuration. If we run - * out of "*port" numbers, return SYSERR. + * out of "*port" numbers, return #GNUNET_SYSERR. * * This is primarily a helper function used internally * by 'GNUNET_TESTING_peer_configure'. @@ -1041,7 +1042,7 @@ associate_shared_service (struct GNUNET_TESTING_System *system, * @param ports array with port numbers used in the created configuration. * Will be updated upon successful return. Can be NULL * @param nports the size of the `ports' array. Will be updated. - * @return GNUNET_OK on success, GNUNET_SYSERR on error - the configuration will + * @return #GNUNET_OK on success, #GNUNET_SYSERR on error - the configuration will * be incomplete and should not be used there upon */ static int @@ -1058,16 +1059,16 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system, uc.status = GNUNET_OK; uc.ports = NULL; uc.nports = 0; - GNUNET_asprintf (&uc.service_home, "%s/%u", system->tmppath, + GNUNET_asprintf (&uc.gnunet_home, "%s/%u", system->tmppath, system->path_counter++); - GNUNET_asprintf (&default_config, "%s/config", uc.service_home); + GNUNET_asprintf (&default_config, "%s/config", uc.gnunet_home); GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "DEFAULTCONFIG", default_config); GNUNET_CONFIGURATION_set_value_string (cfg, "arm", "CONFIG", default_config); GNUNET_free (default_config); - GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "SERVICEHOME", - uc.service_home); + GNUNET_CONFIGURATION_set_value_string (cfg, "PATHS", "GNUNET_HOME", + uc.gnunet_home); /* make PORTs and UNIXPATHs unique */ GNUNET_CONFIGURATION_iterate (cfg, &update_config, &uc); /* allow connections to services from system trusted_ip host */ @@ -1076,7 +1077,7 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system, GNUNET_CONFIGURATION_set_value_string (cfg, "nat", "USE_LOCALADDR", "YES"); - GNUNET_free (uc.service_home); + GNUNET_free (uc.gnunet_home); if ((NULL != ports) && (NULL != nports)) { *ports = uc.ports; @@ -1092,7 +1093,7 @@ GNUNET_TESTING_configuration_create_ (struct GNUNET_TESTING_System *system, * Create a new configuration using the given configuration as a template; * ports and paths will be modified to select available ports on the local * system. The default configuration will be available in PATHS section under - * the option DEFAULTCONFIG after the call. SERVICE_HOME is also set in PATHS + * the option DEFAULTCONFIG after the call. GNUNET_HOME is also set in PATHS * section to the temporary directory specific to this configuration. If we run * out of "*port" numbers, return SYSERR. * diff --git a/src/transport/plugin_transport_http_server.c b/src/transport/plugin_transport_http_server.c index 323379d3e..8e6eff072 100644 --- a/src/transport/plugin_transport_http_server.c +++ b/src/transport/plugin_transport_http_server.c @@ -1868,61 +1868,47 @@ server_load_file (const char *file) * Load ssl certificate * * @param plugin the plugin - * @return GNUNET_OK on success, GNUNET_SYSERR on failure + * @return #GNUNET_OK on success, #GNUNET_SYSERR on failure */ static int server_load_certificate (struct HTTP_Server_Plugin *plugin) { int res = GNUNET_OK; - - char *sh; char *key_file; char *cert_file; - /* Get crypto init string from config - * If not present just use default values */ - - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, - "PATHS", - "SERVICEHOME", - &sh)) - { - GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, plugin->name, - "Failed to get servicehome!\n"); - return GNUNET_SYSERR; - } - - - if (GNUNET_OK == - GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, - plugin->name, - "CRYPTO_INIT", - &plugin->crypto_init)) - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, - "Using crypto init string `%s'\n", - plugin->crypto_init); - else - GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, - "Using default crypto init string \n"); if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (plugin->env->cfg, plugin->name, "KEY_FILE", &key_file)) { - GNUNET_break (0); - GNUNET_asprintf (&key_file, "%s/%s", sh, "https_key.key"); + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + plugin->name, "CERT_FILE"); + return GNUNET_SYSERR; } - - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (plugin->env->cfg, plugin->name, "CERT_FILE", &cert_file)) { - GNUNET_break (0); - GNUNET_asprintf (&cert_file, "%s/%s", sh, "https_cert.crt"); + GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR, + plugin->name, "CERT_FILE"); + GNUNET_free (key_file); + return GNUNET_SYSERR; } - GNUNET_free (sh); + /* Get crypto init string from config. If not present, use + * default values */ + if (GNUNET_OK == + GNUNET_CONFIGURATION_get_value_string (plugin->env->cfg, + plugin->name, + "CRYPTO_INIT", + &plugin->crypto_init)) + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, + "Using crypto init string `%s'\n", + plugin->crypto_init); + else + GNUNET_log_from (GNUNET_ERROR_TYPE_DEBUG, plugin->name, + "Using default crypto init string \n"); + /* read key & certificates from file */ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to loading TLS certificate from key-file `%s' cert-file`%s'\n", diff --git a/src/transport/transport.conf.in b/src/transport/transport.conf.in index fd8b5dbbb..d9abdbf11 100644 --- a/src/transport/transport.conf.in +++ b/src/transport/transport.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @UNIXONLY@ PORT = 2091 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-transport #PREFIX = valgrind NEIGHBOUR_LIMIT = 50 @@ -10,11 +9,11 @@ ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; PLUGINS = tcp udp UNIXPATH = /tmp/gnunet-service-transport.sock -BLACKLIST_FILE = $SERVICEHOME/blacklist +BLACKLIST_FILE = $GNUNET_CONFIG_HOME/transport/blacklist UNIX_MATCH_UID = NO UNIX_MATCH_GID = YES # DISABLE_SOCKET_FORWARDING = NO -# USERNAME = +# USERNAME = # MAXBUF = # TIMEOUT = # DISABLEV6 = @@ -26,11 +25,11 @@ UNIX_MATCH_GID = YES # Configuration settings related to traffic manipulation for testing purposes # Distance # MANIPULATE_DISTANCE_IN = 1 -# MANIPULATE_DISTANCE_OUT = 1 +# MANIPULATE_DISTANCE_OUT = 1 # Delay; WARNING: to large values may lead to peers not connecting! # MANIPULATE_DELAY_IN = 1 ms # MANIPULATE_DELAY_OUT = 1 ms - + [transport-unix] PORT = 22086 @@ -79,16 +78,16 @@ TESTING_IGNORE_KEYS = ACCEPT_FROM; [transport-https_server] # EXTERNAL_HOSTNAME = # EXTERNAL_HOSTNAME_ONLY = YES -# If you have a valid SSL certificate for your external hostname tell, -# clients to verify it +# If you have a valid SSL certificate for your external hostname tell, +# clients to verify it # VERIFY_EXTERNAL_HOSTNAME = YES # Does the external hostname use the same port? # EXTERNAL_HOSTNAME_USE_PORT = YES PORT = 4433 ADVERTISED_PORT = 4433 CRYPTO_INIT = NORMAL -KEY_FILE = $SERVICEHOME/https.key -CERT_FILE = $SERVICEHOME/https.cert +KEY_FILE = $GNUNET_DATA_HOME/transport/https.key +CERT_FILE = $GNUNET_DATA_HOME/transport/https.cert MAX_CONNECTIONS = 128 TESTING_IGNORE_KEYS = ACCEPT_FROM; diff --git a/src/util/configuration.c b/src/util/configuration.c index 1b600b4c8..d7076fac1 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -1,6 +1,6 @@ /* This file is part of GNUnet. - (C) 2006, 2007, 2008, 2009 Christian Grothoff (and other contributing authors) + (C) 2006, 2007, 2008, 2009, 2013 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 @@ -414,7 +414,7 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, } /* For each key = value pair we need to add 4 characters (2 spaces and 1 equal-to character and 1 new line) */ - m_size += strlen (ent->key) + strlen (ent->val) + 4; + m_size += strlen (ent->key) + strlen (ent->val) + 4; } } /* A new line after section end */ @@ -449,7 +449,7 @@ GNUNET_CONFIGURATION_serialize (const struct GNUNET_CONFIGURATION_Handle *cfg, GNUNET_free (val); memcpy (mem + c_size, cbuf, len); c_size += len; - GNUNET_free (cbuf); + GNUNET_free (cbuf); } } memcpy (mem + c_size, "\n", 1); @@ -993,7 +993,7 @@ GNUNET_CONFIGURATION_get_value_choice (const struct GNUNET_CONFIGURATION_Handle * @param cfg configuration to inspect * @param section section of interest * @param option option of interest - * @return GNUNET_YES if so, GNUNET_NO if not. + * @return #GNUNET_YES if so, #GNUNET_NO if not. */ int GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, @@ -1009,70 +1009,182 @@ GNUNET_CONFIGURATION_have_value (const struct GNUNET_CONFIGURATION_Handle *cfg, /** * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" - * where either in the "PATHS" section or the environtment - * "FOO" is set to "DIRECTORY". + * where either in the "PATHS" section or the environtment "FOO" is + * set to "DIRECTORY". We also support default expansion, + * i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is + * set in PATHS or the environment, and otherwise to "default". Note + * that "default" itself can also be a $-expression, thus + * "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined + * to VAR2. * * @param cfg configuration to use for path expansion * @param orig string to $-expand (will be freed!) + * @param depth recursion depth, used to detect recursive expansions * @return $-expanded string */ -char * -GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle - *cfg, char *orig) +static char * +expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, + char *orig, + unsigned int depth) { int i; char *prefix; char *result; + char *start; const char *post; const char *env; + char *def; + char *end; + unsigned int lopen; - LOG (GNUNET_ERROR_TYPE_DEBUG, "Asked to $-expand %s\n", orig); - - if (orig[0] != '$') + if (depth > 128) + { + LOG (GNUNET_ERROR_TYPE_WARNING, + _("Recursive expansion suspected, aborting $-expansion for term `%s'\n"), + orig); + return orig; + } + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Asked to $-expand %s\n", orig); + if ('$' != orig[0]) { - LOG (GNUNET_ERROR_TYPE_DEBUG, "Doesn't start with $ - not expanding\n"); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Doesn't start with $ - not expanding\n"); return orig; } - i = 0; - while ((orig[i] != '/') && (orig[i] != '\\') && (orig[i] != '\0')) - i++; - if (orig[i] == '\0') + if ('{' == orig[1]) { - post = ""; + start = &orig[2]; + lopen = 1; + end = &orig[1]; + while (lopen > 0) + { + end++; + switch (*end) + { + case '}': + lopen--; + break; + case '{': + lopen++; + break; + case '\0': + LOG (GNUNET_ERROR_TYPE_WARNING, + _("Missing closing `%s' in option `%s'\n"), + "}", + orig); + return orig; + default: + break; + } + } + *end = '\0'; + post = end + 1; + def = strchr (orig, ':'); + if (NULL != def) + { + *def = '\0'; + def++; + if ( ('-' == *def) || + ('=' == *def) ) + def++; + def = GNUNET_strdup (def); + } } else { - orig[i] = '\0'; - post = &orig[i + 1]; + start = &orig[1]; + def = NULL; + i = 0; + while ( (orig[i] != '/') && + (orig[i] != '\\') && + (orig[i] != '\0') ) + i++; + if (orig[i] == '\0') + { + post = ""; + } + else + { + orig[i] = '\0'; + post = &orig[i + 1]; + } } - LOG (GNUNET_ERROR_TYPE_DEBUG, "Split into `%s' and `%s'\n", orig, post); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Split into `%s' and `%s' with default %s\n", + start, + post, + def); if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, "PATHS", &orig[1], &prefix)) + GNUNET_CONFIGURATION_get_value_filename (cfg, + "PATHS", + start, + &prefix)) { - LOG (GNUNET_ERROR_TYPE_DEBUG, "Filename for `%s' is not in PATHS config section\n", &orig[1]); - if (NULL == (env = getenv (&orig[1]))) + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Filename for `%s' is not in PATHS config section\n", + start); + if (NULL == (env = getenv (start))) + { + LOG (GNUNET_ERROR_TYPE_DEBUG, + "`%s' is not an environment variable\n", + start); + /* try default */ + def = expand_dollar (cfg, def, depth + 1); + env = def; + } + if (NULL == env) { - LOG (GNUNET_ERROR_TYPE_DEBUG, "`%s' is not an environment variable\n", &orig[1]); - orig[i] = DIR_SEPARATOR; - LOG (GNUNET_ERROR_TYPE_DEBUG, "Expanded to `%s' (returning orig)\n", orig); + orig[strlen (orig)] = DIR_SEPARATOR; + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Expanded to `%s' (returning orig)\n", + orig); return orig; } prefix = GNUNET_strdup (env); } - LOG (GNUNET_ERROR_TYPE_DEBUG, "Prefix is `%s'\n", prefix); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Prefix is `%s'\n", + prefix); result = GNUNET_malloc (strlen (prefix) + strlen (post) + 2); strcpy (result, prefix); - if ((strlen (prefix) == 0) || - ((prefix[strlen (prefix) - 1] != DIR_SEPARATOR) && (strlen (post) > 0))) + if ( (0 == strlen (prefix)) || + ( (prefix[strlen (prefix) - 1] != DIR_SEPARATOR) && + (strlen (post) > 0) ) ) strcat (result, DIR_SEPARATOR_STR); strcat (result, post); + GNUNET_free_non_null (def); GNUNET_free (prefix); GNUNET_free (orig); - LOG (GNUNET_ERROR_TYPE_DEBUG, "Expanded to `%s'\n", result); + LOG (GNUNET_ERROR_TYPE_DEBUG, + "Expanded to `%s'\n", + result); return result; } +/** + * Expand an expression of the form "$FOO/BAR" to "DIRECTORY/BAR" + * where either in the "PATHS" section or the environtment "FOO" is + * set to "DIRECTORY". We also support default expansion, + * i.e. ${VARIABLE:-default} will expand to $VARIABLE if VARIABLE is + * set in PATHS or the environment, and otherwise to "default". Note + * that "default" itself can also be a $-expression, thus + * "${VAR1:-{$VAR2}}" will expand to VAR1 and if that is not defined + * to VAR2. + * + * @param cfg configuration to use for path expansion + * @param orig string to $-expand (will be freed!) + * @return $-expanded string + */ +char * +GNUNET_CONFIGURATION_expand_dollar (const struct GNUNET_CONFIGURATION_Handle *cfg, + char *orig) +{ + return expand_dollar (cfg, orig, 0); +} + + /** * Get a configuration value that should be a string. * diff --git a/src/util/disk.c b/src/util/disk.c index 8dc1e35bf..0d24d5a09 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -1927,78 +1927,6 @@ GNUNET_DISK_get_handle_from_native (FILE *fd) } -/** - * Construct full path to a file inside of the private - * directory used by GNUnet. Also creates the corresponding - * directory. If the resulting name is supposed to be - * a directory, end the last argument in '/' (or pass - * DIR_SEPARATOR_STR as the last argument before NULL). - * - * @param cfg configuration to use (determines HOME) - * @param service_name name of the service - * @param ... is NULL-terminated list of - * path components to append to the - * private directory name. - * @return the constructed filename - */ -char * -GNUNET_DISK_get_home_filename (const struct GNUNET_CONFIGURATION_Handle *cfg, - const char *service_name, ...) -{ - const char *c; - char *pfx; - char *ret; - va_list ap; - unsigned int needed; - - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, service_name, "HOME", &pfx)) - return NULL; - if (pfx == NULL) - { - LOG (GNUNET_ERROR_TYPE_WARNING, - _("No `%s' specified for service `%s' in configuration.\n"), "HOME", - service_name); - return NULL; - } - needed = strlen (pfx) + 2; - if ((pfx[strlen (pfx) - 1] != '/') && (pfx[strlen (pfx) - 1] != '\\')) - needed++; - va_start (ap, service_name); - while (1) - { - c = va_arg (ap, const char *); - - if (c == NULL) - break; - needed += strlen (c); - if ((c[strlen (c) - 1] != '/') && (c[strlen (c) - 1] != '\\')) - needed++; - } - va_end (ap); - ret = GNUNET_malloc (needed); - strcpy (ret, pfx); - GNUNET_free (pfx); - va_start (ap, service_name); - while (1) - { - c = va_arg (ap, const char *); - - if (c == NULL) - break; - if ((c[strlen (c) - 1] != '/') && (c[strlen (c) - 1] != '\\')) - strcat (ret, DIR_SEPARATOR_STR); - strcat (ret, c); - } - va_end (ap); - if ((ret[strlen (ret) - 1] != '/') && (ret[strlen (ret) - 1] != '\\')) - (void) GNUNET_DISK_directory_create_for_file (ret); - else - (void) GNUNET_DISK_directory_create (ret); - return ret; -} - - /** * Handle for a memory-mapping operation. */ diff --git a/src/util/os_installation.c b/src/util/os_installation.c index 98ac7b989..8649fac6f 100644 --- a/src/util/os_installation.c +++ b/src/util/os_installation.c @@ -43,6 +43,7 @@ #define LOG_STRERROR_FILE(kind,syscall,filename) GNUNET_log_from_strerror_file (kind, "util", syscall, filename) + #if LINUX /** * Try to determine path by reading /proc/PID/exe @@ -115,12 +116,13 @@ get_path_from_proc_exe () } #endif -#if WINDOWS +#if WINDOWS static HINSTANCE dll_instance; -/* GNUNET_util_cl_init() in common_logging.c is preferred. +/** + * GNUNET_util_cl_init() in common_logging.c is preferred. * This function is only for thread-local storage (not used in GNUnet) * and hInstance saving. */ @@ -226,6 +228,7 @@ get_path_from_module_filename () } #endif + #if DARWIN /** * Signature of the '_NSGetExecutablePath" function. @@ -415,8 +418,7 @@ os_get_gnunet_path () return ret; /* other attempts here */ LOG (GNUNET_ERROR_TYPE_ERROR, - _ - ("Could not determine installation path for %s. Set `%s' environment variable.\n"), + _("Could not determine installation path for %s. Set `%s' environment variable.\n"), "GNUnet", "GNUNET_PREFIX"); return NULL; } @@ -452,7 +454,7 @@ os_get_exec_path () /** * @brief get the path to a specific GNUnet installation directory or, - * with GNUNET_IPK_SELF_PREFIX, the current running apps installation directory + * with #GNUNET_IPK_SELF_PREFIX, the current running apps installation directory * @author Milan * @return a pointer to the dir path (to be freed by the caller) */ @@ -657,9 +659,9 @@ GNUNET_OS_get_libexec_binary_path (const char *progname) * binary with the -d flag. -d omits a programs main loop and only * executes all privileged operations in an binary. * @param params parameters used for w32 privilege checking (can be NULL for != w32 ) - * @return GNUNET_YES if the file is SUID (*nix) or can be executed with current privileges (W32), - * GNUNET_NO if not SUID (but binary exists), - * GNUNET_SYSERR on error (no such binary or not executable) + * @return #GNUNET_YES if the file is SUID (*nix) or can be executed with current privileges (W32), + * #GNUNET_NO if not SUID (but binary exists), + * #GNUNET_SYSERR on error (no such binary or not executable) */ int GNUNET_OS_check_helper_binary (const char *binary, int check_suid, const char *params) @@ -704,7 +706,8 @@ GNUNET_OS_check_helper_binary (const char *binary, int check_suid, const char *p #endif if (NULL == p) { - LOG (GNUNET_ERROR_TYPE_INFO, _("Could not find binary `%s' in PATH!\n"), + LOG (GNUNET_ERROR_TYPE_INFO, + _("Could not find binary `%s' in PATH!\n"), binary); return GNUNET_SYSERR; } diff --git a/src/util/resolver.conf.in b/src/util/resolver.conf.in index cccb60c2f..42cc5855f 100644 --- a/src/util/resolver.conf.in +++ b/src/util/resolver.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @JAVAPORT@PORT = 2089 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-resolver ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; diff --git a/src/util/test_disk.c b/src/util/test_disk.c index 7579ac7dc..40e6b079c 100644 --- a/src/util/test_disk.c +++ b/src/util/test_disk.c @@ -168,27 +168,6 @@ testDirIter () } -static int -testGetHome () -{ - struct GNUNET_CONFIGURATION_Handle *cfg; - char *fn; - int ret; - - cfg = GNUNET_CONFIGURATION_create (); - GNUNET_assert (cfg != NULL); - GNUNET_CONFIGURATION_set_value_string (cfg, "service", "HOME", - "/tmp/test-gnunet-disk-a/b/c"); - fn = GNUNET_DISK_get_home_filename (cfg, "service", "d", "e", NULL); - GNUNET_assert (fn != NULL); - GNUNET_CONFIGURATION_destroy (cfg); - ret = strcmp ("/tmp/test-gnunet-disk-a/b/c/d/e", fn); - GNUNET_free (fn); - GNUNET_break (GNUNET_OK == - GNUNET_DISK_directory_remove ("/tmp/test-gnunet-disk-a")); - return ret; -} - static int testCanonicalize () { @@ -246,7 +225,6 @@ main (int argc, char *argv[]) failureCount += testOpenClose (); failureCount += testDirScan (); failureCount += testDirIter (); - failureCount += testGetHome (); failureCount += testCanonicalize (); failureCount += testChangeOwner (); failureCount += testDirMani (); diff --git a/src/util/util.conf b/src/util/util.conf index ade7786ad..b7f9deb04 100644 --- a/src/util/util.conf +++ b/src/util/util.conf @@ -1,20 +1,41 @@ [PATHS] +# The PATHS section is special, as filenames including $-expression are +# expanded using the values from PATHS or the system environment (PATHS +# is checked first). GNUnet also supports expanding $-expressions using +# defaults with the syntax "${VAR:-default}". Here, "default" can again +# be a $-expression. +# GNUNET_HOME = $HOME -GNUNET_DATA_HOME = $GNUNET_HOME/.local/share/gnunet/ -GNUNET_CONFIG_HOME = $GNUNET_HOME/.config/gnunet/ -GNUNET_CACHE_HOME = $GNUNET_HOME/.cache/gnunet/ -GNUNET_RUNTIME_DIR = $GNUNET_HOME/.runtime/gnunet/ +# see XDG Base Directory Specification at +# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html +# for how these should be used. +# Persistant data storage +GNUNET_DATA_HOME = ${XDG_DATA_HOME:-$GNUNET_HOME/.local/share}/gnunet/ + +# Configuration files +GNUNET_CONFIG_HOME = ${XDG_CONFIG_HOME:-GNUNET_HOME/.config/}gnunet/ + +# Cached data, no big deal if lost +GNUNET_CACHE_HOME = ${XDG_CACHE_HOME:-$GNUNET_HOME/.cache/}gnunet/ + +# Runtime data (i.e UNIX domain sockets, locks, always lost on system boot) +GNUNET_RUNTIME_DIR = ${XDG_RUNTIME_DIR:-${TMPDIR:-${TMP:-/tmp}}}gnunet/ + +# Legacy option... SERVICEHOME = ~/.gnunet/ # SERVICEHOME = /var/lib/gnunet/ + # DEFAULTCONFIG = /etc/gnunet.conf # If 'DEFAULTCONFIG' is not defined, the current # configuration file is assumed to be the default, # which is what we want by default... + [PEER] -PRIVATE_KEY = $SERVICEHOME/private_key.ecc +PRIVATE_KEY = $GNUNET_DATA_HOME/private_key.ecc + [TESTING] SPEEDUP_INTERVAL = 0 ms diff --git a/src/vpn/vpn.conf.in b/src/vpn/vpn.conf.in index 57657b94f..91610eb2a 100644 --- a/src/vpn/vpn.conf.in +++ b/src/vpn/vpn.conf.in @@ -2,7 +2,6 @@ AUTOSTART = YES @UNIXONLY@ PORT = 2105 HOSTNAME = localhost -HOME = $SERVICEHOME BINARY = gnunet-service-vpn ACCEPT_FROM = 127.0.0.1; ACCEPT_FROM6 = ::1; -- cgit v1.2.3