mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08:00
Use AbsoluteConfigLocation() when building an included path in hba.c
The code building an absolute path to a file included, as prefixed by '@' in authentication files, for user and database lists uses the same logic as for GUCs, except that it has no need to know about DataDir as there is always a calling file to rely to build the base directory path. The refactoring done ina1a7bb8
makes this move straight-forward, and unifies the code used for GUCs and authentication files, and the intention is to rely also on that for the upcoming patch to be able to include full files from HBA or ident files. Note that this gets rid of an inconsistency introduced in370f909
, that copied the logic coming from GUCs but applied it for files included in authentication files, where the result buffer given to join_path_components() must have a size of MAXPGPATH. Based on a double-check of the existing code, all the other callers of join_path_components() already do that, except the code path changed here. Discussion: https://postgr.es/m/Y2igk7q8OMpg+Yta@paquier.xyz
This commit is contained in:
parent
f05a5e0003
commit
6bbd8b7385
@ -41,6 +41,7 @@
|
||||
#include "storage/fd.h"
|
||||
#include "utils/acl.h"
|
||||
#include "utils/builtins.h"
|
||||
#include "utils/conffiles.h"
|
||||
#include "utils/guc.h"
|
||||
#include "utils/lsyscache.h"
|
||||
#include "utils/memutils.h"
|
||||
@ -466,21 +467,7 @@ tokenize_inc_file(List *tokens,
|
||||
ListCell *inc_line;
|
||||
MemoryContext linecxt;
|
||||
|
||||
if (is_absolute_path(inc_filename))
|
||||
{
|
||||
/* absolute path is taken as-is */
|
||||
inc_fullname = pstrdup(inc_filename);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* relative path is relative to dir of calling file */
|
||||
inc_fullname = (char *) palloc(strlen(outer_filename) + 1 +
|
||||
strlen(inc_filename) + 1);
|
||||
strcpy(inc_fullname, outer_filename);
|
||||
get_parent_directory(inc_fullname);
|
||||
join_path_components(inc_fullname, inc_fullname, inc_filename);
|
||||
canonicalize_path(inc_fullname);
|
||||
}
|
||||
inc_fullname = AbsoluteConfigLocation(inc_filename, outer_filename);
|
||||
|
||||
inc_file = AllocateFile(inc_fullname, "r");
|
||||
if (inc_file == NULL)
|
||||
|
@ -35,12 +35,12 @@
|
||||
char *
|
||||
AbsoluteConfigLocation(const char *location, const char *calling_file)
|
||||
{
|
||||
char abs_path[MAXPGPATH];
|
||||
|
||||
if (is_absolute_path(location))
|
||||
return pstrdup(location);
|
||||
else
|
||||
{
|
||||
char abs_path[MAXPGPATH];
|
||||
|
||||
if (calling_file != NULL)
|
||||
{
|
||||
strlcpy(abs_path, calling_file, sizeof(abs_path));
|
||||
|
Loading…
Reference in New Issue
Block a user