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

Commit11f063b

Browse files
committed
Remove some dead code in contrib/adminpack/
Since its introduction infe59e56, the code in charge of validating andconverting a file path includes some extra handling for absolute pathspointing to an external log_directory, but this has never been used.Author: Antonin HouskaReviewed-by: Julien Rouhaud, Michael PaquierDiscussion:https://postgr.es/m/32663.1581592539@antos
1 parenteb67623 commit11f063b

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

‎contrib/adminpack/adminpack.c

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ typedef struct
6969
* Convert a "text" filename argument to C string, and check it's allowable.
7070
*
7171
* Filename may be absolute or relative to the DataDir, but we only allow
72-
* absolute paths that match DataDir or Log_directory.
72+
* absolute paths that match DataDir.
7373
*/
7474
staticchar*
75-
convert_and_check_filename(text*arg,boollogAllowed)
75+
convert_and_check_filename(text*arg)
7676
{
7777
char*filename=text_to_cstring(arg);
7878

@@ -95,13 +95,8 @@ convert_and_check_filename(text *arg, bool logAllowed)
9595
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
9696
errmsg("reference to parent directory (\"..\") not allowed")));
9797

98-
/*
99-
* Allow absolute paths if within DataDir or Log_directory, even
100-
* though Log_directory might be outside DataDir.
101-
*/
102-
if (!path_is_prefix_of_path(DataDir,filename)&&
103-
(!logAllowed|| !is_absolute_path(Log_directory)||
104-
!path_is_prefix_of_path(Log_directory,filename)))
98+
/* Allow absolute paths if within DataDir */
99+
if (!path_is_prefix_of_path(DataDir,filename))
105100
ereport(ERROR,
106101
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
107102
errmsg("absolute path not allowed")));
@@ -185,7 +180,7 @@ pg_file_write_internal(text *file, text *data, bool replace)
185180
char*filename;
186181
int64count=0;
187182

188-
filename=convert_and_check_filename(file, false);
183+
filename=convert_and_check_filename(file);
189184

190185
if (!replace)
191186
{
@@ -228,7 +223,7 @@ pg_file_sync(PG_FUNCTION_ARGS)
228223
char*filename;
229224
structstatfst;
230225

231-
filename=convert_and_check_filename(PG_GETARG_TEXT_PP(0), false);
226+
filename=convert_and_check_filename(PG_GETARG_TEXT_PP(0));
232227

233228
if (stat(filename,&fst)<0)
234229
ereport(ERROR,
@@ -319,13 +314,13 @@ pg_file_rename_internal(text *file1, text *file2, text *file3)
319314
*fn3;
320315
intrc;
321316

322-
fn1=convert_and_check_filename(file1, false);
323-
fn2=convert_and_check_filename(file2, false);
317+
fn1=convert_and_check_filename(file1);
318+
fn2=convert_and_check_filename(file2);
324319

325320
if (file3==NULL)
326321
fn3=NULL;
327322
else
328-
fn3=convert_and_check_filename(file3, false);
323+
fn3=convert_and_check_filename(file3);
329324

330325
if (access(fn1,W_OK)<0)
331326
{
@@ -411,7 +406,7 @@ pg_file_unlink(PG_FUNCTION_ARGS)
411406

412407
requireSuperuser();
413408

414-
filename=convert_and_check_filename(PG_GETARG_TEXT_PP(0), false);
409+
filename=convert_and_check_filename(PG_GETARG_TEXT_PP(0));
415410

416411
if (access(filename,W_OK)<0)
417412
{
@@ -449,7 +444,7 @@ pg_file_unlink_v1_1(PG_FUNCTION_ARGS)
449444
{
450445
char*filename;
451446

452-
filename=convert_and_check_filename(PG_GETARG_TEXT_PP(0), false);
447+
filename=convert_and_check_filename(PG_GETARG_TEXT_PP(0));
453448

454449
if (access(filename,W_OK)<0)
455450
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp