Skip to content

Commit

Permalink
Don't set RLIMIT_FSIZE when dumping lease (#389)
Browse files Browse the repository at this point in the history
Check if output is a tty
If dumping lease, check stdout otherwise check stderr.

---------

Co-authored-by: Roy Marples <[email protected]>
  • Loading branch information
ColinMcInnes and rsmarples authored Oct 29, 2024
1 parent 1b573da commit 550c2bb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/privsep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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");
Expand Down

0 comments on commit 550c2bb

Please sign in to comment.