jschauma at stevens.edu
Fri Oct 12 21:30:52 EDT 2018
Aubhik Mazumdar <amazumda at stevens.edu> wrote:
> Initially I was facing segfaults while printing the username and group
> name retrieved using getpwuid and getgruid.
getpwuid(3) and getgrgid(3) do not require root access.
> This was because the /etc/passwd and shadow files cannot be accessed
> if you are not root.
Unless your system is broken, /etc/passwd must be readable by regular
users. /etc/shadow does not exist on NetBSD, but the equivalent
/etc/master.passwd requires super-user privileges, but that file is not
used when using getpwuid(3).
More information about the cs631apue