]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Don't set RLIMIT_FSIZE when dumping lease (#389)
authorColin McInnes <colin.mcinnes@vecima.com>
Tue, 29 Oct 2024 15:30:59 +0000 (09:30 -0600)
committerGitHub <noreply@github.com>
Tue, 29 Oct 2024 15:30:59 +0000 (15:30 +0000)
Check if output is a tty
If dumping lease, check stdout otherwise check stderr.

---------

Co-authored-by: Roy Marples <roy@marples.name>
src/privsep.c

index 45da237a9fdca4c571fad5f77b8176def6289870..98e8f4883b53737b22b4e5f8a85fc9fb676a1732 100644 (file)
@@ -125,6 +125,8 @@ static int
 ps_dropprivs(struct dhcpcd_ctx *ctx)
 {
        struct passwd *pw = ctx->ps_user;
+       int fd_out = ctx->options & DHCPCD_DUMPLEASE ?
+          STDOUT_FILENO : STDERR_FILENO;
 
        if (ctx->options & DHCPCD_LAUNCHER)
                logdebugx("chrooting as %s to %s", pw->pw_name, pw->pw_dir);
@@ -172,7 +174,7 @@ ps_dropprivs(struct dhcpcd_ctx *ctx)
         * Obviously this won't work if we are using a logfile
         * or redirecting stderr to a file. */
        if ((ctx->options & DHC_NOCHKIO) == DHC_NOCHKIO ||
-           (ctx->logfile == NULL && isatty(STDERR_FILENO) == 1))
+           (ctx->logfile == NULL && isatty(fd_out) == 1))
        {
                if (setrlimit(RLIMIT_FSIZE, &rzero) == -1)
                        logerr("setrlimit RLIMIT_FSIZE");