Commit b1414bff authored by Linus Nordberg's avatar Linus Nordberg

Make radsecproxy-conf exit with !0 if it finds syntax errors in config file.

Note that this is a syntax check only.  Passing this test doesn't mean
that the config file is good for running radsecproxy!
parent 9c5cd8f6
...@@ -5,16 +5,17 @@ ...@@ -5,16 +5,17 @@
#include "debug.h" #include "debug.h"
#include "gconfig.h" #include "gconfig.h"
void listconfig(struct gconffile **cf, char *block, int compact) { int listconfig(struct gconffile **cf, char *block, int compact) {
char *opt = NULL, *val = NULL; char *opt = NULL, *val = NULL;
int conftype; int conftype;
for (;;) { for (;;) {
free(opt); free(opt);
free(val); free(val);
getconfigline(cf, block, &opt, &val, &conftype); if (!getconfigline(cf, block, &opt, &val, &conftype))
if (!opt) return -1;
return; if (!opt)
return 0; /* Success. */
if (conftype == CONF_STR && !strcasecmp(opt, "include")) { if (conftype == CONF_STR && !strcasecmp(opt, "include")) {
if (!pushgconfpaths(cf, val)) if (!pushgconfpaths(cf, val))
...@@ -31,13 +32,17 @@ void listconfig(struct gconffile **cf, char *block, int compact) { ...@@ -31,13 +32,17 @@ void listconfig(struct gconffile **cf, char *block, int compact) {
break; break;
case CONF_CBK: case CONF_CBK:
printf("%s %s {%s", opt, val, compact ? "" : "\n"); printf("%s %s {%s", opt, val, compact ? "" : "\n");
listconfig(cf, val, compact); if (listconfig(cf, val, compact))
return -1;
printf("}\n"); printf("}\n");
break; break;
default: default:
printf("Unsupported config type\n"); printf("Unsupported config type\n");
return -1;
} }
} }
return 0; /* Success. */
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
...@@ -60,8 +65,7 @@ int main(int argc, char **argv) { ...@@ -60,8 +65,7 @@ int main(int argc, char **argv) {
goto usage; goto usage;
cfs = openconfigfile(argv[optind]); cfs = openconfigfile(argv[optind]);
listconfig(&cfs, NULL, compact); return listconfig(&cfs, NULL, compact);
return 0;
usage: usage:
debug(DBG_ERR, "Usage:\n%s [ -c ] configfile", argv[0]); debug(DBG_ERR, "Usage:\n%s [ -c ] configfile", argv[0]);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment