Changeset 455 in openpam
- Timestamp:
- 10/29/11 18:31:11 (19 months ago)
- Location:
- trunk
- Files:
-
- 1 added
- 6 edited
-
HISTORY (modified) (1 diff)
-
doc/man/Makefile.am (modified) (1 diff)
-
include/security/openpam.h (modified) (1 diff)
-
lib/Makefile.am (modified) (1 diff)
-
lib/openpam_subst.c (added)
-
lib/pam_get_authtok.c (modified) (6 diffs)
-
lib/pam_get_user.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/HISTORY
r453 r455 3 3 - ENHANCE: removed static build autodetection, which didn't work anyway. 4 4 Use an explicit, user-specified preprocessor variable instead. 5 6 - ENHANCE: cleaned up the documentation a bit. 7 8 - ENHANCE: added openpam_subst(3), allowing certain PAM items to be 9 embedded in strings such as prompts. Apply it to the prompts used 10 by pam_get_user(3) and pam_get_authtok(3). 11 12 - ENHANCE: add support for the user_prompt, authtok_prompt and 13 oldauthtok_prompt module options, which override the prompts passed 14 by the module to pam_set_user(3) and pam_get_authtok(3). 5 15 ============================================================================ 6 16 OpenPAM Hydrangea 2007-12-21 -
trunk/doc/man/Makefile.am
r449 r455 45 45 openpam_restore_cred.3 \ 46 46 openpam_set_option.3 \ 47 openpam_subst.3 \ 47 48 openpam_ttyconv.3 \ 48 49 pam_error.3 \ -
trunk/include/security/openpam.h
r437 r455 60 60 OPENPAM_NONNULL((1,2)); 61 61 62 int 63 openpam_subst(const pam_handle_t *_pamh, 64 char *_buf, 65 size_t *_bufsize, 66 const char *_template); 67 62 68 void 63 69 openpam_free_data(pam_handle_t *_pamh, -
trunk/lib/Makefile.am
r429 r455 25 25 openpam_set_option.c \ 26 26 openpam_static.c \ 27 openpam_subst.c \ 27 28 openpam_ttyconv.c \ 28 29 pam_acct_mgmt.c \ -
trunk/lib/pam_get_authtok.c
r437 r455 66 66 const char *prompt) 67 67 { 68 char prompt_buf[1024]; 69 size_t prompt_size; 68 70 const void *oldauthtok, *prevauthtok, *promptp; 69 const char * default_prompt;71 const char *prompt_option, *default_prompt; 70 72 char *resp, *resp2; 71 73 int pitem, r, style, twice; … … 79 81 case PAM_AUTHTOK: 80 82 pitem = PAM_AUTHTOK_PROMPT; 83 prompt_option = "authtok_prompt"; 81 84 default_prompt = authtok_prompt; 82 85 r = pam_get_item(pamh, PAM_OLDAUTHTOK, &oldauthtok); … … 88 91 case PAM_OLDAUTHTOK: 89 92 pitem = PAM_OLDAUTHTOK_PROMPT; 93 prompt_option = "oldauthtok_prompt"; 90 94 default_prompt = oldauthtok_prompt; 91 95 twice = 0; … … 104 108 RETURNC(r == PAM_SUCCESS ? PAM_AUTH_ERR : r); 105 109 } 106 if (prompt == NULL) { 107 r = pam_get_item(pamh, pitem, &promptp); 108 if (r != PAM_SUCCESS || promptp == NULL) 109 prompt = default_prompt; 110 else 110 /* pam policy overrides the module's choice */ 111 if ((promptp = openpam_get_option(pamh, prompt_option)) != NULL) 112 prompt = promptp; 113 /* no prompt provided, see if there is one tucked away somewhere */ 114 if (prompt == NULL) 115 if (pam_get_item(pamh, pitem, &promptp) && promptp != NULL) 111 116 prompt = promptp; 112 } 117 /* fall back to hardcoded default */ 118 if (prompt == NULL) 119 prompt = default_prompt; 120 /* expand */ 121 prompt_size = sizeof prompt_buf; 122 r = openpam_subst(pamh, prompt_buf, &prompt_size, prompt); 123 if (r == PAM_SUCCESS && prompt_size <= sizeof prompt_buf) 124 prompt = prompt_buf; 113 125 style = openpam_get_option(pamh, "echo_pass") ? 114 126 PAM_PROMPT_ECHO_ON : PAM_PROMPT_ECHO_OFF; … … 165 177 * as appropriate, will be used. 166 178 * If that item is also =NULL, a hardcoded default prompt will be used. 179 * Either way, the prompt is expanded using =openpam_subst before it is 180 * passed to the conversation function. 181 * 182 * If =pam_get_authtok is called from a module and the ;authtok_prompt / 183 * ;oldauthtok_prompt option is set in the policy file, the value of that 184 * option takes precedence over both the =prompt argument and the 185 * =PAM_AUTHTOK_PROMPT / =PAM_OLDAUTHTOK_PROMPT item. 167 186 * 168 187 * If =item is set to =PAM_AUTHTOK and there is a non-null =PAM_OLDAUTHTOK … … 173 192 * >pam_get_item 174 193 * >pam_get_user 194 * >openpam_subst 175 195 */ -
trunk/lib/pam_get_user.c
r437 r455 63 63 const char *prompt) 64 64 { 65 char prompt_buf[1024]; 66 size_t prompt_size; 65 67 const void *promptp; 66 68 char *resp; … … 73 75 if (r == PAM_SUCCESS && *user != NULL) 74 76 RETURNC(PAM_SUCCESS); 75 if (prompt == NULL) { 76 r = pam_get_item(pamh, PAM_USER_PROMPT, &promptp); 77 if (r != PAM_SUCCESS || promptp == NULL) 78 prompt = user_prompt; 79 else 77 /* pam policy overrides the module's choice */ 78 if ((promptp = openpam_get_option(pamh, "user_prompt")) != NULL) 79 prompt = promptp; 80 /* no prompt provided, see if there is one tucked away somewhere */ 81 if (prompt == NULL) 82 if (pam_get_item(pamh, PAM_USER_PROMPT, &promptp) && 83 promptp != NULL) 80 84 prompt = promptp; 81 } 85 /* fall back to hardcoded default */ 86 if (prompt == NULL) 87 prompt = user_prompt; 88 /* expand */ 89 prompt_size = sizeof prompt_buf; 90 r = openpam_subst(pamh, prompt_buf, &prompt_size, prompt); 91 if (r == PAM_SUCCESS && prompt_size <= sizeof prompt_buf) 92 prompt = prompt_buf; 82 93 r = pam_prompt(pamh, PAM_PROMPT_ECHO_ON, &resp, "%s", prompt); 83 94 if (r != PAM_SUCCESS) … … 110 121 * The =prompt argument specifies a prompt to use if no user name is 111 122 * cached. 112 * If it is =NULL, the =PAM_USER_PROMPT will be used.123 * If it is =NULL, the =PAM_USER_PROMPT item will be used. 113 124 * If that item is also =NULL, a hardcoded default prompt will be used. 125 * Either way, the prompt is expanded using =openpam_subst before it is 126 * passed to the conversation function. 127 * 128 * If =pam_get_user is called from a module and the ;user_prompt option is 129 * set in the policy file, the value of that option takes precedence over 130 * both the =prompt argument and the =PAM_USER_PROMPT item. 114 131 * 115 132 * >pam_get_item 116 133 * >pam_get_authtok 134 * >openpam_subst 117 135 */
Note: See TracChangeset
for help on using the changeset viewer.