Subject: install(1) vs. chown change
To: None <current-users@NetBSD.ORG>
From: Todd Vierling <tv@NetBSD.ORG>
List: current-users
Date: 03/06/1998 12:02:41
I reread PR #3563 today relating to some annoyances in building a couple
packages, and I have thought about how to allow a very slim set of
circumstances through install(1) to allow -o/-g (set owner and group) to
fail silently when the user is not root.  I have the following diff. 

diff -r1.25 xinstall.c
<       if ((gid != -1 || uid != -1) && fchown(to_fd, uid, gid)) {
>       if ((gid != -1 || uid != -1) && fchown(to_fd, uid, gid) &&
>           (!_POSIX_CHOWN_RESTRICTED || errno != EPERM || geteuid() == 0 ||
>            mode & (S_ISUID|S_ISGID|S_ISVTX))) {

What this does here is allow fchown() to fail silently only if:

- errno is equal to EPERM
- the user is not root
- the mode of the file to be set is not setuid, setgid, or sticky

If any of these four conditions are false, install(1) will still exit as

Are there any objections or modifications to this?  Would anybody prefer it
to warn the user (to continue operating) instead of silently fail if the
above conditions hold? 

-- Todd Vierling (Personal; Bus.