Subject: Re: commoning up code that changes uids and gids
To: Jaromir Dolecek <jdolecek@netbsd.org>
From: David Laight <david@l8s.co.uk>
List: tech-kern
Date: 03/04/2003 09:57:26
On Tue, Mar 04, 2003 at 09:57:36AM +0100, Jaromir Dolecek wrote:
> While commoditation like this is in principle good thing, I don't
> think it's wise to do if you are not 200% sure you are right.
> E.g. I'm not sure if this in sys_setregid():
>
> > + if (rgid == -1)
> > + rgid = p->p_cred->p_rgid;
> > ...
> > + svgid = rgid == p->p_cred->p_rgid ? -1 : egid;
>
> is bug or uncommented code shortcut or harmless completely.
It actually matches the man page better than the old code!
If rgid or egid is -1, the current gid is filled in by the system.
and:
If the real group ID is changed, the saved group ID is changed
to the new value of the effective group ID.
> Did you confirm the semantics for compat code matches
> previous state? E.g. linux_misc.c/linux_misc_notalpha.c has
> this comment:
>
> /*
> * Note: These checks are a little different than the NetBSD
> * setreuid(2) call performs. This precisely follows the
> * behavior of the Linux kernel.
> */
I read the existing code VERY carefully and implemented what it
actually did.
David
--
David Laight: david@l8s.co.uk