Subject: Re: Setreuid not working as specified in NetBSD 1.0/i386
To: Curt Sampson <curt@portal.ca>
From: Ian Lance Taylor <ian@airs.com>
List: netbsd-users
Date: 08/10/1995 22:32:59
> Unfortuately, it seems that setreuid() doesn't set the real user ID
> as it's supposed to, or at least doesn't do it in a way that makes
> getuid() return the correct value. I can swap the two IDs back if I
> give it the original euid, but I don't get that original euid back from
> getuid():
On most systems the setreuid function does not work in this fashion.
It seems like a gratuitous incompatibility. I didn't make up my usage
of setreuid; I stole it from kermit.
> $ cat ts.c
> /* test reversal of setreuid */
>
> #include <sys/types.h>
> #include <unistd.h>
>
> main()
> {
> printf("uid: %d euid: %d\n", getuid(), geteuid());
> printf("setreuid = %d\n", setreuid(geteuid(), getuid()));
> printf("uid: %d euid: %d\n", getuid(), geteuid());
> printf("setreuid = %d\n", setreuid(geteuid(), getuid()));
> printf("uid: %d euid: %d\n", getuid(), geteuid());
> }
> $ ls -l ts
> -rwsr-xr-x 1 uucp staff 13974 Aug 10 18:16 ts
> $ ./ts
> uid: 1000 euid: 66
> setreuid = 0
> uid: 1000 euid: 1000
> setreuid = 0
> uid: 1000 euid: 1000
On my Ultrix (BSD4.2 based) system:
comton> ls -l foo
-rwsrwxr-x 1 uucp users 50112 Aug 10 22:29 foo*
comton> ./foo
uid: 269 euid: 4
setreuid = 0
uid: 4 euid: 269
setreuid = 0
uid: 269 euid: 4
--
Ian Taylor | ian@airs.com | First to identify quote wins free e-mail message:
``[I]n Paris, for example, in 1660 there were 103 holidays in the year.''