From 550c2bb5da56bd5a3c7f4073365a8a65ac6dc54c Mon Sep 17 00:00:00 2001 From: Colin McInnes Date: Tue, 29 Oct 2024 09:30:59 -0600 Subject: [PATCH] Don't set RLIMIT_FSIZE when dumping lease (#389) Check if output is a tty If dumping lease, check stdout otherwise check stderr. --------- Co-authored-by: Roy Marples --- src/privsep.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/privsep.c b/src/privsep.c index 45da237a..98e8f488 100644 --- a/src/privsep.c +++ b/src/privsep.c @@ -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"); -- 2.47.2