From 29c724d2a7764f83fe846b418d09540348b86983 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Thu, 3 Nov 2011 13:19:52 +0000 Subject: implementing #1747 --- src/util/Makefile.am | 5 +++++ src/util/configuration.c | 46 ++++++++++++++++++++++++++++++++++++---------- src/util/disk.c | 1 + src/util/resolver.conf | 22 ++++++++++++++++++++++ src/util/util.conf | 16 ++++++++++++++++ 5 files changed, 80 insertions(+), 10 deletions(-) create mode 100644 src/util/resolver.conf create mode 100644 src/util/util.conf (limited to 'src/util') diff --git a/src/util/Makefile.am b/src/util/Makefile.am index d816bc42c..98af8383a 100644 --- a/src/util/Makefile.am +++ b/src/util/Makefile.am @@ -2,6 +2,11 @@ INCLUDES = -I$(top_srcdir)/src/include -I$(top_builddir)/src/include plugindir = $(libdir)/gnunet +pkgcfgdir= $(pkgdatadir)/config.d/ + +dist_pkgcfg_DATA = \ + util.conf resolver.conf + if MINGW noinst_LTLIBRARIES = \ libgnunetutilwin.la diff --git a/src/util/configuration.c b/src/util/configuration.c index adfd4ea5a..a269ed036 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c @@ -1214,6 +1214,25 @@ GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle } +/** + * Wrapper around GNUNET_CONFIGURATION_parse. + * + * @param cls the cfg + * @param filename file to parse + * @return GNUNET_OK on success + */ +static int +parse_configuration_file (void *cls, + const char *filename) +{ + struct GNUNET_CONFIGURATION_Handle *cfg = cls; + int ret; + + ret = GNUNET_CONFIGURATION_parse (cfg, filename); + return ret; +} + + /** * Load configuration (starts with defaults, then loads * system-specific configuration). @@ -1233,17 +1252,24 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg, if (ipath == NULL) return GNUNET_SYSERR; baseconfig = NULL; - GNUNET_asprintf (&baseconfig, "%s%s%s", ipath, DIR_SEPARATOR_STR, - "defaults.conf"); + GNUNET_asprintf (&baseconfig, "%s%s", ipath, + "config.d"); GNUNET_free (ipath); - if ((GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, baseconfig)) || - (!((filename == NULL) || - (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename))))) - { - GNUNET_free (baseconfig); - return (filename == NULL) ? GNUNET_OK : GNUNET_SYSERR; - } - GNUNET_free (baseconfig); + if (GNUNET_SYSERR == + GNUNET_DISK_directory_scan (baseconfig, + &parse_configuration_file, + cfg)) + { + GNUNET_free (baseconfig); + return GNUNET_SYSERR; /* no configuration at all found */ + } + GNUNET_free (baseconfig); + if ( (filename != NULL) && + (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, filename)) ) + { + /* specified configuration not found */ + return GNUNET_SYSERR; + } if (((GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) && (filename != NULL)) diff --git a/src/util/disk.c b/src/util/disk.c index 2021d6493..12f985791 100644 --- a/src/util/disk.c +++ b/src/util/disk.c @@ -795,6 +795,7 @@ GNUNET_DISK_fn_write (const char *fn, const void *buffer, size_t n, return ret; } + /** * Scan a directory for files. * diff --git a/src/util/resolver.conf b/src/util/resolver.conf new file mode 100644 index 000000000..a2690fcc3 --- /dev/null +++ b/src/util/resolver.conf @@ -0,0 +1,22 @@ +[resolver] +AUTOSTART = YES +PORT = 2089 +HOSTNAME = localhost +HOME = $SERVICEHOME +CONFIG = $DEFAULTCONFIG +BINARY = gnunet-service-resolver +ACCEPT_FROM = 127.0.0.1; +ACCEPT_FROM6 = ::1; +UNIXPATH = /tmp/gnunet-service-resolver.sock +UNIX_MATCH_UID = NO +UNIX_MATCH_GID = NO +# DISABLE_SOCKET_FORWARDING = NO +# USERNAME = +# MAXBUF = +# TIMEOUT = +# DISABLEV6 = +# BINDTO = +# REJECT_FROM = +# REJECT_FROM6 = +# PREFIX = + diff --git a/src/util/util.conf b/src/util/util.conf new file mode 100644 index 000000000..ba9dfec70 --- /dev/null +++ b/src/util/util.conf @@ -0,0 +1,16 @@ +[PATHS] +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... + +[gnunetd] +HOSTKEY = $SERVICEHOME/.hostkey + +[client] +HOME = $SERVICEHOME + +[TESTING] +WEAKRANDOM = NO -- cgit v1.2.3