I am writing a file transfer server app that uses PAM modules to authenticates users on our network (NIS). What I need to do is somehow obtain the newly authenicated user's userid. The code is to run on a SunOS.
uname -a
Code:
SunOS gandalf 5.9 Generic_118558-04 sun4u sparc SUNW,Sun-Fire-88
The only thing that I do with PAM, is to make sure that the user has a valid account on the network. Here is some of the relevant code (no need to show the login_conv() function, it just gets the username/pass over a socket)...
Code:
pam_handle_t *pamh = NULL;
int retval;
char *service = "other";
/* start / authenticate */
retval = pam_start(service, user, &conv, &pamh);
if (retval == PAM_SUCCESS) {
retval = pam_authenticate(pamh, 0);
} else {
// failure code
}
/* begin processing */
if (retval == PAM_SUCCESS) {
processUser();
} else {
// failure code
}
/* end */
if (pam_end(pamh, retval) != PAM_SUCCESS) {
// failure code
}
I have two questions:
1) Is it possible to obtain a user's id given their username with C?
2) Is it possible for PAM to obtain a user's id once they are authenticated?
I have checked the man pages, and have checked google, but to no avail. Thanks for any help.