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 1997 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.9 */
32 /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */
42 static char **_loadaccess ( char * );
45 ** load_userform_access() - LOAD ALLOW/DENY LISTS FOR USER+FORM
49 load_userform_access(char *form
, char ***pallow
, char ***pdeny
)
51 return (loadaccess(Lp_A_Forms
, form
, "", pallow
, pdeny
));
55 ** load_userprinter_access() - LOAD ALLOW/DENY LISTS FOR USER+PRINTER
59 load_userprinter_access(char *printer
, char ***pallow
, char ***pdeny
)
61 return (loadaccess(Lp_A_Printers
, printer
, UACCESSPREFIX
, pallow
,
66 ** load_formprinter_access() - LOAD ALLOW/DENY LISTS FOR FORM+PRINTER
70 load_formprinter_access(char *printer
, char ***pallow
, char ***pdeny
)
72 return (loadaccess(Lp_A_Printers
, printer
, FACCESSPREFIX
, pallow
,
77 ** load_paperprinter_access() - LOAD ALLOW/DENY LISTS FOR FORM+PRINTER
81 load_paperprinter_access(char *printer
, char ***pallow
, char ***pdeny
)
83 return (loadaccess(Lp_A_Printers
, printer
, PACCESSPREFIX
, pallow
,
88 ** loadaccess() - LOAD ALLOW OR DENY LISTS
92 loadaccess(char *dir
, char *name
, char *prefix
, char ***pallow
, char ***pdeny
)
94 register char *allow_file
= 0,
100 !(allow_file
= getaccessfile(dir
, name
, prefix
, ALLOWFILE
))
101 || !(*pallow
= _loadaccess(allow_file
)) && errno
!= ENOENT
102 || !(deny_file
= getaccessfile(dir
, name
, prefix
, DENYFILE
))
103 || !(*pdeny
= _loadaccess(deny_file
)) && errno
!= ENOENT
118 ** _loadaccess() - LOAD ALLOW OR DENY FILE
122 _loadaccess(char *file
)
124 register size_t nalloc
,
127 register char **list
;
134 if ((fd
= open_locked(file
, "r", 0)) < 0)
138 * Preallocate space for the initial list. We'll always
139 * allocate one more than the list size, for the terminating null.
141 nalloc
= ACC_MAX_GUESS
;
142 list
= (char **)Malloc((nalloc
+ 1) * sizeof(char *));
150 for (nlist
= 0; fdgets(buf
, BUFSIZ
, fd
); ) {
152 buf
[strlen(buf
) - 1] = 0;
155 * Allocate more space if needed.
157 if (nlist
>= nalloc
) {
158 nalloc
+= ACC_MAX_GUESS
;
159 list
= (char **)Realloc(
161 (nalloc
+ 1) * sizeof(char *)
169 list
[nlist
] = Strdup(buf
); /* if fail, minor problem */
174 int save_errno
= errno
;
184 * If we have more space allocated than we need,
187 if (nlist
!= nalloc
) {
188 list
= (char **)Realloc(
190 (nlist
+ 1) * sizeof(char *)