From 8004abbb9ccf59c8d4fd63d5ef4981c5463dee48 Mon Sep 17 00:00:00 2001 From: Mikhail Kot Date: Tue, 24 Jun 2025 12:50:59 +0100 Subject: [PATCH] fix --- pgxn/neon_walredo/walredoproc.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/pgxn/neon_walredo/walredoproc.c b/pgxn/neon_walredo/walredoproc.c index 49285c9487..175541ae82 100644 --- a/pgxn/neon_walredo/walredoproc.c +++ b/pgxn/neon_walredo/walredoproc.c @@ -160,7 +160,7 @@ static XLogReaderState *reader_state; * fail the build deliberately rather than ifdef'ing it to ENOSYS. * We prefer a compile time over a runtime error for walredo. * - * If, however, we need to build on old systems for development, e.g. Ubuntu 20 + * If, however, we need to build on old systems for development, e.g. Ubuntu 20.04 * with glibc 2.31, provide a NO_CLOSE_RANGE macro for suboptimal implementation */ #include @@ -210,22 +210,27 @@ enter_seccomp_mode(void) * wal records. See the comment in the Rust code that launches this process. */ #define START_FD 3 +#define STR(s) #s #ifdef __NR_close_range if (syscall(__NR_close_range, START_FD, ~0U, 0) != 0) ereport(FATAL, (errcode(ERRCODE_SYSTEM_ERROR), - errmsg("seccomp: could not close files >= fd START_FD"))); + errmsg("seccomp: could not close files >= " STR(START_FD)))); #else // close_range can return EINVAL -- not our case as start_fd and end_fd are hardcoded. // It doesn't return any other errors if CLOSE_RANGE_UNSHARE is not set so we don't - // report any errors here + // report any errors here. #ifdef NO_CLOSE_RANGE - #warning "__NR_close_range unavailable, using suboptimal implementation" + #warning + "__NR_close_range is not defined which means you're using kernel < 5.9." + "Using suboptimal implementation. Do NOT use this in production" int fd; for (fd = START_FD; fd <= INT_MAX; ++fd) close(fd); #else - #error "__NR_close_range syscall not defined, NO_CLOSE_RANGE not defined either" + #error + "__NR_close_range is not defined which means you're using kernel < 5.9." + "Define NO_CLOSE_RANGE for local development" #endif #endif