pam_get_item.c revision 92289
150702Swpaul/*- 250702Swpaul * Copyright (c) 2002 Networks Associates Technology, Inc. 350702Swpaul * All rights reserved. 450702Swpaul * 550702Swpaul * This software was developed for the FreeBSD Project by ThinkSec AS and 650702Swpaul * NAI Labs, the Security Research Division of Network Associates, Inc. 750702Swpaul * under DARPA/SPAWAR contract N66001-01-C-8035 ("CBOSS"), as part of the 850702Swpaul * DARPA CHATS research program. 950702Swpaul * 1050702Swpaul * Redistribution and use in source and binary forms, with or without 1150702Swpaul * modification, are permitted provided that the following conditions 1250702Swpaul * are met: 1350702Swpaul * 1. Redistributions of source code must retain the above copyright 1450702Swpaul * notice, this list of conditions and the following disclaimer. 1550702Swpaul * 2. Redistributions in binary form must reproduce the above copyright 1650702Swpaul * notice, this list of conditions and the following disclaimer in the 1750702Swpaul * documentation and/or other materials provided with the distribution. 1850702Swpaul * 3. The name of the author may not be used to endorse or promote 1950702Swpaul * products derived from this software without specific prior written 2050702Swpaul * permission. 2150702Swpaul * 2250702Swpaul * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 2350702Swpaul * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2450702Swpaul * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2550702Swpaul * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 2650702Swpaul * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2750702Swpaul * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2850702Swpaul * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2950702Swpaul * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3050702Swpaul * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3150702Swpaul * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3250702Swpaul * SUCH DAMAGE. 3350702Swpaul * 3450702Swpaul * $P4: //depot/projects/openpam/lib/pam_get_item.c#10 $ 3550702Swpaul */ 3650702Swpaul 3750702Swpaul#include <sys/param.h> 3850702Swpaul 3950702Swpaul#include <security/pam_appl.h> 4050702Swpaul 4150702Swpaul#include "openpam_impl.h" 4250702Swpaul 4350702Swpaul/* 4450702Swpaul * XSSO 4.2.1 4550702Swpaul * XSSO 6 page 46 4694149Swpaul * 4750702Swpaul * Get PAM information 4850702Swpaul */ 4950702Swpaul 5050702Swpaulint 5194149Swpaulpam_get_item(pam_handle_t *pamh, 5250702Swpaul int item_type, 5394149Swpaul const void **item) 5494149Swpaul{ 5594149Swpaul if (pamh == NULL) 5650702Swpaul return (PAM_SYSTEM_ERR); 5750702Swpaul 5850702Swpaul switch (item_type) { 5950702Swpaul case PAM_SERVICE: 6050702Swpaul case PAM_USER: 6150702Swpaul case PAM_AUTHTOK: 6250702Swpaul case PAM_OLDAUTHTOK: 6392739Salfred case PAM_TTY: 6492739Salfred case PAM_RHOST: 6592739Salfred case PAM_RUSER: 6650702Swpaul case PAM_CONV: 6750702Swpaul case PAM_USER_PROMPT: 6850702Swpaul case PAM_AUTHTOK_PROMPT: 6950702Swpaul *item = pamh->item[item_type]; 7050702Swpaul return (PAM_SUCCESS); 7150702Swpaul default: 7250702Swpaul return (PAM_SYMBOL_ERR); 7350702Swpaul } 7450702Swpaul} 7550702Swpaul 7650702Swpaul/* 7750702Swpaul * Error codes: 7850702Swpaul * 7950702Swpaul * PAM_SYMBOL_ERR 8050702Swpaul * PAM_SYSTEM_ERR 8150702Swpaul */ 8250702Swpaul 8350702Swpaul/** 8450702Swpaul * The =pam_get_item function stores a pointer to the item specified by 8550702Swpaul * the =item_type argument in the location specified by the =item 8692739Salfred * argument. 8794149Swpaul * The item is retrieved from the PAM context specified by the =pamh 8850702Swpaul * argument. 8950702Swpaul * The following item types are recognized: 9050702Swpaul * 9150702Swpaul * =PAM_SERVICE: 9250702Swpaul * The name of the requesting service. 9350702Swpaul * =PAM_USER: 9450702Swpaul * The name of the user the application is trying to 9550702Swpaul * authenticate. 9650702Swpaul * =PAM_TTY: 9750702Swpaul * The name of the current terminal. 9894149Swpaul * =PAM_RHOST: 9994149Swpaul * The name of the applicant's host. 10094149Swpaul * =PAM_CONV: 10194149Swpaul * A =struct pam_conv describing the current conversation 10294149Swpaul * function. 10394149Swpaul * =PAM_AUTHTOK: 10494149Swpaul * The current authentication token. 10550702Swpaul * =PAM_OLDAUTHTOK: 10650702Swpaul * The expired authentication token. 10750702Swpaul * =PAM_RUSER: 10850702Swpaul * The name of the applicant. 10950702Swpaul * =PAM_USER_PROMPT: 11050702Swpaul * The prompt to use when asking the applicant for a user 11150702Swpaul * name to authenticate as. 11250702Swpaul * =PAM_AUTHTOK_PROMPT: 11350702Swpaul * The prompt to use when asking the applicant for an 11450702Swpaul * authentication token. 11550702Swpaul * 11650702Swpaul * See =pam_start for a description of =struct pam_conv. 11750702Swpaul * 11850702Swpaul * >pam_set_item 11950702Swpaul */ 12050702Swpaul