Reputation: 7216
Hello I'd like to list all real users on Linux/*nix and it's data. I probably need to parse /etc/passwd
and /etc/shadow
and check if user have password.
The problem is that is not cross-platform (on *BSD there is no /etc/shadow
). Is there any cross-platform library/command I can use?
Upvotes: 2
Views: 1230
Reputation: 9331
See man pages for getpwent.
The getpwent() function returns a pointer to a structure containing the
broken-out fields of a record from the password database (e.g., the
local password file /etc/passwd, NIS, and LDAP).
I will add that if you want to check the passwords, look at getspent, getspnam for listing the shadow password file. The man page says that the getspent etc. functions might not be cross-platform though.
Upvotes: 2