Subject: setuid() question.
To: None <netbsd-help@NetBSD.ORG>
From: Kenneth Stailey <kstailey@leidecker.gsfc.nasa.gov>
List: netbsd-help
Date: 07/16/1996 19:02:24
When this sample program
#include <stdio.h>
#include <pwd.h>
main()
{
int rc;
struct passwd *pw;
if ((pw = getpwnam("uucp")) == NULL) {
perror("getpwnam");
exit(1);
}
rc = setuid(pw->pw_uid);
printf("return code from setuid(<uucp>) is %d\n", rc);
}
is compiled and the ownership and modes are setup like this:
-rwsr-xr-x 1 uucp sys 74725 Jul 10 15:03 setuid
sys@kestrel(83)>./setuid
return code from setuid(<uucp>) is 0
sys@kestrel(84)>uname -a
kestrel kestrel 3.2.0 V2.1.7 i386
kstailey@owl$ ./setuid
return code from setuid(<uucp>) is -1
kstailey@owl$ uname -a
NetBSD owl 1.2_ALPHA NetBSD 1.2_ALPHA (OWL) #1: Wed Jun 26 17:14:30 EDT 1996 kstailey@owl:/usr/src/sys/arch/i386/compile/OWL i386
Both of these systems claim to impliment POSIX. Which return code
from setuid() is the right one and why?