On Mon, May 6, 2013 at 7:51 PM, Friedrich Locke
<[email protected]> wrote:
> As Noah Pugsley noted: it should have worked, regardless error checking
> code is not right.
>
> As asked:
>
> sioux@scallop$ ls -l /etc/pwd.db /etc/spwd.db
> -rw-r--r-- 1 root wheel 1220608 May 1 12:41 /etc/pwd.db
> -rw-r----- 1 root _shadow 1273856 May 1 12:41 /etc/spwd.db
> sioux@scallop$
>
> I am running as and ordinary user.
i'm surprised most obvious question isn't being asked: OBSD version,
or more generically dmesg output.
$ cat > /tmp/s.c
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <pwd.h>
int main(int argc, char *argv[])
{
int e;
struct passwd *p;
e = errno;
errno = 0;
p = getpwuid(0);
printf("p=%p\nerrno=%d\n", p, errno);
if (p)
printf("pw_name=%s\n", p->pw_name);
endpwent();
printf("\n--patrick\n");
exit(0);
}
$ cc -g -O0 /tmp/s.c -o /tmp/s
$ /tmp/s
p=0x17cdf179a960
errno=0
pw_name=root
--patrick