Date: Sat, 4 Mar 2017 21:06:40 +0000 (UTC) From: Baptiste Daroussin <bapt@FreeBSD.org> To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r314679 - user/bapt/diff Message-ID: <201703042106.v24L6eR9070917@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: bapt Date: Sat Mar 4 21:06:40 2017 New Revision: 314679 URL: https://svnweb.freebsd.org/changeset/base/314679 Log: Fix passing diffing from stdin in capability mode Modified: user/bapt/diff/diffreg.c Modified: user/bapt/diff/diffreg.c ============================================================================== --- user/bapt/diff/diffreg.c Sat Mar 4 20:50:17 2017 (r314678) +++ user/bapt/diff/diffreg.c Sat Mar 4 21:06:40 2017 (r314679) @@ -425,8 +425,14 @@ diffreg(char *file1, char *file2, int fl err(2, "unable to limit rights on: %s", file1); if (cap_rights_limit(fileno(f2), &rights_ro) < 0) err(2, "unable to limit rights on: %s", file2); - if (caph_limit_stdio() == -1) - err(2, "unable to limit stdio"); + if (fileno(f1) == STDIN_FILENO || fileno(f2) == STDIN_FILENO) { + /* stding has already been limited */ + if (caph_limit_stderr() == -1) + err(2, "unable to limit stderr"); + if (caph_limit_stdout() == -1) + err(2, "unable to limit stdout"); + } else if (caph_limit_stdio() == -1) + err(2, "unable to limit stdio"); caph_cache_catpages(); if (cap_enter() < 0 && errno != ENOSYS)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201703042106.v24L6eR9070917>