Bug 139314 - [patch] install(1): install -d reports success on failure
Summary: [patch] install(1): install -d reports success on failure
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: Unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL: https://reviews.freebsd.org/D14626
Depends on:
Reported: 2009-10-02 20:20 UTC by Thomas Swan
Modified: 2018-03-08 16:34 UTC (History)
1 user (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Swan 2009-10-02 20:20:00 UTC
/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 $?
Comment 1 Mikolaj Golub 2009-10-13 21:18:39 UTC
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 $?                                       

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
Comment 2 Volker Werth freebsd_committer 2010-08-21 20:42:44 UTC
State Changed
From-To: open->analyzed

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: 
but I'm really not happy about that. 
Either use something similar to my patch or we can close this PR as WONTFIX.
Comment 3 Steve Wills freebsd_committer 2018-03-08 16:34:01 UTC
Updated the patch and created a review for it.