From 89208e7de1c477c8a49b559b36c3177ab1ff5645 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Tue, 3 Apr 2012 02:17:33 +0200 Subject: Ignore peer configs with errors in peer dirs instead of exiting --- src/config.y | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) (limited to 'src/config.y') diff --git a/src/config.y b/src/config.y index cbb58c7..df46f20 100644 --- a/src/config.y +++ b/src/config.y @@ -174,14 +174,18 @@ mode: TOK_TAP { conf->mode = MODE_TAP; } ; protocol: TOK_STRING { - if (!strcmp($1->str, "null")) + if (!strcmp($1->str, "null")) { conf->protocol = &fastd_protocol_null; + } #ifdef WITH_PROTOCOL_ECFXP - else if (!strcmp($1->str, "ecfxp")) + else if (!strcmp($1->str, "ecfxp")) { conf->protocol = &fastd_protocol_ec25519_fhmqvc_xsalsa20_poly1305; + } #endif - else - exit_error(ctx, "config error: invalid protocol `%s'", $1->str); + else { + fastd_config_error(&@$, ctx, conf, filename, depth, "invalid protocol"); + YYERROR; + } } ; @@ -227,7 +231,10 @@ peer_address: TOK_ADDR ':' port { peer_key: TOK_STRING { free(conf->peers->key); conf->peers->key = strdup($1->str); } ; -peer_include: TOK_STRING { fastd_read_config(ctx, conf, $1->str, true, depth); } +peer_include: TOK_STRING { + if (!fastd_read_config(ctx, conf, $1->str, true, depth)) + YYERROR; + } ; @@ -239,12 +246,16 @@ include: TOK_PEER TOK_STRING maybe_as { fastd_peer_config_new(ctx, conf); conf->peers->name = strdup($3->str); - fastd_read_config(ctx, conf, $2->str, true, depth); + if (!fastd_read_config(ctx, conf, $2->str, true, depth)) + YYERROR; } | TOK_PEERS TOK_FROM TOK_STRING { fastd_read_config_dir(ctx, conf, $3->str, depth); } - | TOK_STRING { fastd_read_config(ctx, conf, $1->str, false, depth); } + | TOK_STRING { + if (!fastd_read_config(ctx, conf, $1->str, false, depth)) + YYERROR; + } ; @@ -265,12 +276,14 @@ boolean: TOK_YES { $$ = true; } ; port: TOK_INTEGER { - if ($1 < 0 || $1 > 65635) - exit_error(ctx, "config error: invalid port %i", $1); + if ($1 < 0 || $1 > 65635) { + fastd_config_error(&@$, ctx, conf, filename, depth, "invalid port"); + YYERROR; + } $$ = htons($1); } ; %% void fastd_config_error(YYLTYPE *loc, fastd_context *ctx, fastd_config *conf, const char *filename, int depth, char *s) { - exit_error(ctx, "config error: %s at %s:%i:%i", s, filename, loc->first_line, loc->first_column); + pr_error(ctx, "config error: %s at %s:%i:%i", s, filename, loc->first_line, loc->first_column); } -- cgit v1.2.3