[net.unix-wizards] Query about setuid

johnm@nvuxd.UUCP (J. Montgomery) (02/07/85)

<eat me>

I have run the following program on a System V VAX and on a
newly aquired Pyramid 90x (I ran it setuid to uucp):

#include <stdio.h>

main()
{
        int Uid, Euid;

        Uid = getuid();
        Euid = geteuid();
        printf("uid = %d euid = %d\n", Uid, Euid);

        printf("setuid(%d) returns %d\n", Uid, setuid(Uid));
        printf("uid = %d euid = %d\n", getuid(), geteuid());

        printf("setuid(%d) returns %d\n", Euid, setuid(Euid));
        printf("uid = %d euid = %d\n", getuid(), geteuid());
}

on the VAX (USG 5.0.5) it gives

uid = 882 euid = 5
setuid(882) returns 0
uid = 882 euid = 882
setuid(5) returns 0
uid = 882 euid = 5

on the Pyramid it gives

uid = 100 euid = 5
setuid(100) returns -1
uid = 100 euid = 100
setuid(5) returns -1
uid = 100 euid = 100

I'm wondering which is correct.  The behavior of the Pyramid will
break some things I have on the VAX (including, I believe, the
honey danber uucp).  I'm assuming that (at least in the att universe)
the Pyramid is broken.  What should 4.2 do?  Please reply by mail,
I'll forward or post replies if there is interest.
-- 
	John Montgomery
	Bell Communications Research
	...{allegra,ihnp4}!nvuxd!johnm

Ron Natalie <ron@BRL-TGR> (02/10/85)

The VAX version is only valid for System V release 2 or later.  Prior
to that it was always illegal to set the UID to something other than
the real uid if you were not the superuser.  In VR2 you are allowed
to return to the value you were originally invoked as.

First, remember that the Pyramid UNIX (OS/x) has both System V and 4.2
modes.  Assuming bsd mode, It would seem that the Pyramid is wrong for
not doing the first case, since setting the effective to the real is
allowed (and it did do it). In the second case, it is correct.  4.2 only
allows the real to be set to the effective and vice versa.  Note that
setuid() will set both the real and the effective on 4.2.  There are
other calls to set them individually.

Perhaps you should try the Pyramid in Sys5 mode?

-Ron