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]
21 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
22 /* All Rights Reserved */
25 #pragma ident "%Z%%M% %I% %E% SMI"
28 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
29 * Use is subject to license terms.
32 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
40 #include <auth_attr.h>
41 #include <auth_list.h>
42 #include <tsol/label.h>
45 ** is_user_admin() - CHECK IF CURRENT USER IS AN ADMINISTRATOR
57 /* For a labeled system, tsol_check_admin_auth is called
58 * instead of using Access.
60 if (is_system_labeled()) {
61 /* Check that user has print admin authorization */
62 return (tsol_check_admin_auth(getuid()));
64 return (Access(Lp_A
, W_OK
) == -1? 0 : 1);
69 ** is_user_allowed() - CHECK USER ACCESS ACCORDING TO ALLOW/DENY LISTS
80 is_user_allowed (user
, allow
, deny
)
86 if (bangequ(user
, LOCAL_LPUSER
) || bangequ(user
, LOCAL_ROOTUSER
))
89 return (allowed(user
, allow
, deny
));
93 ** is_user_allowed_form() - CHECK USER ACCESS TO FORM
98 is_user_allowed_form (
103 is_user_allowed_form (user
, form
)
111 if (loadaccess(Lp_A_Forms
, form
, "", &allow
, &deny
) == -1)
114 return (is_user_allowed(user
, allow
, deny
));
118 ** is_user_allowed_printer() - CHECK USER ACCESS TO PRINTER
122 #if defined(__STDC__)
123 is_user_allowed_printer (
128 is_user_allowed_printer (user
, printer
)
136 if (loadaccess(Lp_A_Printers
, printer
, UACCESSPREFIX
, &allow
, &deny
) == -1)
139 return (is_user_allowed(user
, allow
, deny
));
143 ** is_form_allowed_printer() - CHECK FORM USE ON PRINTER
147 #if defined(__STDC__)
148 is_form_allowed_printer (
153 is_form_allowed_printer (form
, printer
)
161 if (loadaccess(Lp_A_Printers
, printer
, FACCESSPREFIX
, &allow
, &deny
) == -1)
164 return (allowed(form
, allow
, deny
));
168 ** allowed() - GENERAL ROUTINE TO CHECK ALLOW/DENY LISTS
172 #if defined(__STDC__)
179 allowed (item
, allow
, deny
)
186 if (bang_searchlist(item
, allow
))
193 if (bang_searchlist(item
, deny
))
203 * Check to see if the specified user has the administer the printing
204 * system authorization.
207 tsol_check_admin_auth(uid_t uid
)
213 if (p
!= NULL
&& p
->pw_name
!= NULL
)
218 return (chkauthattr(PRINT_ADMIN_AUTH
, name
));