Mercurial > hg > dhcpcd
changeset 5396:541348d5a5a9 draft
privsep: Don't limit file writes if logging to a file
stderr could be redirected.
While here, there is no longer a need to redirect stderr or stdout
as they already have been in dhcpcd.
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Wed, 01 Jul 2020 11:45:06 +0100 |
| parents | 3ed7914080a9 |
| children | 4c2de9b44e60 |
| files | src/privsep.c |
| diffstat | 1 files changed, 3 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/src/privsep.c Tue Jun 30 22:06:00 2020 +0100 +++ b/src/privsep.c Wed Jul 01 11:45:06 2020 +0100 @@ -160,8 +160,9 @@ } /* Prohibit writing to files. - * Obviously this won't work if we are using a logfile. */ - if (ctx->logfile == NULL) { + * Obviously this won't work if we are using a logfile + * or redirecting stderr to a file. */ + if (ctx->logfile == NULL && isatty(loggeterrfd())) { if (setrlimit(RLIMIT_FSIZE, &rzero) == -1) logerr("setrlimit RLIMIT_FSIZE"); } @@ -365,14 +366,6 @@ if (callback(recv_ctx) == -1) goto errexit; - if (!(ctx->options & DHCPCD_DEBUG) && - (!(ctx->options & DHCPCD_TEST) || loggetopts() & LOGERR_QUIET)) - { - if (freopen(_PATH_DEVNULL, "w", stdout) == NULL || - freopen(_PATH_DEVNULL, "w", stderr) == NULL) - logerr("%s: freopen", __func__); - } - if (flags & PSF_DROPPRIVS) ps_dropprivs(ctx);
