4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 1993 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 /* All Rights Reserved */
31 #pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.8 */
32 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
41 static int chgaccess ( int , char ** , char * , char * , char * );
42 static char ** empty_list ( void );
45 ** deny_user_form() - DENY USER ACCESS TO FORM
49 deny_user_form(char **user_list
, char *form
)
51 return (chgaccess(0, user_list
, form
, Lp_A_Forms
, ""));
55 ** allow_user_form() - ALLOW USER ACCESS TO FORM
59 allow_user_form(char **user_list
, char *form
)
61 return (chgaccess(1, user_list
, form
, Lp_A_Forms
, ""));
65 ** deny_user_printer() - DENY USER ACCESS TO PRINTER
69 deny_user_printer(char **user_list
, char *printer
)
71 return (chgaccess(0, user_list
, printer
, Lp_A_Printers
, UACCESSPREFIX
));
75 ** allow_user_printer() - ALLOW USER ACCESS TO PRINTER
79 allow_user_printer(char **user_list
, char *printer
)
81 return (chgaccess(1, user_list
, printer
, Lp_A_Printers
, UACCESSPREFIX
));
85 ** deny_form_printer() - DENY FORM USE ON PRINTER
89 deny_form_printer(char **form_list
, char *printer
)
91 return (chgaccess(0, form_list
, printer
, Lp_A_Printers
, FACCESSPREFIX
));
95 ** allow_form_printer() - ALLOW FORM USE ON PRINTER
99 allow_form_printer(char **form_list
, char *printer
)
101 return (chgaccess(1, form_list
, printer
, Lp_A_Printers
, FACCESSPREFIX
));
105 ** remove_paper_from_printer() - DENY FORM USE ON PRINTER
109 remove_paper_from_printer(char **form_list
, char *printer
)
111 return (chgaccess(0, form_list
, printer
, Lp_A_Printers
, PACCESSPREFIX
));
115 ** add_paper_to_printer() - ALLOW FORM USE ON PRINTER
119 add_paper_to_printer(char **form_list
, char *printer
)
121 return (chgaccess(1, form_list
, printer
, Lp_A_Printers
, PACCESSPREFIX
));
125 ** chgaccess() - UPDATE ALLOW/DENY ACCESS OF ITEM TO RESOURCE
129 chgaccess(int isallow
, char **list
, char *name
, char *dir
, char *prefix
)
131 register char ***padd_list
,
138 if (loadaccess(dir
, name
, prefix
, &allow_list
, &deny_list
) == -1)
142 padd_list
= &allow_list
;
143 prem_list
= &deny_list
;
145 padd_list
= &deny_list
;
146 prem_list
= &allow_list
;
149 for (pl
= list
; *pl
; pl
++) {
152 * Do the ``all'' and ``none'' cases explicitly,
153 * so that we can clean up the lists nicely.
155 if (STREQU(*pl
, NAME_NONE
)) {
160 STREQU(*pl
, NAME_ALL
)
161 || STREQU(*pl
, NAME_ANY
)
162 || STREQU(*pl
, ALL_BANG_ALL
)
165 freelist (allow_list
);
166 freelist (deny_list
);
169 deny_list
= empty_list();
179 * For each regular item in the list,
180 * we add it to the ``add list'' and remove it
181 * from the ``remove list''. This is not
182 * efficient, especially if there are a lot of
183 * items in the caller's list; doing it the
184 * way we do, however, has the side effect
185 * of skipping duplicate names in the caller's
188 * Do a regular "addlist()"--the resulting
189 * list may have redundancies, but it will
192 if (addlist(padd_list
, *pl
) == -1)
194 if (bang_dellist(prem_list
, *pl
) == -1)
201 return (dumpaccess(dir
, name
, prefix
, &allow_list
, &deny_list
));
205 ** empty_list() - CREATE AN EMPTY LIST
211 register char **empty
;
214 if (!(empty
= (char **)Malloc(sizeof(char *)))) {