configuration: reject direct recursion

Ensure a configuration file can't include itself.

This is the same behaviour as core PostgreSQL.
This commit is contained in:
Ian Barwick
2020-05-14 15:32:04 +09:00
parent d59cadd5f6
commit ff4771ab02

View File

@@ -132,7 +132,15 @@ ProcessConfigFile(const char *base_dir, const char *config_file, const char *cal
abs_path = AbsoluteConfigLocation(base_dir, config_file, calling_file); abs_path = AbsoluteConfigLocation(base_dir, config_file, calling_file);
// XXX reject direct recursion. /* Reject direct recursion */
if (calling_file && strcmp(abs_path, calling_file) == 0)
{
item_list_append_format(error_list,
_("configuration file recursion in \"%s\""),
calling_file);
pfree(abs_path);
return false;
}
fp = fopen(abs_path, "r"); fp = fopen(abs_path, "r");
if (!fp) if (!fp)
@@ -188,7 +196,8 @@ ProcessConfigFp(FILE *fp, const char *config_file, const char *calling_file, con
OK = false; OK = false;
goto cleanup; goto cleanup;
} }
printf("ProcessConfigFp(): base: '%s' file: '%s'; calling: '%s'\n", base_dir, config_file, calling_file);
//printf("ProcessConfigFp(): base: '%s' file: '%s'; calling: '%s'\n", base_dir, config_file, calling_file);
/* /*
* Parse * Parse
*/ */