pam_get_authtok.c (91097) | pam_get_authtok.c (91100) |
---|---|
1/*- 2 * Copyright (c) 2002 Networks Associates Technologies, Inc. 3 * All rights reserved. 4 * 5 * This software was developed for the FreeBSD Project by ThinkSec AS and 6 * NAI Labs, the Security Research Division of Network Associates, Inc. 7 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 8 * DARPA CHATS research program. --- 39 unchanged lines hidden (view full) --- 48 */ 49 50int 51pam_get_authtok(pam_handle_t *pamh, 52 const char **authtok, 53 const char *prompt) 54{ 55 char *p, *resp; | 1/*- 2 * Copyright (c) 2002 Networks Associates Technologies, Inc. 3 * All rights reserved. 4 * 5 * This software was developed for the FreeBSD Project by ThinkSec AS and 6 * NAI Labs, the Security Research Division of Network Associates, Inc. 7 * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 8 * DARPA CHATS research program. --- 39 unchanged lines hidden (view full) --- 48 */ 49 50int 51pam_get_authtok(pam_handle_t *pamh, 52 const char **authtok, 53 const char *prompt) 54{ 55 char *p, *resp; |
56 int r; | 56 int r, style; |
57 58 if (pamh == NULL || authtok == NULL) 59 return (PAM_SYSTEM_ERR); 60 | 57 58 if (pamh == NULL || authtok == NULL) 59 return (PAM_SYSTEM_ERR); 60 |
61 r = pam_get_item(pamh, PAM_AUTHTOK, (const void **)authtok); 62 if (r == PAM_SUCCESS && *authtok != NULL) 63 return (PAM_SUCCESS); 64 if (prompt == NULL) { 65 if (pam_get_item(pamh, PAM_AUTHTOK_PROMPT, 66 (const void **)&p) != PAM_SUCCESS || p == NULL) 67 prompt = "Password:"; | 61 if (openpam_get_option(pamh, "try_first_pass") || 62 openpam_get_option(pamh, "use_first_pass")) { 63 r = pam_get_item(pamh, PAM_AUTHTOK, (const void **)authtok); 64 if (r == PAM_SUCCESS && *authtok != NULL) 65 return (PAM_SUCCESS); 66 else if (openpam_get_option(pamh, "use_first_pass")) 67 return (r == PAM_SUCCESS ? PAM_AUTH_ERR : r); |
68 } | 68 } |
69 r = pam_prompt(pamh, PAM_PROMPT_ECHO_OFF, &resp, 70 "%s", prompt ? prompt : p); | 69 if (pam_get_item(pamh, PAM_AUTHTOK_PROMPT, 70 (const void **)&p) != PAM_SUCCESS || p == NULL) 71 if (prompt == NULL) 72 prompt = "Password:"; 73 style = openpam_get_option(pamh, "echo_pass") ? 74 PAM_PROMPT_ECHO_ON : PAM_PROMPT_ECHO_OFF; 75 r = pam_prompt(pamh, style, &resp, "%s", p ? p : prompt); |
71 if (r != PAM_SUCCESS) 72 return (r); 73 *authtok = resp; 74 return (pam_set_item(pamh, PAM_AUTHTOK, *authtok)); 75} | 76 if (r != PAM_SUCCESS) 77 return (r); 78 *authtok = resp; 79 return (pam_set_item(pamh, PAM_AUTHTOK, *authtok)); 80} |
81 82/* 83 * Error codes: 84 * 85 * =pam_get_item 86 * =pam_prompt 87 * =pam_set_item 88 * !PAM_SYMBOL_ERR 89 */ |
|