diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-11-03 13:19:52 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-11-03 13:19:52 +0000 |
commit | 29c724d2a7764f83fe846b418d09540348b86983 (patch) | |
tree | dafaff8e37ba51355b22b6f38d856ae49e145006 /src/util | |
parent | b303961f38c9b578f30248ee364ed4e5ffdcd06c (diff) | |
download | gnunet-29c724d2a7764f83fe846b418d09540348b86983.tar.gz gnunet-29c724d2a7764f83fe846b418d09540348b86983.zip |
implementing #1747
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/Makefile.am | 5 | ||||
-rw-r--r-- | src/util/configuration.c | 46 | ||||
-rw-r--r-- | src/util/disk.c | 1 | ||||
-rw-r--r-- | src/util/resolver.conf | 22 | ||||
-rw-r--r-- | src/util/util.conf | 16 |
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 | ||
3 | plugindir = $(libdir)/gnunet | 3 | plugindir = $(libdir)/gnunet |
4 | 4 | ||
5 | pkgcfgdir= $(pkgdatadir)/config.d/ | ||
6 | |||
7 | dist_pkgcfg_DATA = \ | ||
8 | util.conf resolver.conf | ||
9 | |||
5 | if MINGW | 10 | if MINGW |
6 | noinst_LTLIBRARIES = \ | 11 | noinst_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 | */ | ||
1224 | static int | ||
1225 | parse_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] | ||
2 | AUTOSTART = YES | ||
3 | PORT = 2089 | ||
4 | HOSTNAME = localhost | ||
5 | HOME = $SERVICEHOME | ||
6 | CONFIG = $DEFAULTCONFIG | ||
7 | BINARY = gnunet-service-resolver | ||
8 | ACCEPT_FROM = 127.0.0.1; | ||
9 | ACCEPT_FROM6 = ::1; | ||
10 | UNIXPATH = /tmp/gnunet-service-resolver.sock | ||
11 | UNIX_MATCH_UID = NO | ||
12 | UNIX_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] | ||
2 | SERVICEHOME = ~/.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] | ||
10 | HOSTKEY = $SERVICEHOME/.hostkey | ||
11 | |||
12 | [client] | ||
13 | HOME = $SERVICEHOME | ||
14 | |||
15 | [TESTING] | ||
16 | WEAKRANDOM = NO | ||