/*
* 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
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <syslog.h>
#include <pwd.h>
#include <unistd.h>
#include <strings.h>
#include <security/pam_appl.h>
#include <security/pam_modules.h>
#include <libintl.h>
#include <pwd.h>
#include <user_attr.h>
#include <secdb.h>
#include <nss_dbdefs.h>
#include <security/pam_impl.h>
static int roleinlist();
/*
* pam_sm_acct_mgmt():
* Account management module
* This module disallows roles for primary logins and adds special
* checks to allow roles for secondary logins.
*/
/*ARGSUSED*/
int
{
char *kva_value;
char *username;
char *auser;
char *rhost;
int i;
int debug = 0;
int allow_remote = 0;
for (i = 0; i < argc; i++) {
allow_remote = 1;
debug = 1;
} else {
"pam_roles:pam_sm_acct_mgmt: illegal module "
"option %s", argv[i]);
}
}
if (debug) {
char *ruser;
char *service;
"service = %s, allow_remote = %d, user = %s auser = %s "
}
return (PAM_USER_UNKNOWN);
/* stop masquerades by mapping username to uid to username */
return (PAM_USER_UNKNOWN);
return (PAM_USER_UNKNOWN);
/*
* If there's no user_attr entry for the primary user or it's not a
* role, no further checks are needed.
*/
USERATTR_TYPE_KW)) == NULL) ||
return (PAM_IGNORE);
}
/* username is a role */
"pam_roles:pam_sm_acct_mgmt: user name %s "
"maps to user id %d which is user name %s",
}
/* Who's the user requesting the role? */
/* authenticated requesting user */
} else {
/* user is implied by real UID */
/*
* Root user_attr entry cannot have roles.
* Force error and deny access.
*/
user_entry = NULL;
} else {
return (PAM_USER_UNKNOWN);
}
}
}
allow_remote == 0) {
/* don't allow remote roles for this service */
return (PAM_PERM_DENIED);
}
/*
* If the original user does not have a user_attr entry or isn't
* assigned the role being assumed, fail.
*/
if ((user_entry == NULL) ||
USERATTR_ROLES_KW)) == NULL) ||
"Roles can only be assumed by authorized users"),
sizeof (messages[0]));
NULL);
return (PAM_PERM_DENIED);
}
return (PAM_IGNORE);
}
int
{
while (rolename) {
return (1);
else
}
return (0);
}