tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Proposed chown(8)/chgrp(1) enhancement



On Sat, 29 Apr 2023, наб wrote:

On Fri, Apr 28, 2023 at 11:25:03PM +0000, RVP wrote:
On Fri, 28 Apr 2023, Paul Goyette wrote:
I propose the attached enhancement to chown/chgrp to avoid setting
a new user/group value if the desired values are already set.  The
change is pretty simple.
I don't think we need a flag for this. I think what you're proposing
should just be the default behaviour.
It probably shouldn't, since chown/chgrp clear SUID/SGID;
this change, as written, both (a) violates POSIX by no longer behaving
as-if XCU chown ran XSH chown(), and hence (b) changes existing behaviour.

OTOH if you add a
 && !(p->fts_statp->st_mode & 07000)
then that's probably fine.

Yeah, although it would be better to do the mode check only if chown
is NOT being executed by super-user (the SxID bits are not modified if
running as root).  Unfortunately the program doesn't (currently) know
if it is running as root or as some other user.

I've update my local copy of the to be

		...
		if (dflag &&
		    ( -1 == uid || p->fts_statp->st_uid == uid ) &&
		    ( -1 == gid || p->fts_statp->st_gid == gid ) &&
		    ( p->fts_statp->st_mode && 07000 ) == 0))
			continue;
		...

+--------------------+--------------------------+----------------------+
| Paul Goyette       | PGP Key fingerprint:     | E-mail addresses:    |
| (Retired)          | FA29 0E3B 35AF E8AE 6651 | paul%whooppee.com@localhost    |
| Software Developer | 0786 F758 55DE 53BA 7731 | pgoyette%netbsd.org@localhost  |
| & Network Engineer |                          | pgoyette99%gmail.com@localhost |
+--------------------+--------------------------+----------------------+


Home | Main Index | Thread Index | Old Index