[cs631apue] /etc/passwd and getpwuid(3)
Jan Schaumann
jschauma at stevens.edu
Mon Sep 23 23:06:41 EDT 2024
Hello,
In class, I had wanted to demonstrate that removing
group/other read permissions from /etc/passwd would
lead to "ls -l" not being able to display usernames.
I forgot that on NetBSD, the user password database is
processed into a db(3) style database as /etc/pwd.db.
This allows for more efficient lookups by functions
like getpwuid(3) etc. (which we'll see in the
materials for this week).
So to demonstrate what I had intended:
apue$ ls -l
[ output shows usernames ]
apue$ sudo chmod go-r /etc/pwd.db
apue$ ls -l
[ output shows uids
For group names, just changing the permissions on
/etc/group suffice.
-Jan]
More information about the cs631apue
mailing list