From owner-svn-src-user@freebsd.org Sat Mar 4 21:06:41 2017 Return-Path: Delivered-To: svn-src-user@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id CB538CF9F2B for ; Sat, 4 Mar 2017 21:06:41 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 98BCF1641; Sat, 4 Mar 2017 21:06:41 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v24L6eEp070918; Sat, 4 Mar 2017 21:06:40 GMT (envelope-from bapt@FreeBSD.org) Received: (from bapt@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v24L6eR9070917; Sat, 4 Mar 2017 21:06:40 GMT (envelope-from bapt@FreeBSD.org) Message-Id: <201703042106.v24L6eR9070917@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: bapt set sender to bapt@FreeBSD.org using -f From: Baptiste Daroussin Date: Sat, 4 Mar 2017 21:06:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org Subject: svn commit: r314679 - user/bapt/diff X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 04 Mar 2017 21:06:41 -0000 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)