aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2011-11-03 13:19:52 +0000
committerChristian Grothoff <christian@grothoff.org>2011-11-03 13:19:52 +0000
commit29c724d2a7764f83fe846b418d09540348b86983 (patch)
treedafaff8e37ba51355b22b6f38d856ae49e145006 /src/util
parentb303961f38c9b578f30248ee364ed4e5ffdcd06c (diff)
downloadgnunet-29c724d2a7764f83fe846b418d09540348b86983.tar.gz
gnunet-29c724d2a7764f83fe846b418d09540348b86983.zip
implementing #1747
Diffstat (limited to 'src/util')
-rw-r--r--src/util/Makefile.am5
-rw-r--r--src/util/configuration.c46
-rw-r--r--src/util/disk.c1
-rw-r--r--src/util/resolver.conf22
-rw-r--r--src/util/util.conf16
5 files changed, 80 insertions, 10 deletions
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
2 2
3plugindir = $(libdir)/gnunet 3plugindir = $(libdir)/gnunet
4 4
5pkgcfgdir= $(pkgdatadir)/config.d/
6
7dist_pkgcfg_DATA = \
8 util.conf resolver.conf
9
5if MINGW 10if MINGW
6noinst_LTLIBRARIES = \ 11noinst_LTLIBRARIES = \
7 libgnunetutilwin.la 12 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
@@ -1215,6 +1215,25 @@ GNUNET_CONFIGURATION_remove_value_filename (struct GNUNET_CONFIGURATION_Handle
1215 1215
1216 1216
1217/** 1217/**
1218 * Wrapper around GNUNET_CONFIGURATION_parse.
1219 *
1220 * @param cls the cfg
1221 * @param filename file to parse
1222 * @return GNUNET_OK on success
1223 */
1224static int
1225parse_configuration_file (void *cls,
1226 const char *filename)
1227{
1228 struct GNUNET_CONFIGURATION_Handle *cfg = cls;
1229 int ret;
1230
1231 ret = GNUNET_CONFIGURATION_parse (cfg, filename);
1232 return ret;
1233}
1234
1235
1236/**
1218 * Load configuration (starts with defaults, then loads 1237 * Load configuration (starts with defaults, then loads
1219 * system-specific configuration). 1238 * system-specific configuration).
1220 * 1239 *
@@ -1233,17 +1252,24 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
1233 if (ipath == NULL) 1252 if (ipath == NULL)
1234 return GNUNET_SYSERR; 1253 return GNUNET_SYSERR;
1235 baseconfig = NULL; 1254 baseconfig = NULL;
1236 GNUNET_asprintf (&baseconfig, "%s%s%s", ipath, DIR_SEPARATOR_STR, 1255 GNUNET_asprintf (&baseconfig, "%s%s", ipath,
1237 "defaults.conf"); 1256 "config.d");
1238 GNUNET_free (ipath); 1257 GNUNET_free (ipath);
1239 if ((GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, baseconfig)) || 1258 if (GNUNET_SYSERR ==
1240 (!((filename == NULL) || 1259 GNUNET_DISK_directory_scan (baseconfig,
1241 (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename))))) 1260 &parse_configuration_file,
1242 { 1261 cfg))
1243 GNUNET_free (baseconfig); 1262 {
1244 return (filename == NULL) ? GNUNET_OK : GNUNET_SYSERR; 1263 GNUNET_free (baseconfig);
1245 } 1264 return GNUNET_SYSERR; /* no configuration at all found */
1246 GNUNET_free (baseconfig); 1265 }
1266 GNUNET_free (baseconfig);
1267 if ( (filename != NULL) &&
1268 (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, filename)) )
1269 {
1270 /* specified configuration not found */
1271 return GNUNET_SYSERR;
1272 }
1247 if (((GNUNET_YES != 1273 if (((GNUNET_YES !=
1248 GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) && 1274 GNUNET_CONFIGURATION_have_value (cfg, "PATHS", "DEFAULTCONFIG"))) &&
1249 (filename != NULL)) 1275 (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,
795 return ret; 795 return ret;
796} 796}
797 797
798
798/** 799/**
799 * Scan a directory for files. 800 * Scan a directory for files.
800 * 801 *
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 @@
1[resolver]
2AUTOSTART = YES
3PORT = 2089
4HOSTNAME = localhost
5HOME = $SERVICEHOME
6CONFIG = $DEFAULTCONFIG
7BINARY = gnunet-service-resolver
8ACCEPT_FROM = 127.0.0.1;
9ACCEPT_FROM6 = ::1;
10UNIXPATH = /tmp/gnunet-service-resolver.sock
11UNIX_MATCH_UID = NO
12UNIX_MATCH_GID = NO
13# DISABLE_SOCKET_FORWARDING = NO
14# USERNAME =
15# MAXBUF =
16# TIMEOUT =
17# DISABLEV6 =
18# BINDTO =
19# REJECT_FROM =
20# REJECT_FROM6 =
21# PREFIX =
22
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 @@
1[PATHS]
2SERVICEHOME = ~/.gnunet/
3# SERVICEHOME = /var/lib/gnunet/
4# DEFAULTCONFIG = /etc/gnunet.conf
5# If 'DEFAULTCONFIG' is not defined, the current
6# configuration file is assumed to be the default,
7# which is what we want by default...
8
9[gnunetd]
10HOSTKEY = $SERVICEHOME/.hostkey
11
12[client]
13HOME = $SERVICEHOME
14
15[TESTING]
16WEAKRANDOM = NO