Do not use the absolute path

This commit is contained in:
Victor Polevoy
2025-07-15 11:27:36 +02:00
parent 32293ed6bc
commit 005d274c22
2 changed files with 3 additions and 28 deletions
-1
View File
@@ -2,7 +2,6 @@
//! - async tokio communicator core, which receives requests and processes them.
//! - Main loop and requests queues, which routes requests from backends to the core
//! - the per-backend glue code, which submits requests
#![warn(unused)]
mod backend_comms;
+3 -27
View File
@@ -178,32 +178,6 @@ assign_request_id(void)
return result;
}
/*
* Returns the absolute path to the given path.
*/
static inline char * get_absolute_path(const char *path)
{
char *abs_path = bounce_buf();
char cwd[PATH_MAX];
int size = 0;
if (path[0] == '/') {
strncpy(abs_path, path, strlen(path));
return abs_path;
}
getcwd(cwd, sizeof(cwd));
size = snprintf(NULL, 0, "%s/%s", cwd, path);
if (size < 0 || size >= PATH_MAX) {
return NULL;
}
snprintf(abs_path, size + 1, "%s/%s", cwd, path);
return abs_path;
}
/**** Initialization functions. These run in postmaster ****/
void
@@ -1041,13 +1015,15 @@ communicator_new_read_slru_segment(
}
};
int nblocks = -1;
char *abs_path = bounce_buf();
if (path == NULL) {
elog(ERROR, "read_slru_segment called with NULL path");
return -1;
}
request.read_slru_segment.destination_file_path.ptr = (uint8_t *) get_absolute_path(path);
strlcpy(abs_path, path, Min(PATH_MAX, strlen(path) + 1));
request.read_slru_segment.destination_file_path.ptr = (uint8_t *) abs_path;
elog(DEBUG5, "readslrusegment called for kind=%u, segno=%u, file_path=\"%s\"",
kind, segno, request.read_slru_segment.destination_file_path.ptr);