pam_get_authtok.c (228690) | pam_get_authtok.c (236099) |
---|---|
1/*- 2 * Copyright (c) 2002-2003 Networks Associates Technology, Inc. 3 * Copyright (c) 2004-2011 Dag-Erling Sm��rgrav 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by ThinkSec AS and 7 * Network Associates Laboratories, the Security Research Division of 8 * Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * | 1/*- 2 * Copyright (c) 2002-2003 Networks Associates Technology, Inc. 3 * Copyright (c) 2004-2011 Dag-Erling Sm��rgrav 4 * All rights reserved. 5 * 6 * This software was developed for the FreeBSD Project by ThinkSec AS and 7 * Network Associates Laboratories, the Security Research Division of 8 * Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 --- 18 unchanged lines hidden (view full) --- 27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33 * SUCH DAMAGE. 34 * |
35 * $Id: pam_get_authtok.c 455 2011-10-29 18:31:11Z des $ | 35 * $Id: pam_get_authtok.c 510 2011-12-31 13:14:23Z des $ |
36 */ 37 38#ifdef HAVE_CONFIG_H 39# include "config.h" 40#endif 41 42#include <sys/param.h> 43 44#include <stdlib.h> 45#include <string.h> 46 47#include <security/pam_appl.h> 48#include <security/openpam.h> 49 50#include "openpam_impl.h" 51 52static const char authtok_prompt[] = "Password:"; | 36 */ 37 38#ifdef HAVE_CONFIG_H 39# include "config.h" 40#endif 41 42#include <sys/param.h> 43 44#include <stdlib.h> 45#include <string.h> 46 47#include <security/pam_appl.h> 48#include <security/openpam.h> 49 50#include "openpam_impl.h" 51 52static const char authtok_prompt[] = "Password:"; |
53static const char authtok_prompt_remote[] = "Password for %u@%h:"; |
|
53static const char oldauthtok_prompt[] = "Old Password:"; 54static const char newauthtok_prompt[] = "New Password:"; 55 56/* 57 * OpenPAM extension 58 * 59 * Retrieve authentication token 60 */ 61 62int 63pam_get_authtok(pam_handle_t *pamh, 64 int item, 65 const char **authtok, 66 const char *prompt) 67{ 68 char prompt_buf[1024]; 69 size_t prompt_size; 70 const void *oldauthtok, *prevauthtok, *promptp; 71 const char *prompt_option, *default_prompt; | 54static const char oldauthtok_prompt[] = "Old Password:"; 55static const char newauthtok_prompt[] = "New Password:"; 56 57/* 58 * OpenPAM extension 59 * 60 * Retrieve authentication token 61 */ 62 63int 64pam_get_authtok(pam_handle_t *pamh, 65 int item, 66 const char **authtok, 67 const char *prompt) 68{ 69 char prompt_buf[1024]; 70 size_t prompt_size; 71 const void *oldauthtok, *prevauthtok, *promptp; 72 const char *prompt_option, *default_prompt; |
73 const void *lhost, *rhost; |
|
72 char *resp, *resp2; 73 int pitem, r, style, twice; 74 75 ENTER(); 76 if (pamh == NULL || authtok == NULL) 77 RETURNC(PAM_SYSTEM_ERR); 78 *authtok = NULL; 79 twice = 0; 80 switch (item) { 81 case PAM_AUTHTOK: 82 pitem = PAM_AUTHTOK_PROMPT; 83 prompt_option = "authtok_prompt"; 84 default_prompt = authtok_prompt; | 74 char *resp, *resp2; 75 int pitem, r, style, twice; 76 77 ENTER(); 78 if (pamh == NULL || authtok == NULL) 79 RETURNC(PAM_SYSTEM_ERR); 80 *authtok = NULL; 81 twice = 0; 82 switch (item) { 83 case PAM_AUTHTOK: 84 pitem = PAM_AUTHTOK_PROMPT; 85 prompt_option = "authtok_prompt"; 86 default_prompt = authtok_prompt; |
87 r = pam_get_item(pamh, PAM_RHOST, &rhost); 88 if (r == PAM_SUCCESS && rhost != NULL) { 89 r = pam_get_item(pamh, PAM_HOST, &lhost); 90 if (r == PAM_SUCCESS && lhost != NULL) { 91 if (strcmp(rhost, lhost) != 0) 92 default_prompt = authtok_prompt_remote; 93 } 94 } |
|
85 r = pam_get_item(pamh, PAM_OLDAUTHTOK, &oldauthtok); 86 if (r == PAM_SUCCESS && oldauthtok != NULL) { 87 default_prompt = newauthtok_prompt; 88 twice = 1; 89 } 90 break; 91 case PAM_OLDAUTHTOK: 92 pitem = PAM_OLDAUTHTOK_PROMPT; --- 103 unchanged lines hidden --- | 95 r = pam_get_item(pamh, PAM_OLDAUTHTOK, &oldauthtok); 96 if (r == PAM_SUCCESS && oldauthtok != NULL) { 97 default_prompt = newauthtok_prompt; 98 twice = 1; 99 } 100 break; 101 case PAM_OLDAUTHTOK: 102 pitem = PAM_OLDAUTHTOK_PROMPT; --- 103 unchanged lines hidden --- |