Changeset 105 in openpam
- Timestamp:
- Apr 6, 2002, 9:23:26 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/pam_get_authtok.c
r101 r105 32 32 * SUCH DAMAGE. 33 33 * 34 * $P4: //depot/projects/openpam/lib/pam_get_authtok.c#1 4$34 * $P4: //depot/projects/openpam/lib/pam_get_authtok.c#15 $ 35 35 */ 36 36 … … 46 46 const char authtok_prompt[] = "Password:"; 47 47 const char oldauthtok_prompt[] = "Old Password:"; 48 const char newauthtok_prompt[] = "New Password:"; 48 49 49 50 /* … … 59 60 const char *prompt) 60 61 { 62 const void *oldauthtok; 61 63 const char *default_prompt; 62 char *resp ;63 int pitem, r, style ;64 char *resp, *resp2; 65 int pitem, r, style, twice; 64 66 65 67 if (pamh == NULL || authtok == NULL) … … 67 69 68 70 *authtok = NULL; 71 twice = 0; 69 72 switch (item) { 70 73 case PAM_AUTHTOK: 71 74 pitem = PAM_AUTHTOK_PROMPT; 72 75 default_prompt = authtok_prompt; 76 r = pam_get_item(pamh, PAM_OLDAUTHTOK, &oldauthtok); 77 if (r == PAM_SUCCESS && oldauthtok != NULL) { 78 default_prompt = newauthtok_prompt; 79 twice = 1; 80 } 73 81 break; 74 82 case PAM_OLDAUTHTOK: 75 83 pitem = PAM_OLDAUTHTOK_PROMPT; 76 84 default_prompt = oldauthtok_prompt; 85 twice = 0; 77 86 break; 78 87 default: … … 98 107 if (r != PAM_SUCCESS) 99 108 return (r); 109 if (twice) { 110 r = pam_prompt(pamh, style, &resp2, "Retype %s", prompt); 111 if (r != PAM_SUCCESS) { 112 free(resp); 113 return (r); 114 } 115 if (strcmp(resp, resp2) != 0) { 116 free(resp); 117 resp = NULL; 118 } 119 free(resp2); 120 } 121 if (resp == NULL) 122 return (PAM_TRY_AGAIN); 100 123 r = pam_set_item(pamh, pitem, resp); 101 124 free(resp); … … 112 135 * =pam_set_item 113 136 * !PAM_SYMBOL_ERR 137 * PAM_TRY_AGAIN 114 138 */ 115 139 … … 134 158 * default prompt will be used. 135 159 * 160 * If =item is set to =PAM_AUTHTOK and there is a non-null =PAM_OLDAUTHTOK 161 * item, =pam_get_authtok will ask the user to confirm the new token by 162 * retyping it. If there is a mismatch, =pam_get_authtok will return 163 * =PAM_TRY_AGAIN. 164 * 136 165 * >pam_get_item 137 166 * >pam_get_user
Note: See TracChangeset
for help on using the changeset viewer.