#include <freeradius-devel/util/dict_fixup_priv.h>
#include <freeradius-devel/util/file.h>
#include <freeradius-devel/util/rand.h>
+#include <freeradius-devel/util/strerror.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/value.h>
/*
* If fopen works, this works.
*/
- if (stat(fn, &statbuf) < 0) {
+ if (fstat(fileno(fp), &statbuf) < 0) {
+ fr_strerror_printf_push("Failed stating dictionary \"%s\" - %s", fn, fr_syserror(errno));
+
+ perm_error:
fclose(fp);
return -1;
}
if (!S_ISREG(statbuf.st_mode)) {
- fclose(fp);
fr_strerror_printf_push("Dictionary is not a regular file: %s", fn);
- return -1;
+ goto perm_error;
}
/*
fclose(fp);
fr_strerror_printf_push("Dictionary is globally writable: %s. "
"Refusing to start due to insecure configuration", fn);
- return -1;
+ goto perm_error;
}
#endif
*/
if (strcasecmp(argv[0], "ENUM") == 0) {
if (dict_read_process_enum(ctx,
- argv + 1, argc - 1,
- &base_flags) == -1) goto error;
+ argv + 1, argc - 1,
+ &base_flags) == -1) goto error;
continue;
}
if (ret < 0) {
fr_strerror_printf_push("from $INCLUDE at %s[%d]", fr_cwd_strip(fn), line);
- fclose(fp);
- return -1;
+ goto error;
}
if (ctx->stack_depth < stack_depth) {
fr_strerror_printf_push("unexpected END-??? in $INCLUDE at %s[%d]",
fr_cwd_strip(fn), line);
- fclose(fp);
- return -1;
+ goto error;
}
while (ctx->stack_depth > stack_depth) {
fr_strerror_printf_push("BEGIN-??? without END-... in file $INCLUDEd from %s[%d]",
fr_cwd_strip(fn), line);
- fclose(fp);
- return -1;
+ goto error;
}
/*
* error. So we don't need to do that
* here.
*/
- if (dict_finalise(ctx) < 0) {
- fclose(fp);
- return -1;
- }
+ if (dict_finalise(ctx) < 0) goto error;
ctx->stack_depth--;
ctx->dict = ctx->stack[ctx->stack_depth].dict;
goto error;
}
-
-
da = fr_dict_attr_by_oid(NULL, ctx->stack[ctx->stack_depth - 1].da, argv[1]);
if (!da) {
fr_strerror_const_push("Failed resolving attribute in END-TLV entry");
* was copied from the parent, so there are guaranteed to
* be missing things.
*/
-
fclose(fp);
+
return 0;
}