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
377c377,379
<       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:

- _POSIX_CHOWN_RESTRICTED is set
- 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
usual.

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 tv@pobox.com; Bus. todd_vierling@xn.xerox.com)