fail hard if configuration file specified via -c does not exist (in all services...
authorChristian Grothoff <christian@grothoff.org>
Tue, 11 Dec 2018 09:21:39 +0000 (10:21 +0100)
committerChristian Grothoff <christian@grothoff.org>
Tue, 11 Dec 2018 09:21:39 +0000 (10:21 +0100)
src/util/configuration.c
src/util/gnunet-config.c
src/util/program.c
src/util/service.c

index 197c664db83d24081977c33b84702b2cf9399579..d61b9c27eac7a59a5979c01ddf8c33bd001a14c4 100644 (file)
@@ -945,7 +945,7 @@ GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle
                   number,
                   dummy))
     return GNUNET_SYSERR;
-  return GNUNET_OK;  
+  return GNUNET_OK;
 }
 
 
@@ -966,7 +966,7 @@ GNUNET_CONFIGURATION_get_value_float  (const struct GNUNET_CONFIGURATION_Handle
 {
   struct ConfigEntry *e;
   char dummy[2];
-  
+
   if (NULL == (e = find_entry (cfg, section, option)))
     return GNUNET_SYSERR;
   if (NULL == e->val)
@@ -1748,7 +1748,9 @@ GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg,
                                const char *defaults_d)
 {
   if (GNUNET_SYSERR ==
-      GNUNET_DISK_directory_scan (defaults_d, &parse_configuration_file, cfg))
+      GNUNET_DISK_directory_scan (defaults_d,
+                                  &parse_configuration_file,
+                                  cfg))
     return GNUNET_SYSERR;       /* no configuration at all found */
   return GNUNET_OK;
 }
index 4528bbe243129e3b11120212d606c8981bfdf8c8..46c523da4804f27438395b47da26560389618a13 100644 (file)
@@ -11,7 +11,7 @@
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Affero General Public License for more details.
-    
+
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -82,7 +82,7 @@ print_option (void *cls,
   {
     char *value_fn;
     char *fn;
-    
+
     GNUNET_assert (GNUNET_OK ==
                   GNUNET_CONFIGURATION_get_value_filename (cfg,
                                                            section,
@@ -167,14 +167,19 @@ run (void *cls,
     if (! list_sections)
     {
       fprintf (stderr,
-               _("--section argument is required\n"));
+               _("%s or %s argument is required\n"),
+               "--section",
+               "--list-sections");
+      ret = 1;
+    }
+    else
+    {
+      fprintf (stderr,
+               _("The following sections are available:\n"));
+      GNUNET_CONFIGURATION_iterate_sections (cfg,
+                                             &print_section_name,
+                                             NULL);
     }
-    fprintf (stderr,
-             _("The following sections are available:\n"));
-    GNUNET_CONFIGURATION_iterate_sections (cfg,
-                                           &print_section_name,
-                                           NULL);
-    ret = 1;
     goto cleanup;
   }
 
index 2a9b4fac9c935153778d17386473e984050afa60..da58348d0272f90c13b05d151bae87a61b56c795 100644 (file)
@@ -11,7 +11,7 @@
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPROSE.  See the GNU
      Affero General Public License for more details.
-    
+
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -286,15 +286,10 @@ GNUNET_PROGRAM_run2 (int argc,
   {
     if (0 != strcmp (cc.cfgfile,
                     cfg_fn))
+    {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                  _("Could not access configuration file `%s'\n"),
                  cc.cfgfile);
-    if (GNUNET_SYSERR ==
-       GNUNET_CONFIGURATION_load (cfg,
-                                  NULL))
-    {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _("Malformed configuration, exit ...\n"));
       ret = GNUNET_SYSERR;
       GNUNET_free (allopts);
       GNUNET_free (lpfx);
index b611685706a6254596b41d437fe65f998691d4ba..2dc7dd5763b7057fb6f948207e368950b42f3a87 100644 (file)
@@ -11,7 +11,7 @@
      WITHOUT ANY WARRANTY; without even the implied warranty of
      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      Affero General Public License for more details.
-    
+
      You should have received a copy of the GNU Affero General Public License
      along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
@@ -1177,7 +1177,7 @@ setup_service (struct GNUNET_SERVICE_Handle *sh)
   int flags;
   char dummy[2];
 #endif
-  
+
   if (GNUNET_CONFIGURATION_have_value
       (sh->cfg,
        sh->service_name,
@@ -1837,9 +1837,12 @@ GNUNET_SERVICE_run_ (int argc,
     }
     if (0 != strcmp (opt_cfg_filename,
                     cfg_filename))
+    {
       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
                  _("Could not access configuration file `%s'\n"),
                  opt_cfg_filename);
+      goto shutdown;
+    }
   }
   if (GNUNET_OK != setup_service (&sh))
     goto shutdown;