Changeset 100 in openpam
- Timestamp:
- Apr 6, 2002, 5:05:21 PM (19 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/security/openpam.h
r93 r100 32 32 * SUCH DAMAGE. 33 33 * 34 * $P4: //depot/projects/openpam/include/security/openpam.h#1 2$34 * $P4: //depot/projects/openpam/include/security/openpam.h#13 $ 35 35 */ 36 36 … … 66 66 int 67 67 pam_get_authtok(pam_handle_t *_pamh, 68 int _item, 68 69 const char **_authtok, 69 70 const char *_prompt); -
trunk/include/security/pam_constants.h
r93 r100 32 32 * SUCH DAMAGE. 33 33 * 34 * $P4: //depot/projects/openpam/include/security/pam_constants.h#1 2$34 * $P4: //depot/projects/openpam/include/security/pam_constants.h#13 $ 35 35 */ 36 36 … … 120 120 PAM_USER_PROMPT = 9, 121 121 PAM_AUTHTOK_PROMPT = 10, /* OpenPAM extension */ 122 PAM_OLDAUTHTOK_PROMPT = 11, /* OpenPAM extension */ 122 123 PAM_NUM_ITEMS /* OpenPAM extension */ 123 124 }; -
trunk/lib/pam_get_authtok.c
r93 r100 32 32 * SUCH DAMAGE. 33 33 * 34 * $P4: //depot/projects/openpam/lib/pam_get_authtok.c#1 2$34 * $P4: //depot/projects/openpam/lib/pam_get_authtok.c#13 $ 35 35 */ 36 36 … … 42 42 #include "openpam_impl.h" 43 43 44 const char authtok_prompt[] = "Password:"; 45 const char oldauthtok_prompt[] = "Old Password:"; 46 44 47 /* 45 48 * OpenPAM extension … … 50 53 int 51 54 pam_get_authtok(pam_handle_t *pamh, 55 int item, 52 56 const char **authtok, 53 57 const char *prompt) 54 58 { 55 char *p, *resp; 56 int r, style; 59 const char *default_prompt; 60 char *resp; 61 int pitem, r, style; 57 62 58 63 if (pamh == NULL || authtok == NULL) 59 64 return (PAM_SYSTEM_ERR); 60 65 66 *authtok = NULL; 67 switch (item) { 68 case PAM_AUTHTOK: 69 pitem = PAM_AUTHTOK_PROMPT; 70 default_prompt = authtok_prompt; 71 break; 72 case PAM_OLDAUTHTOK: 73 pitem = PAM_OLDAUTHTOK_PROMPT; 74 default_prompt = oldauthtok_prompt; 75 break; 76 default: 77 return (PAM_SYMBOL_ERR); 78 } 79 61 80 if (openpam_get_option(pamh, "try_first_pass") || 62 81 openpam_get_option(pamh, "use_first_pass")) { 63 r = pam_get_item(pamh, PAM_AUTHTOK, (const void **)authtok);82 r = pam_get_item(pamh, item, (const void **)authtok); 64 83 if (r == PAM_SUCCESS && *authtok != NULL) 65 84 return (PAM_SUCCESS); … … 67 86 return (r == PAM_SUCCESS ? PAM_AUTH_ERR : r); 68 87 } 69 if (pam_get_item(pamh, PAM_AUTHTOK_PROMPT, 70 (const void **)&p) != PAM_SUCCESS || p == NULL) 71 if (prompt == NULL) 72 prompt = "Password:"; 88 if (prompt == NULL) { 89 r = pam_get_item(pamh, pitem, (const void **)&prompt); 90 if (r != PAM_SUCCESS || prompt == NULL) 91 prompt = default_prompt; 92 } 73 93 style = openpam_get_option(pamh, "echo_pass") ? 74 94 PAM_PROMPT_ECHO_ON : PAM_PROMPT_ECHO_OFF; 75 r = pam_prompt(pamh, style, &resp, "%s", p ? p : prompt);95 r = pam_prompt(pamh, style, &resp, "%s", prompt); 76 96 if (r != PAM_SUCCESS) 77 97 return (r); 78 98 *authtok = resp; 79 return (pam_set_item(pamh, PAM_AUTHTOK, *authtok));99 return (pam_set_item(pamh, item, *authtok)); 80 100 } 81 101 … … 88 108 * !PAM_SYMBOL_ERR 89 109 */ 110 111 /** 112 * The =pam_get_authtok function returns the cached authentication token, 113 * or prompts the user if no token is currently cached. Either way, a 114 * pointer to the authentication token is stored in the location pointed 115 * to by the =authtok argument. 116 * 117 * The =item argument must have one of the following values: 118 * 119 * =PAM_AUTHTOK 120 * Returns the current authentication token, or the new token 121 * when changing authentication tokens. 122 * =PAM_OLDAUTHTOK 123 * Returns the previous authentication token when changing 124 * authentication tokens. 125 * 126 * 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, as 128 * appropriate, will be used. If that item is also =NULL, a hardcoded 129 * default prompt will be used. 130 * 131 * >pam_get_item 132 */ -
trunk/lib/pam_get_item.c
r93 r100 32 32 * SUCH DAMAGE. 33 33 * 34 * $P4: //depot/projects/openpam/lib/pam_get_item.c#1 0$34 * $P4: //depot/projects/openpam/lib/pam_get_item.c#11 $ 35 35 */ 36 36 … … 67 67 case PAM_USER_PROMPT: 68 68 case PAM_AUTHTOK_PROMPT: 69 case PAM_OLDAUTHTOK_PROMPT: 69 70 *item = pamh->item[item_type]; 70 71 return (PAM_SUCCESS); … … 113 114 * The prompt to use when asking the applicant for an 114 115 * authentication token. 116 * =PAM_OLDAUTHTOK_PROMPT: 117 * The prompt to use when asking the applicant for an 118 * expired authentication token prior to changing it. 115 119 * 116 120 * See =pam_start for a description of =struct pam_conv. -
trunk/lib/pam_set_item.c
r93 r100 32 32 * SUCH DAMAGE. 33 33 * 34 * $P4: //depot/projects/openpam/lib/pam_set_item.c#1 2$34 * $P4: //depot/projects/openpam/lib/pam_set_item.c#13 $ 35 35 */ 36 36 … … 74 74 case PAM_USER_PROMPT: 75 75 case PAM_AUTHTOK_PROMPT: 76 case PAM_OLDAUTHTOK_PROMPT: 76 77 if (*slot != NULL) 77 78 size = strlen(*slot) + 1;
Note: See TracChangeset
for help on using the changeset viewer.