From owner-svn-src-head@freebsd.org Mon Dec 12 18:56:41 2016 Return-Path: Delivered-To: svn-src-head@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 7F077C72B77; Mon, 12 Dec 2016 18:56:41 +0000 (UTC) (envelope-from robak@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 48035EFD; Mon, 12 Dec 2016 18:56:41 +0000 (UTC) (envelope-from robak@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBCIue3i077525; Mon, 12 Dec 2016 18:56:40 GMT (envelope-from robak@FreeBSD.org) Received: (from robak@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBCIuePK077524; Mon, 12 Dec 2016 18:56:40 GMT (envelope-from robak@FreeBSD.org) Message-Id: <201612121856.uBCIuePK077524@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: robak set sender to robak@FreeBSD.org using -f From: Bartek Rutkowski Date: Mon, 12 Dec 2016 18:56:40 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r309921 - head/bin/dd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 12 Dec 2016 18:56:41 -0000 Author: robak (ports committer) Date: Mon Dec 12 18:56:40 2016 New Revision: 309921 URL: https://svnweb.freebsd.org/changeset/base/309921 Log: Fix regression when stdin/out/err fds are are overridden by shell. Submitted by: Pawel Biernacki Reported by: ngie Approved by: ngie Sponsored by: Mysterious Code Ltd. Differential Revision: https://reviews.freebsd.org/D8543 Modified: head/bin/dd/dd.c Modified: head/bin/dd/dd.c ============================================================================== --- head/bin/dd/dd.c Mon Dec 12 18:55:41 2016 (r309920) +++ head/bin/dd/dd.c Mon Dec 12 18:56:40 2016 (r309921) @@ -142,8 +142,6 @@ setup(void) in.fd = open(in.name, O_RDONLY, 0); if (in.fd == -1) err(1, "%s", in.name); - if (caph_limit_stdin() == -1) - err(1, "unable to limit capability rights"); } getfdtype(&in); @@ -176,8 +174,6 @@ setup(void) } if (out.fd == -1) err(1, "%s", out.name); - if (caph_limit_stdout() == -1) - err(1, "unable to limit capability rights"); } getfdtype(&out); @@ -188,6 +184,16 @@ setup(void) errno != ENOSYS) err(1, "unable to limit capability rights"); + if (in.fd != STDIN_FILENO && out.fd != STDIN_FILENO) { + if (caph_limit_stdin() == -1) + err(1, "unable to limit capability rights"); + } + + if (in.fd != STDOUT_FILENO && out.fd != STDOUT_FILENO) { + if (caph_limit_stdout() == -1) + err(1, "unable to limit capability rights"); + } + if (in.fd != STDERR_FILENO && out.fd != STDERR_FILENO) { if (caph_limit_stderr() == -1) err(1, "unable to limit capability rights");