34c34
< * $P4: //depot/projects/openpam/lib/pam_get_user.c#10 $
---
> * $P4: //depot/projects/openpam/lib/pam_get_user.c#11 $
38a39,40
> #include <stdlib.h>
>
43a46,47
> const char user_prompt[] = "Login:";
>
56c60
< char *p, *resp;
---
> char *resp;
66,68c70,72
< if (pam_get_item(pamh, PAM_USER_PROMPT,
< (const void **)&p) != PAM_SUCCESS || p == NULL)
< prompt = "Login: ";
---
> r = pam_get_item(pamh, PAM_USER_PROMPT, (const void **)&prompt);
> if (r != PAM_SUCCESS || prompt == NULL)
> prompt = user_prompt;
70,71c74
< r = pam_prompt(pamh, PAM_PROMPT_ECHO_ON, &resp,
< "%s", prompt ? prompt : p);
---
> r = pam_prompt(pamh, PAM_PROMPT_ECHO_ON, &resp, "%s", prompt);
74,75c77,81
< *user = resp;
< return (pam_set_item(pamh, PAM_USER, *user));
---
> r = pam_set_item(pamh, PAM_USER, resp);
> free(resp);
> if (r != PAM_SUCCESS)
> return (r);
> return (pam_get_item(pamh, PAM_USER, (const void **)user));
85a92,106
>
> /**
> * The =pam_get_user function returns the name of the target user, as
> * specified to =pam_start. If no user was specified, nor set using
> * =pam_set_item, =pam_get_user will prompt for a user name. Either way,
> * a pointer to the user name is stored in the location pointed to by the
> * =user argument.
>
> * The =prompt argument specifies a prompt to use if no user name is
> * cached. If it is =NULL, the =PAM_USER_PROMPT will be used. If that
> * item is also =NULL, a hardcoded default prompt will be used.
> *
> * >pam_get_item
> * >pam_get_authtok
> */
< * $P4: //depot/projects/openpam/lib/pam_get_user.c#10 $
---
> * $P4: //depot/projects/openpam/lib/pam_get_user.c#11 $
38a39,40
> #include <stdlib.h>
>
43a46,47
> const char user_prompt[] = "Login:";
>
56c60
< char *p, *resp;
---
> char *resp;
66,68c70,72
< if (pam_get_item(pamh, PAM_USER_PROMPT,
< (const void **)&p) != PAM_SUCCESS || p == NULL)
< prompt = "Login: ";
---
> r = pam_get_item(pamh, PAM_USER_PROMPT, (const void **)&prompt);
> if (r != PAM_SUCCESS || prompt == NULL)
> prompt = user_prompt;
70,71c74
< r = pam_prompt(pamh, PAM_PROMPT_ECHO_ON, &resp,
< "%s", prompt ? prompt : p);
---
> r = pam_prompt(pamh, PAM_PROMPT_ECHO_ON, &resp, "%s", prompt);
74,75c77,81
< *user = resp;
< return (pam_set_item(pamh, PAM_USER, *user));
---
> r = pam_set_item(pamh, PAM_USER, resp);
> free(resp);
> if (r != PAM_SUCCESS)
> return (r);
> return (pam_get_item(pamh, PAM_USER, (const void **)user));
85a92,106
>
> /**
> * The =pam_get_user function returns the name of the target user, as
> * specified to =pam_start. If no user was specified, nor set using
> * =pam_set_item, =pam_get_user will prompt for a user name. Either way,
> * a pointer to the user name is stored in the location pointed to by the
> * =user argument.
>
> * The =prompt argument specifies a prompt to use if no user name is
> * cached. If it is =NULL, the =PAM_USER_PROMPT will be used. If that
> * item is also =NULL, a hardcoded default prompt will be used.
> *
> * >pam_get_item
> * >pam_get_authtok
> */