C function to test existence of a login

Hi everybody,

I need to check in C program whether a given login is known on the system. Is there any system function that could do this ?

So far, all I could find is getpwnam(), which answers my problem by parsing the local password database. But won't work if a user is authenticated by other means (PAM, Kerberos, ...).

I am surprised not to have found anything on that topic, because any shell is able to resolve a user's HOME while doing the tilde expansion, but how is it done? I had a look at the shell C sources, but I am a bit lost. Also, I don't have a system with network authentication handy, so I can't ktrace /bin/sh while doing a tilde expansion to see what function is called...

Thanks in advance, any help much appreciated.

Xavier

Did you check man wtmp or man wtmpx?

Hi, the discussion has moved here, indeed:

X.