Mercurial > hg > dhcpcd
changeset 5443:2d1bbc57daeb draft
privsep: limit rights for stdout/stderr/stdin using capsicum
| author | Roy Marples <roy@marples.name> |
|---|---|
| date | Sun, 06 Sep 2020 11:57:19 +0100 |
| parents | a069d919d44c |
| children | d861892268ff |
| files | src/privsep.c |
| diffstat | 1 files changed, 13 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/src/privsep.c Sun Sep 06 03:01:49 2020 +0100 +++ b/src/privsep.c Sun Sep 06 11:57:19 2020 +0100 @@ -75,6 +75,8 @@ #ifdef HAVE_CAPSICUM #include <sys/capsicum.h> +#include <capsicum_helpers.h> +#define ps_rights_limit_stdio caph_limit_stdio #endif #ifdef HAVE_UTIL_H #include <util.h> @@ -340,6 +342,14 @@ close(ctx->ps_root_fd); ctx->ps_root_fd = -1; } + +#ifdef PRIVSEP_RIGHTS + /* We cannot limit the root process in any way. */ + if (ps_rights_limit_stdio() == -1) { + logerr("ps_rights_limit_stdio"); + goto errexit; + } +#endif } if (priv_fd != &ctx->ps_inet_fd && ctx->ps_inet_fd != -1) { @@ -470,9 +480,9 @@ } #ifdef PRIVSEP_RIGHTS - if ((ps_rights_limit_ioctl(ctx->pf_inet_fd) == -1 || - ps_rights_limit_fd(ctx->link_fd) == -1) && - errno != ENOSYS) + if (ps_rights_limit_ioctl(ctx->pf_inet_fd) == -1 || + ps_rights_limit_fd(ctx->link_fd) == -1 || + ps_rights_limit_stdio() == -1) { logerr("%s: cap_rights_limit", __func__); return -1;
