diff options
author | Christian Grothoff <christian@grothoff.org> | 2018-12-11 10:21:39 +0100 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2018-12-11 10:21:39 +0100 |
commit | ee10b40c55c154400bbefd13175bd8b280cb7798 (patch) | |
tree | d475fcde922f4a5e413fb4b76c8784eb48fe71d3 /src | |
parent | 70ae2bd54ee0ff610d95a63856f38395920b804d (diff) | |
download | gnunet-ee10b40c55c154400bbefd13175bd8b280cb7798.tar.gz gnunet-ee10b40c55c154400bbefd13175bd8b280cb7798.zip |
fail hard if configuration file specified via -c does not exist (in all services and programs)
Diffstat (limited to 'src')
-rw-r--r-- | src/util/configuration.c | 8 | ||||
-rw-r--r-- | src/util/gnunet-config.c | 23 | ||||
-rw-r--r-- | src/util/program.c | 9 | ||||
-rw-r--r-- | src/util/service.c | 7 |
4 files changed, 26 insertions, 21 deletions
diff --git a/src/util/configuration.c b/src/util/configuration.c index 197c664db..d61b9c27e 100644 --- a/src/util/configuration.c +++ b/src/util/configuration.c | |||
@@ -945,7 +945,7 @@ GNUNET_CONFIGURATION_get_value_number (const struct GNUNET_CONFIGURATION_Handle | |||
945 | number, | 945 | number, |
946 | dummy)) | 946 | dummy)) |
947 | return GNUNET_SYSERR; | 947 | return GNUNET_SYSERR; |
948 | return GNUNET_OK; | 948 | return GNUNET_OK; |
949 | } | 949 | } |
950 | 950 | ||
951 | 951 | ||
@@ -966,7 +966,7 @@ GNUNET_CONFIGURATION_get_value_float (const struct GNUNET_CONFIGURATION_Handle | |||
966 | { | 966 | { |
967 | struct ConfigEntry *e; | 967 | struct ConfigEntry *e; |
968 | char dummy[2]; | 968 | char dummy[2]; |
969 | 969 | ||
970 | if (NULL == (e = find_entry (cfg, section, option))) | 970 | if (NULL == (e = find_entry (cfg, section, option))) |
971 | return GNUNET_SYSERR; | 971 | return GNUNET_SYSERR; |
972 | if (NULL == e->val) | 972 | if (NULL == e->val) |
@@ -1748,7 +1748,9 @@ GNUNET_CONFIGURATION_load_from (struct GNUNET_CONFIGURATION_Handle *cfg, | |||
1748 | const char *defaults_d) | 1748 | const char *defaults_d) |
1749 | { | 1749 | { |
1750 | if (GNUNET_SYSERR == | 1750 | if (GNUNET_SYSERR == |
1751 | GNUNET_DISK_directory_scan (defaults_d, &parse_configuration_file, cfg)) | 1751 | GNUNET_DISK_directory_scan (defaults_d, |
1752 | &parse_configuration_file, | ||
1753 | cfg)) | ||
1752 | return GNUNET_SYSERR; /* no configuration at all found */ | 1754 | return GNUNET_SYSERR; /* no configuration at all found */ |
1753 | return GNUNET_OK; | 1755 | return GNUNET_OK; |
1754 | } | 1756 | } |
diff --git a/src/util/gnunet-config.c b/src/util/gnunet-config.c index 4528bbe24..46c523da4 100644 --- a/src/util/gnunet-config.c +++ b/src/util/gnunet-config.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -82,7 +82,7 @@ print_option (void *cls, | |||
82 | { | 82 | { |
83 | char *value_fn; | 83 | char *value_fn; |
84 | char *fn; | 84 | char *fn; |
85 | 85 | ||
86 | GNUNET_assert (GNUNET_OK == | 86 | GNUNET_assert (GNUNET_OK == |
87 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 87 | GNUNET_CONFIGURATION_get_value_filename (cfg, |
88 | section, | 88 | section, |
@@ -167,14 +167,19 @@ run (void *cls, | |||
167 | if (! list_sections) | 167 | if (! list_sections) |
168 | { | 168 | { |
169 | fprintf (stderr, | 169 | fprintf (stderr, |
170 | _("--section argument is required\n")); | 170 | _("%s or %s argument is required\n"), |
171 | "--section", | ||
172 | "--list-sections"); | ||
173 | ret = 1; | ||
174 | } | ||
175 | else | ||
176 | { | ||
177 | fprintf (stderr, | ||
178 | _("The following sections are available:\n")); | ||
179 | GNUNET_CONFIGURATION_iterate_sections (cfg, | ||
180 | &print_section_name, | ||
181 | NULL); | ||
171 | } | 182 | } |
172 | fprintf (stderr, | ||
173 | _("The following sections are available:\n")); | ||
174 | GNUNET_CONFIGURATION_iterate_sections (cfg, | ||
175 | &print_section_name, | ||
176 | NULL); | ||
177 | ret = 1; | ||
178 | goto cleanup; | 183 | goto cleanup; |
179 | } | 184 | } |
180 | 185 | ||
diff --git a/src/util/program.c b/src/util/program.c index 2a9b4fac9..da58348d0 100644 --- a/src/util/program.c +++ b/src/util/program.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPROSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPROSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -286,15 +286,10 @@ GNUNET_PROGRAM_run2 (int argc, | |||
286 | { | 286 | { |
287 | if (0 != strcmp (cc.cfgfile, | 287 | if (0 != strcmp (cc.cfgfile, |
288 | cfg_fn)) | 288 | cfg_fn)) |
289 | { | ||
289 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 290 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
290 | _("Could not access configuration file `%s'\n"), | 291 | _("Could not access configuration file `%s'\n"), |
291 | cc.cfgfile); | 292 | cc.cfgfile); |
292 | if (GNUNET_SYSERR == | ||
293 | GNUNET_CONFIGURATION_load (cfg, | ||
294 | NULL)) | ||
295 | { | ||
296 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
297 | _("Malformed configuration, exit ...\n")); | ||
298 | ret = GNUNET_SYSERR; | 293 | ret = GNUNET_SYSERR; |
299 | GNUNET_free (allopts); | 294 | GNUNET_free (allopts); |
300 | GNUNET_free (lpfx); | 295 | GNUNET_free (lpfx); |
diff --git a/src/util/service.c b/src/util/service.c index b61168570..2dc7dd576 100644 --- a/src/util/service.c +++ b/src/util/service.c | |||
@@ -11,7 +11,7 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | */ | 17 | */ |
@@ -1177,7 +1177,7 @@ setup_service (struct GNUNET_SERVICE_Handle *sh) | |||
1177 | int flags; | 1177 | int flags; |
1178 | char dummy[2]; | 1178 | char dummy[2]; |
1179 | #endif | 1179 | #endif |
1180 | 1180 | ||
1181 | if (GNUNET_CONFIGURATION_have_value | 1181 | if (GNUNET_CONFIGURATION_have_value |
1182 | (sh->cfg, | 1182 | (sh->cfg, |
1183 | sh->service_name, | 1183 | sh->service_name, |
@@ -1837,9 +1837,12 @@ GNUNET_SERVICE_run_ (int argc, | |||
1837 | } | 1837 | } |
1838 | if (0 != strcmp (opt_cfg_filename, | 1838 | if (0 != strcmp (opt_cfg_filename, |
1839 | cfg_filename)) | 1839 | cfg_filename)) |
1840 | { | ||
1840 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1841 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1841 | _("Could not access configuration file `%s'\n"), | 1842 | _("Could not access configuration file `%s'\n"), |
1842 | opt_cfg_filename); | 1843 | opt_cfg_filename); |
1844 | goto shutdown; | ||
1845 | } | ||
1843 | } | 1846 | } |
1844 | if (GNUNET_OK != setup_service (&sh)) | 1847 | if (GNUNET_OK != setup_service (&sh)) |
1845 | goto shutdown; | 1848 | goto shutdown; |