better defaults, nicer error msgs:
authorChristian Grothoff <christian@grothoff.org>
Mon, 15 Mar 2010 09:39:23 +0000 (09:39 +0000)
committerChristian Grothoff <christian@grothoff.org>
Mon, 15 Mar 2010 09:39:23 +0000 (09:39 +0000)
contrib/defaults.conf
doc/man/gnunet-peerinfo.1
src/util/configuration.c
src/util/service.c

index 07bea373243eb5015348dd819b53668ee09f051e..da25633eb05659b310bb3bbe4e6ee2e752b11607 100644 (file)
@@ -1,6 +1,9 @@
 [PATHS]
 SERVICEHOME = /var/lib/gnunet/
-DEFAULTCONFIG = /etc/gnunet.conf
+# 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
index d25dfa3d38d3eaffd778472ec953a3dae0d68846..3eb2157d64d837ca05f0987847be5fb058935016 100644 (file)
@@ -15,7 +15,7 @@ gnunet\-peerinfo \- Display information about other peers.
 .SH OPTIONS
 .B
 .IP "\-c FILENAME, \-\-config=FILENAME"
-Load config file (default: /etc/gnunet.conf)
+Load config file (default: ~/.gnunet/gnunet.conf)
 .B
 .IP "\-h, \-\-help"
 Print help page
index 41eeeb461049444990da4902ccc2cc374b1e0551..167fd375ae9c4d25377c5e947dd6b056d37286f7 100644 (file)
@@ -1140,10 +1140,18 @@ GNUNET_CONFIGURATION_load (struct GNUNET_CONFIGURATION_Handle *cfg,
       (!((filename == NULL) ||
          (GNUNET_OK == GNUNET_CONFIGURATION_parse (cfg, filename)))))
     {
-     GNUNET_free (baseconfig);
+      GNUNET_free (baseconfig);
       return GNUNET_SYSERR;
     }
   GNUNET_free (baseconfig);
+  if ( ((GNUNET_YES != GNUNET_CONFIGURATION_have_value (cfg,
+                                                       "PATHS",
+                                                       "DEFAULTCONFIG"))) &&
+       (filename != NULL) )
+    GNUNET_CONFIGURATION_set_value_string (cfg,
+                                          "PATHS",
+                                          "DEFAULTCONFIG",
+                                          filename);
   if ((GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg,
                                                       "TESTING",
                                                       "WEAKRANDOM")) &&
index 2100740172137c50c893c6aebb2cee3826cdc72e..e6fec7514b6b8d9ef513fc4ac92097d741696f0e 100644 (file)
@@ -999,8 +999,13 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
           GNUNET_CONFIGURATION_get_value_time (sctx->cfg,
                                                sctx->serviceName,
                                                "TIMEOUT", &idleout))
-        return GNUNET_SYSERR;
-
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     _("Specified value for `%s' of service `%s' is invalid\n"),
+                     "TIMEOUT",
+                     sctx->serviceName);
+         return GNUNET_SYSERR;
+       }
       sctx->timeout = idleout;
     }
   else
@@ -1012,7 +1017,13 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
           GNUNET_CONFIGURATION_get_value_number (sctx->cfg,
                                                  sctx->serviceName,
                                                  "MAXBUF", &maxbuf))
-        return GNUNET_SYSERR;
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     _("Specified value for `%s' of service `%s' is invalid\n"),
+                     "MAXBUF",
+                     sctx->serviceName);
+         return GNUNET_SYSERR;
+       }
     }
   else
     maxbuf = GNUNET_SERVER_MAX_MESSAGE_SIZE;
@@ -1023,7 +1034,13 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
           (sctx->allow_shutdown =
            GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg, sctx->serviceName,
                                                  "ALLOW_SHUTDOWN")))
-        return GNUNET_SYSERR;
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     _("Specified value for `%s' of service `%s' is invalid\n"),
+                     "ALLOW_SHUTDOWN",
+                     sctx->serviceName);
+         return GNUNET_SYSERR;
+       }
     }
   else
     sctx->allow_shutdown = GNUNET_NO;
@@ -1036,7 +1053,13 @@ setup_service (struct GNUNET_SERVICE_Context *sctx)
           (tolerant = GNUNET_CONFIGURATION_get_value_yesno (sctx->cfg,
                                                             sctx->serviceName,
                                                             "TOLERANT")))
-        return GNUNET_SYSERR;
+       {
+         GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+                     _("Specified value for `%s' of service `%s' is invalid\n"),
+                     "TOLERANT",
+                     sctx->serviceName);
+         return GNUNET_SYSERR;
+       }
     }
   else
     tolerant = GNUNET_NO;
@@ -1417,17 +1440,17 @@ GNUNET_SERVICE_run (int argc,
   /* setup subsystems */
   if (GNUNET_SYSERR == GNUNET_GETOPT_run (serviceName, service_options, argc,
       argv))    
-    HANDLE_ERROR;
+    goto shutdown;
   if (GNUNET_OK != GNUNET_log_setup (serviceName, loglev, logfile))
     HANDLE_ERROR;
   if (GNUNET_OK != GNUNET_CONFIGURATION_load (cfg, cfg_fn))
-    HANDLE_ERROR;
+    goto shutdown;
   if (GNUNET_OK != setup_service (&sctx))
-    HANDLE_ERROR;
+    goto shutdown;
   if ( (do_daemonize == 1) && (GNUNET_OK != detach_terminal (&sctx)))    
     HANDLE_ERROR;
   if (GNUNET_OK != set_user_id (&sctx))
-    HANDLE_ERROR;
+    goto shutdown;
 #if DEBUG_SERVICE
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
               "Service `%s' runs with configuration from `%s'\n",