pam_chauthtok.c revision 263421
1292915Sdim/*- 2292915Sdim * Copyright (c) 2002-2003 Networks Associates Technology, Inc. 3292915Sdim * Copyright (c) 2004-2011 Dag-Erling Sm��rgrav 4292915Sdim * All rights reserved. 5292915Sdim * 6292915Sdim * This software was developed for the FreeBSD Project by ThinkSec AS and 7292915Sdim * Network Associates Laboratories, the Security Research Division of 8292915Sdim * Network Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 9292915Sdim * ("CBOSS"), as part of the DARPA CHATS research program. 10292915Sdim * 11292915Sdim * Redistribution and use in source and binary forms, with or without 12292915Sdim * modification, are permitted provided that the following conditions 13292915Sdim * are met: 14292915Sdim * 1. Redistributions of source code must retain the above copyright 15292915Sdim * notice, this list of conditions and the following disclaimer. 16292915Sdim * 2. Redistributions in binary form must reproduce the above copyright 17292915Sdim * notice, this list of conditions and the following disclaimer in the 18292915Sdim * documentation and/or other materials provided with the distribution. 19292915Sdim * 3. The name of the author may not be used to endorse or promote 20292915Sdim * products derived from this software without specific prior written 21292915Sdim * permission. 22292915Sdim * 23292915Sdim * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 24292915Sdim * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25292915Sdim * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26292915Sdim * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 27292915Sdim * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28292915Sdim * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29292915Sdim * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30292915Sdim * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31292915Sdim * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32292915Sdim * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33292915Sdim * SUCH DAMAGE. 34292915Sdim * 35292915Sdim * $Id: pam_chauthtok.c 648 2013-03-05 17:54:27Z des $ 36292915Sdim */ 37292915Sdim 38292915Sdim#ifdef HAVE_CONFIG_H 39292915Sdim# include "config.h" 40292915Sdim#endif 41292915Sdim 42292915Sdim#include <sys/param.h> 43292915Sdim 44292915Sdim#include <security/pam_appl.h> 45292915Sdim 46292915Sdim#include "openpam_impl.h" 47292915Sdim 48292915Sdim/* 49292915Sdim * XSSO 4.2.1 50292915Sdim * XSSO 6 page 38 51292915Sdim * 52292915Sdim * Perform password related functions within the PAM framework 53292915Sdim */ 54292915Sdim 55292915Sdimint 56292915Sdimpam_chauthtok(pam_handle_t *pamh, 57292915Sdim int flags) 58292915Sdim{ 59292915Sdim int r; 60292915Sdim 61292915Sdim ENTER(); 62292915Sdim if (flags & ~(PAM_SILENT|PAM_CHANGE_EXPIRED_AUTHTOK)) 63292915Sdim RETURNC(PAM_SYMBOL_ERR); 64292915Sdim r = openpam_dispatch(pamh, PAM_SM_CHAUTHTOK, 65292915Sdim flags | PAM_PRELIM_CHECK); 66292915Sdim if (r == PAM_SUCCESS) 67292915Sdim r = openpam_dispatch(pamh, PAM_SM_CHAUTHTOK, 68292915Sdim flags | PAM_UPDATE_AUTHTOK); 69292915Sdim pam_set_item(pamh, PAM_OLDAUTHTOK, NULL); 70292915Sdim pam_set_item(pamh, PAM_AUTHTOK, NULL); 71292915Sdim RETURNC(r); 72292915Sdim} 73292915Sdim 74292915Sdim/* 75292915Sdim * Error codes: 76292915Sdim * 77292915Sdim * =openpam_dispatch 78292915Sdim * =pam_sm_chauthtok 79292915Sdim * !PAM_IGNORE 80292915Sdim * PAM_SYMBOL_ERR 81292915Sdim */ 82292915Sdim 83292915Sdim/** 84292915Sdim * The =pam_chauthtok function attempts to change the authentication token 85292915Sdim * for the user associated with the pam context specified by the =pamh 86292915Sdim * argument. 87292915Sdim * 88292915Sdim * The =flags argument is the binary or of zero or more of the following 89292915Sdim * values: 90292915Sdim * 91292915Sdim * =PAM_SILENT: 92292915Sdim * Do not emit any messages. 93292915Sdim * =PAM_CHANGE_EXPIRED_AUTHTOK: 94292915Sdim * Change only those authentication tokens that have expired. 95292915Sdim * 96292915Sdim * If any other bits are set, =pam_chauthtok will return =PAM_SYMBOL_ERR. 97292915Sdim */ 98292915Sdim