From: Alan T. DeKok Date: Wed, 20 Sep 2023 17:54:01 +0000 (-0400) Subject: dup stdout / stderr if we can X-Git-Tag: release_3_2_4~137 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=08dbb545a391019e943584df9f08fb42932cb66e;p=thirdparty%2Ffreeradius-server.git dup stdout / stderr if we can Otherwise fall back to open(/dev/foo) --- diff --git a/src/main/exfile.c b/src/main/exfile.c index 59e6a05d80f..1b498cedb64 100644 --- a/src/main/exfile.c +++ b/src/main/exfile.c @@ -170,7 +170,20 @@ static int exfile_open_mkdir(exfile_t *ef, char const *filename, mode_t permissi oflag = O_RDWR; } - fd = open(filename, oflag, permissions); + /* + * Just dup stdout / stderr if it's possible. + */ + if ((default_log.dst == L_DST_STDOUT) && + (strcmp(filename, "/dev/stdout") == 0)) { + fd = dup(STDOUT_FILENO); + + } else if ((default_log.dst == L_DST_STDERR) && + (strcmp(filename, "/dev/stderr") == 0)) { + fd = dup(STDERR_FILENO); + } else { + fd = open(filename, oflag, permissions); + } + if (fd < 0) { fr_strerror_printf("Failed to open file %s: %s", filename, strerror(errno));