Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit6bbd8b7

Browse files
committed
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 samelogic as for GUCs, except that it has no need to know about DataDir asthere is always a calling file to rely to build the base directory path.The refactoring done ina1a7bb8 makes this move straight-forward, andunifies the code used for GUCs and authentication files, and theintention is to rely also on that for the upcoming patch to be able toinclude full files from HBA or ident files.Note that this gets rid of an inconsistency introduced in370f909, thatcopied the logic coming from GUCs but applied it for files included inauthentication files, where the result buffer given tojoin_path_components() must have a size of MAXPGPATH. Based on adouble-check of the existing code, all the other callers ofjoin_path_components() already do that, except the code path changedhere.Discussion:https://postgr.es/m/Y2igk7q8OMpg+Yta@paquier.xyz
1 parentf05a5e0 commit6bbd8b7

File tree

2 files changed

+4
-17
lines changed

2 files changed

+4
-17
lines changed

‎src/backend/libpq/hba.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
#include"storage/fd.h"
4242
#include"utils/acl.h"
4343
#include"utils/builtins.h"
44+
#include"utils/conffiles.h"
4445
#include"utils/guc.h"
4546
#include"utils/lsyscache.h"
4647
#include"utils/memutils.h"
@@ -466,21 +467,7 @@ tokenize_inc_file(List *tokens,
466467
ListCell*inc_line;
467468
MemoryContextlinecxt;
468469

469-
if (is_absolute_path(inc_filename))
470-
{
471-
/* absolute path is taken as-is */
472-
inc_fullname=pstrdup(inc_filename);
473-
}
474-
else
475-
{
476-
/* relative path is relative to dir of calling file */
477-
inc_fullname= (char*)palloc(strlen(outer_filename)+1+
478-
strlen(inc_filename)+1);
479-
strcpy(inc_fullname,outer_filename);
480-
get_parent_directory(inc_fullname);
481-
join_path_components(inc_fullname,inc_fullname,inc_filename);
482-
canonicalize_path(inc_fullname);
483-
}
470+
inc_fullname=AbsoluteConfigLocation(inc_filename,outer_filename);
484471

485472
inc_file=AllocateFile(inc_fullname,"r");
486473
if (inc_file==NULL)

‎src/backend/utils/misc/conffiles.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@
3535
char*
3636
AbsoluteConfigLocation(constchar*location,constchar*calling_file)
3737
{
38-
charabs_path[MAXPGPATH];
39-
4038
if (is_absolute_path(location))
4139
returnpstrdup(location);
4240
else
4341
{
42+
charabs_path[MAXPGPATH];
43+
4444
if (calling_file!=NULL)
4545
{
4646
strlcpy(abs_path,calling_file,sizeof(abs_path));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp