From owner-svn-src-all@FreeBSD.ORG Fri Sep 21 11:36:59 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 503E01065677; Fri, 21 Sep 2012 11:36:59 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (unknown [IPv6:2001:610:1108:5012::107]) by mx1.freebsd.org (Postfix) with ESMTP id D953C8FC26; Fri, 21 Sep 2012 11:36:58 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id D8B7D12013D; Fri, 21 Sep 2012 13:36:54 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id B53E72847B; Fri, 21 Sep 2012 13:36:54 +0200 (CEST) Date: Fri, 21 Sep 2012 13:36:54 +0200 From: Jilles Tjoelker To: Devin Teske Message-ID: <20120921113654.GA7865@stack.nl> References: <201209210136.q8L1aKiF031991@svn.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201209210136.q8L1aKiF031991@svn.freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r240770 - in head/usr.sbin/bsdconfig: . console mouse networking networking/share share startup startup/share timezone/share usermgmt/share X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Sep 2012 11:36:59 -0000 On Fri, Sep 21, 2012 at 01:36:20AM +0000, Devin Teske wrote: > Author: dteske > Date: Fri Sep 21 01:36:20 2012 > New Revision: 240770 > URL: http://svn.freebsd.org/changeset/base/240770 > Log: > Replace redirections to /dev/null with "close file-descriptor" syntax (>&-). > Reviewed by: adrian (co-mentor) > Approved by: adrian (co-mentor) > [snip] > Modified: head/usr.sbin/bsdconfig/bsdconfig > ============================================================================== > --- head/usr.sbin/bsdconfig/bsdconfig Fri Sep 21 00:36:35 2012 (r240769) > +++ head/usr.sbin/bsdconfig/bsdconfig Fri Sep 21 01:36:20 2012 (r240770) > @@ -73,7 +73,7 @@ usage() > # Determine the maximum width of terminal/console > # > local max_size max_width > - max_size=$( stty size 2> /dev/null ) > + max_size=$( stty size 2>&- ) > : ${max_size:="24 80"} > max_width="${max_size#*[$IFS]}" > f_dprintf "max_width=[$max_width]" > [snip] This change is risky because it may cause error messages to be written to unexpected files. The first file the utility opens will be fd 2, and if something decides to write an error message to fd 2 it will try to write to that file. For this reason, the kernel will automatically open /dev/null if you execute suid/sgid binaries with fd 0, 1 and/or 2 closed. Particularly with fd 1 (>&-) there is another danger in that the output may fail with [EBADF] rather than being silently discarded. This may cause unexpected failures. If the reason is that there may be no /dev/null, then you will have to change the environment such that there will be a /dev/null. -- Jilles Tjoelker