From c0cc45975c39e5a13f704958b14eb4e12496e0bc Mon Sep 17 00:00:00 2001 From: Yves Rutschle Date: Tue, 15 Apr 2025 22:27:27 +0200 Subject: [PATCH] clean up inline define --- common.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/common.c b/common.c index 22c81a3..db97490 100644 --- a/common.c +++ b/common.c @@ -986,6 +986,11 @@ void drop_privileges(const char* user_name, const char* chroot_path) } } + +#ifndef O_NOFOLLOW +#define O_NOFOLLOW 0 +#endif + /* Writes my PID */ void write_pid_file(const char* pidfile) { @@ -1001,12 +1006,8 @@ void write_pid_file(const char* pidfile) return; } - /* Open file with O_NOFOLLOW to prevent symlink attacks */ - fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC -#ifdef O_NOFOLLOW - | O_NOFOLLOW -#endif - ,0644); + /* Open file with O_NOFOLLOW to prevent symlink attacks (Similar to CVE-2020-28935) */ + fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW ,0644); if (fd == -1) { print_message(msg_system_error, "write_pid_file: %s: %s\n", pidfile, strerror(errno));