4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
23 * Use is subject to license terms.
26 #pragma ident "%Z%%M% %I% %E% SMI"
34 #include <security/pam_appl.h>
35 #include <security/pam_modules.h>
36 #include <security/pam_impl.h>
38 #include <tsol/label.h>
41 * pam_tsol_account - Trusted Extensions account management.
42 * Validates that the user's label range contains
43 * the process label (label of the zone).
47 free_labels(m_range_t
*r
, m_label_t
*l
)
49 m_label_free(r
->lower_bound
);
50 m_label_free(r
->upper_bound
);
57 pam_sm_acct_mgmt(pam_handle_t
*pamh
, int flags
, int argc
, const char **argv
)
61 int allow_unlabeled
= 0;
67 for (i
= 0; i
< argc
; i
++) {
68 if (strcmp(argv
[i
], "debug") == 0) {
70 } else if (strcmp(argv
[i
], "allow_unlabeled") == 0) {
73 __pam_log(LOG_AUTH
| LOG_ERR
,
74 "pam_tsol_account: illegal option %s", argv
[i
]);
78 /* Trusted Extensions not enabled */
80 if (!is_system_labeled())
83 (void) pam_get_item(pamh
, PAM_USER
, (void **)&user
);
85 (void) pam_get_item(pamh
, PAM_RHOST
, (void **)&rhost
);
88 __pam_log(LOG_AUTH
| LOG_DEBUG
,
89 "pam_tsol_account: allowed_unlabeled = %d, user %s, "
92 (user
== NULL
) ? "NULL" : (user
== '\0') ? "ZERO" :
94 (rhost
== NULL
) ? "NULL" : (rhost
== '\0') ? "ZERO" :
97 if (user
== NULL
|| *user
== '\0') {
98 __pam_log(LOG_AUTH
| LOG_ERR
,
99 "pam_tsol_account: no user");
100 return (PAM_USER_UNKNOWN
);
103 if ((range
= getuserrange(user
)) == NULL
) {
104 __pam_log(LOG_AUTH
| LOG_ERR
,
105 "pam_tsol_account: getuserrange(%s) failure", user
);
106 return (PAM_SYSTEM_ERR
);
108 if ((plabel
= m_label_alloc(MAC_LABEL
)) == NULL
) {
109 __pam_log(LOG_AUTH
| LOG_ERR
,
110 "pam_tsol_account: out of memory");
111 free_labels(range
, NULL
);
112 return (PAM_BUF_ERR
);
114 if (getplabel(plabel
) < 0) {
115 __pam_log(LOG_AUTH
| LOG_CRIT
,
116 "pam_tsol_account: Unable to get process label %m");
117 free_labels(range
, plabel
);
118 return (PAM_SYSTEM_ERR
);
120 if (!blinrange(plabel
, range
)) {
121 free_labels(range
, plabel
);
122 return (PAM_PERM_DENIED
);
125 free_labels(range
, plabel
);
127 /* Remote Host Type Policy Check */
129 if ((allow_unlabeled
== 0) &&
130 (getzoneid() == GLOBAL_ZONEID
) &&
131 (rhost
!= NULL
&& *rhost
!= '\0')) {
132 tsol_host_type_t host_type
;
134 host_type
= tsol_getrhtype(rhost
);
141 return (PAM_PERM_DENIED
);
144 return (PAM_SUCCESS
);