Changeset 101 in openpam
- Timestamp:
- Apr 6, 2002, 5:17:44 PM (19 years ago)
- Location:
- trunk/lib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/pam_get_authtok.c
r100 r101 32 32 * SUCH DAMAGE. 33 33 * 34 * $P4: //depot/projects/openpam/lib/pam_get_authtok.c#1 3$34 * $P4: //depot/projects/openpam/lib/pam_get_authtok.c#14 $ 35 35 */ 36 36 37 37 #include <sys/param.h> 38 39 #include <stdlib.h> 38 40 39 41 #include <security/pam_appl.h> … … 96 98 if (r != PAM_SUCCESS) 97 99 return (r); 98 *authtok = resp; 99 return (pam_set_item(pamh, item, *authtok)); 100 r = pam_set_item(pamh, pitem, resp); 101 free(resp); 102 if (r != PAM_SUCCESS) 103 return (r); 104 return (pam_get_item(pamh, pitem, (const void **)authtok)); 100 105 } 101 106 … … 125 130 * 126 131 * The =prompt argument specifies a prompt to use if no token is cached. 127 * If =NULL, the =PAM_AUTHTOK_PROMPT or =PAM_OLDAUTHTOK_PROMPT item, as128 * a ppropriate, will be used. If that item is also =NULL, a hardcoded132 * If it is =NULL, the =PAM_AUTHTOK_PROMPT or =PAM_OLDAUTHTOK_PROMPT item, 133 * as appropriate, will be used. If that item is also =NULL, a hardcoded 129 134 * default prompt will be used. 130 135 * 131 136 * >pam_get_item 137 * >pam_get_user 132 138 */ -
trunk/lib/pam_get_user.c
r93 r101 32 32 * SUCH DAMAGE. 33 33 * 34 * $P4: //depot/projects/openpam/lib/pam_get_user.c#1 0$34 * $P4: //depot/projects/openpam/lib/pam_get_user.c#11 $ 35 35 */ 36 36 37 37 #include <sys/param.h> 38 39 #include <stdlib.h> 38 40 39 41 #include <security/pam_appl.h> … … 41 43 42 44 #include "openpam_impl.h" 45 46 const char user_prompt[] = "Login:"; 43 47 44 48 /* … … 54 58 const char *prompt) 55 59 { 56 char * p, *resp;60 char *resp; 57 61 int r; 58 62 … … 64 68 return (PAM_SUCCESS); 65 69 if (prompt == NULL) { 66 if (pam_get_item(pamh, PAM_USER_PROMPT,67 (const void **)&p) != PAM_SUCCESS || p== NULL)68 prompt = "Login: ";70 r = pam_get_item(pamh, PAM_USER_PROMPT, (const void **)&prompt); 71 if (r != PAM_SUCCESS || prompt == NULL) 72 prompt = user_prompt; 69 73 } 70 r = pam_prompt(pamh, PAM_PROMPT_ECHO_ON, &resp, 71 "%s", prompt ? prompt : p); 74 r = pam_prompt(pamh, PAM_PROMPT_ECHO_ON, &resp, "%s", prompt); 72 75 if (r != PAM_SUCCESS) 73 76 return (r); 74 *user = resp; 75 return (pam_set_item(pamh, PAM_USER, *user)); 77 r = pam_set_item(pamh, PAM_USER, resp); 78 free(resp); 79 if (r != PAM_SUCCESS) 80 return (r); 81 return (pam_get_item(pamh, PAM_USER, (const void **)user)); 76 82 } 77 83 … … 84 90 * !PAM_SYMBOL_ERR 85 91 */ 92 93 /** 94 * The =pam_get_user function returns the name of the target user, as 95 * specified to =pam_start. If no user was specified, nor set using 96 * =pam_set_item, =pam_get_user will prompt for a user name. Either way, 97 * a pointer to the user name is stored in the location pointed to by the 98 * =user argument. 99 100 * The =prompt argument specifies a prompt to use if no user name is 101 * cached. If it is =NULL, the =PAM_USER_PROMPT will be used. If that 102 * item is also =NULL, a hardcoded default prompt will be used. 103 * 104 * >pam_get_item 105 * >pam_get_authtok 106 */
Note: See TracChangeset
for help on using the changeset viewer.