/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
*/
#include <stdlib.h>
#include <string.h>
#include <secdb.h>
#include <user_attr.h>
#include <syslog.h>
#include <note.h>
#include <pwd.h>
#include <nss_dbdefs.h>
#include <libintl.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
#include <security/pam_impl.h>
/*
* Callback function for _enum_attrs() which looks for the 'pam_policy'
* keyword, passed in via the 'ctxt' argument, in any entries in the
* user_attr(4) database for this user or in any profiles granted to this
* user in the prof_attr(4) database or in policy.conf(4) which are
* passed in as key-value pair attributes in 'kva'.
*/
static int
{
char *match;
if (*match != '/') {
char *pam_policy;
(*match == '\0')) {
"pam_user_policy: find_pam_policy_cb() "
"invalid path supplied: '%s'", match);
return (0);
}
match);
*(char **)result = pam_policy;
} else {
}
return (1);
}
return (0);
}
/*
* Cleanup function for pam_set_data(3PAM) which is called from
* pam_end(3PAM) to free the memory allocated for 'pam_policy' which is
* stored here.
*/
static void
{
}
/*
* This is the common routine called by all of the PAM service module
* API routines (pam_sm(3PAM)) which implements the core of the
* pam_user_policy(5) functionality. We lookup a user's 'pam_policy' key in
* their user attributes or an assigned profile and then evaluate the
* pam.conf(4) formatted file pointed to by 'pam_policy' using pam_eval(3PAM).
* If no 'pam_policy' has been set for the user the default is 'unix'
* which uses UNIX for authentication, account management, session
* management, and password management. The value of 'pam_policy' is cached
* using pam_set_data(3PAM) so other modules in the same authentication
* transaction don't have to repeat the lookup.
*/
static int
const char **argv, const char *function_name)
{
int rval;
char *user;
}
if (debug) {
"pam_user_policy: %s(flags = 0x%x, argc = %d)",
}
/*
* Get the value of PAM_USER; prompting if necessary when called
* by the authentication service module. This username is then
* used to look up that user's respective 'pam_policy' key in
* their user attributes.
*/
if (debug) {
"pam_user_policy: pam_get_user() failed: "
}
return (rval);
}
} else {
}
if (debug) {
"pam_user_policy: PAM_USER is NULL or empty");
}
return (PAM_IGNORE);
}
if (debug) {
"pam_user_policy: unknown username '%s'", user);
}
return (PAM_IGNORE);
}
/*
* Check if 'pam_policy' was looked up previously and stashed away
* successfully. Since the 'pam_policy' data is per-user we
* don't check for a previously saved copy unless the user has
* successfully authenticated.
*/
(const void **)&pam_policy) == PAM_SUCCESS)) {
if (debug) {
"pam_get_data: pam_policy = %s for user '%s'",
}
}
/*
* Walk the user_attr(4) and prof_attr(4) databases for this user's
* attributes and any profiles granted as well as profiles specified
* in policy.conf(4) for the 'pam_policy' keyword and store the value
* associated with that key, if any, in pam_policy_attr.pam_policy.
*/
&pam_policy);
if (debug) {
"find_pam_policy: pam_policy = %s for user '%s'",
}
/*
* Default to UNIX policy if no pam_policy key set for user.
* which by default implements UNIX authentication.
*/
if (pam_policy == NULL) {
return (PAM_IGNORE);
}
/*
* Store the pam_policy in the pam handle in case there are
* additional pam_user_policy(5) modules configured in the stack
* for this PAM authentication transaction.
*/
pam_policy_data_cleanup)) != PAM_SUCCESS) {
"pam_user_policy: pam_set_data() failed: %s",
return (PAM_SERVICE_ERR);
}
}
int
{
"pam_sm_acct_mgmt"));
}
int
{
"pam_sm_authenticate"));
}
int
{
"pam_sm_chauthtok"));
}
int
{
"pam_sm_open_session"));
}
int
const char **argv)
{
"pam_sm_close_session"));
}
int
{
"pam_sm_setcred"));
}