1236099Sdes/*- 2348980Sdes * Copyright (c) 2012-2017 Dag-Erling Sm��rgrav 3236099Sdes * All rights reserved. 4236099Sdes * 5236099Sdes * Redistribution and use in source and binary forms, with or without 6236099Sdes * modification, are permitted provided that the following conditions 7236099Sdes * are met: 8236099Sdes * 1. Redistributions of source code must retain the above copyright 9255376Sdes * notice, this list of conditions and the following disclaimer. 10236099Sdes * 2. Redistributions in binary form must reproduce the above copyright 11236099Sdes * notice, this list of conditions and the following disclaimer in the 12236099Sdes * documentation and/or other materials provided with the distribution. 13236099Sdes * 3. The name of the author may not be used to endorse or promote 14236099Sdes * products derived from this software without specific prior written 15236099Sdes * permission. 16236099Sdes * 17236099Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18236099Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19236099Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20236099Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 21236099Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22236099Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23236099Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24236099Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25236099Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26236099Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27236099Sdes * SUCH DAMAGE. 28236099Sdes * 29348980Sdes * $OpenPAM: openpam_get_feature.c 938 2017-04-30 21:34:42Z des $ 30236099Sdes */ 31236099Sdes 32236099Sdes#ifdef HAVE_CONFIG_H 33236099Sdes# include "config.h" 34236099Sdes#endif 35236099Sdes 36236099Sdes#include <security/pam_appl.h> 37236099Sdes#include <security/openpam.h> 38236099Sdes 39236099Sdes#include "openpam_impl.h" 40236099Sdes 41236099Sdes/* 42236099Sdes * OpenPAM extension 43236099Sdes * 44236099Sdes * Query the state of an optional feature. 45236099Sdes */ 46236099Sdes 47236099Sdesint 48236099Sdesopenpam_get_feature(int feature, int *onoff) 49236099Sdes{ 50236099Sdes 51236099Sdes ENTERF(feature); 52236099Sdes if (feature < 0 || feature >= OPENPAM_NUM_FEATURES) 53348980Sdes RETURNC(PAM_BAD_FEATURE); 54236099Sdes *onoff = openpam_features[feature].onoff; 55236099Sdes RETURNC(PAM_SUCCESS); 56236099Sdes} 57236099Sdes 58236099Sdes/* 59236099Sdes * Error codes: 60236099Sdes * 61348980Sdes * PAM_BAD_FEATURE 62236099Sdes */ 63236099Sdes 64236099Sdes/** 65236099Sdes * EXPERIMENTAL 66236099Sdes * 67236099Sdes * The =openpam_get_feature function stores the current state of the 68236099Sdes * specified feature in the variable pointed to by its =onoff argument. 69236099Sdes * 70236099Sdes * The following features are recognized: 71236099Sdes * 72236099Sdes * =OPENPAM_RESTRICT_SERVICE_NAME: 73236099Sdes * Disallow path separators in service names. 74236099Sdes * This feature is enabled by default. 75236099Sdes * Disabling it allows the application to specify the path to 76236099Sdes * the desired policy file directly. 77236099Sdes * 78236099Sdes * =OPENPAM_VERIFY_POLICY_FILE: 79236099Sdes * Verify the ownership and permissions of the policy file 80236099Sdes * and the path leading up to it. 81236099Sdes * This feature is enabled by default. 82236099Sdes * 83236099Sdes * =OPENPAM_RESTRICT_MODULE_NAME: 84236099Sdes * Disallow path separators in module names. 85236099Sdes * This feature is disabled by default. 86236099Sdes * Enabling it prevents the use of modules in non-standard 87236099Sdes * locations. 88236099Sdes * 89236099Sdes * =OPENPAM_VERIFY_MODULE_FILE: 90236099Sdes * Verify the ownership and permissions of each loadable 91236099Sdes * module and the path leading up to it. 92236099Sdes * This feature is enabled by default. 93236099Sdes * 94236099Sdes * 95236099Sdes * >openpam_set_feature 96236099Sdes * 97236099Sdes * AUTHOR DES 98236099Sdes */ 99