Why reinvent the wheel? [root@black ~]# getent passwd 1 daemon:*:1:1:The devil himself:/root:/sbin/nologin [root@black ~]#
-mike On May 7, 2013, at 4:06 AM, Friedrich Locke <friedrich.lo...@gmail.com> wrote: > Dear list members, > > I am in need to write a simple program to return the passwd entry for a > given uid number. > > Here you have it: > > #include <sys/types.h> > #include <errno.h> > #include <pwd.h> > #include <stdio.h> > > int > main(int argc, char **argv) > { > struct passwd *p; > int e; > > e = errno, errno = 0; > p = getpwuid(0); > if (errno) { > fprintf(stdout, "errno is: %u\n", errno); > return 127; > } > errno = e; > > fprintf(stdout, "%s\n", p->pw_name); > return 0; > } > > > When i execute it i get this on a openbsd: > > sioux@lion$ ./pw > errno is: 13 > sioux@lion$ > > > Any ideia why openbsd implementation of getpwuid returns error ? > > Thanks in advance.