From nobody@FreeBSD.org  Fri Oct  2 19:11:00 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3546A10656A6
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  2 Oct 2009 19:11:00 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 24D2A8FC0A
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  2 Oct 2009 19:11:00 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id n92JAx05021670
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 2 Oct 2009 19:10:59 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id n92JAxYm021669;
	Fri, 2 Oct 2009 19:10:59 GMT
	(envelope-from nobody)
Message-Id: <200910021910.n92JAxYm021669@www.freebsd.org>
Date: Fri, 2 Oct 2009 19:10:59 GMT
From: Thomas Swan <thomas.swan@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: /usr/bin/install -d reports success on failure
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         139314
>Category:       bin
>Synopsis:       [patch] install(1): install -d reports success on failure
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          analyzed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 02 19:20:00 UTC 2009
>Closed-Date:    
>Last-Modified:  Sat Aug 21 19:47:49 UTC 2010
>Originator:     Thomas Swan
>Release:        4.x, 6.x, 7.x
>Organization:
>Environment:
FreeBSD localhost 7.2-STABLE FreeBSD 7.2-STABLE #0: Tue Aug  4 16:11:51 CDT 2009     root@localhost:/usr/obj/usr/src/sys/SMALL-SMP  i386
>Description:
/usr/bin/install exits zero when it should exit non-zero when installing a directory.  

install should exit non-zero according to the man page.
>How-To-Repeat:
as root:
# /usr/bin/install -d -m755 /tmp/root-owned

as a mortal:
$ /usr/bin/install -d -m755 /tmp/root-owned
install: chmod 755 /tmp/root-owned: Operation not permitted
$ echo $?
0
>Fix:


>Release-Note:
>Audit-Trail:

From: Mikolaj Golub <to.my.trociny@gmail.com>
To: Thomas Swan <thomas.swan@gmail.com>
Cc: bug-followup@FreeBSD.org
Subject: Re: bin/139314: /usr/bin/install -d reports success on failure
Date: Tue, 13 Oct 2009 23:18:39 +0300

 On Fri, 2 Oct 2009 19:10:59 GMT Thomas Swan wrote:
  TS> as root:
  TS> # /usr/bin/install -d -m755 /tmp/root-owned
 
  TS> as a mortal:
  TS> $ /usr/bin/install -d -m755 /tmp/root-owned
  TS> install: chmod 755 /tmp/root-owned: Operation not permitted
  TS> $ echo $?
  TS> 0
 
 Actually I am not 100% sure this is a bug. Please note, the message is that it
 was not able to chmod, not to create directory. install(1) considers this is
 as a warning, not a error message.
 
 If you try to create new directory then you will get error exit code:
 
 zhuzha:~% /usr/bin/install -d -m755 /tmp/root-owned/test
 install: mkdir /tmp/root-owned/test: Permission denied
 zhuzha:~% echo $?                                       
 71
 
 In the install code warn() is called when chmod() has failed. So if this still
 looks like a bug the patch is simple -- just replace warn(...) with
 err(EX_OSERR, ...).  But then may be the same thing should be done on chown()
 failure (currently warn() is called here too).
 
 -- 
 Mikolaj Golub
State-Changed-From-To: open->analyzed 
State-Changed-By: vwe 
State-Changed-When: Sat Aug 21 19:42:44 UTC 2010 
State-Changed-Why:  
I'm somewhat undecided about this report. 
IMO if a tool is being told to do one thing and it can't be done, it can be 
seen as a failure. If install is able to install a file / directory but isn't 
able to set modes or owner (when told do set them), it should be seen as a 
failed job (do everything right or signal error, but not do half the way right). 

Changing that may break a lot of places where install is being used. 
I've created a patch for that which is signalling a failure if mode or owner 
can't be set only when -T has been given. 

The patch can be found at: 
http://people.freebsd.org/~vwe/files/patches/pr139314_xinstall.diff 
but I'm really not happy about that. 
Either use something similar to my patch or we can close this PR as WONTFIX. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=139314 
>Unformatted:
