@@ -69,10 +69,10 @@ typedef struct
69
69
* Convert a "text" filename argument to C string, and check it's allowable.
70
70
*
71
71
* 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.
73
73
*/
74
74
static char *
75
- convert_and_check_filename (text * arg , bool logAllowed )
75
+ convert_and_check_filename (text * arg )
76
76
{
77
77
char * filename = text_to_cstring (arg );
78
78
@@ -95,13 +95,8 @@ convert_and_check_filename(text *arg, bool logAllowed)
95
95
(errcode (ERRCODE_INSUFFICIENT_PRIVILEGE ),
96
96
errmsg ("reference to parent directory (\"..\") not allowed" )));
97
97
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 ))
105
100
ereport (ERROR ,
106
101
(errcode (ERRCODE_INSUFFICIENT_PRIVILEGE ),
107
102
errmsg ("absolute path not allowed" )));
@@ -185,7 +180,7 @@ pg_file_write_internal(text *file, text *data, bool replace)
185
180
char * filename ;
186
181
int64 count = 0 ;
187
182
188
- filename = convert_and_check_filename (file , false );
183
+ filename = convert_and_check_filename (file );
189
184
190
185
if (!replace )
191
186
{
@@ -228,7 +223,7 @@ pg_file_sync(PG_FUNCTION_ARGS)
228
223
char * filename ;
229
224
struct stat fst ;
230
225
231
- filename = convert_and_check_filename (PG_GETARG_TEXT_PP (0 ), false );
226
+ filename = convert_and_check_filename (PG_GETARG_TEXT_PP (0 ));
232
227
233
228
if (stat (filename , & fst ) < 0 )
234
229
ereport (ERROR ,
@@ -319,13 +314,13 @@ pg_file_rename_internal(text *file1, text *file2, text *file3)
319
314
* fn3 ;
320
315
int rc ;
321
316
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 );
324
319
325
320
if (file3 == NULL )
326
321
fn3 = NULL ;
327
322
else
328
- fn3 = convert_and_check_filename (file3 , false );
323
+ fn3 = convert_and_check_filename (file3 );
329
324
330
325
if (access (fn1 , W_OK ) < 0 )
331
326
{
@@ -411,7 +406,7 @@ pg_file_unlink(PG_FUNCTION_ARGS)
411
406
412
407
requireSuperuser ();
413
408
414
- filename = convert_and_check_filename (PG_GETARG_TEXT_PP (0 ), false );
409
+ filename = convert_and_check_filename (PG_GETARG_TEXT_PP (0 ));
415
410
416
411
if (access (filename , W_OK ) < 0 )
417
412
{
@@ -449,7 +444,7 @@ pg_file_unlink_v1_1(PG_FUNCTION_ARGS)
449
444
{
450
445
char * filename ;
451
446
452
- filename = convert_and_check_filename (PG_GETARG_TEXT_PP (0 ), false );
447
+ filename = convert_and_check_filename (PG_GETARG_TEXT_PP (0 ));
453
448
454
449
if (access (filename , W_OK ) < 0 )
455
450
{
0 commit comments