/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 $?
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 $?
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).
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.
Updated the patch and created a review for it.