1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ 23*7c478bd9Sstevel@tonic-gate /* All Rights Reserved */ 24*7c478bd9Sstevel@tonic-gate 25*7c478bd9Sstevel@tonic-gate 26*7c478bd9Sstevel@tonic-gate #ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.7 */ 27*7c478bd9Sstevel@tonic-gate /* EMACS_MODES: !fill, lnumb, !overwrite, !nodelete, !picture */ 28*7c478bd9Sstevel@tonic-gate 29*7c478bd9Sstevel@tonic-gate #include "string.h" 30*7c478bd9Sstevel@tonic-gate #include "unistd.h" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate #include "lp.h" 33*7c478bd9Sstevel@tonic-gate #include "access.h" 34*7c478bd9Sstevel@tonic-gate 35*7c478bd9Sstevel@tonic-gate /** 36*7c478bd9Sstevel@tonic-gate ** is_user_admin() - CHECK IF CURRENT USER IS AN ADMINISTRATOR 37*7c478bd9Sstevel@tonic-gate **/ 38*7c478bd9Sstevel@tonic-gate 39*7c478bd9Sstevel@tonic-gate int 40*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 41*7c478bd9Sstevel@tonic-gate is_user_admin ( 42*7c478bd9Sstevel@tonic-gate void 43*7c478bd9Sstevel@tonic-gate ) 44*7c478bd9Sstevel@tonic-gate #else 45*7c478bd9Sstevel@tonic-gate is_user_admin () 46*7c478bd9Sstevel@tonic-gate #endif 47*7c478bd9Sstevel@tonic-gate { 48*7c478bd9Sstevel@tonic-gate return (Access(Lp_A, W_OK) == -1? 0 : 1); 49*7c478bd9Sstevel@tonic-gate } 50*7c478bd9Sstevel@tonic-gate 51*7c478bd9Sstevel@tonic-gate /** 52*7c478bd9Sstevel@tonic-gate ** is_user_allowed() - CHECK USER ACCESS ACCORDING TO ALLOW/DENY LISTS 53*7c478bd9Sstevel@tonic-gate **/ 54*7c478bd9Sstevel@tonic-gate 55*7c478bd9Sstevel@tonic-gate int 56*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 57*7c478bd9Sstevel@tonic-gate is_user_allowed ( 58*7c478bd9Sstevel@tonic-gate char * user, 59*7c478bd9Sstevel@tonic-gate char ** allow, 60*7c478bd9Sstevel@tonic-gate char ** deny 61*7c478bd9Sstevel@tonic-gate ) 62*7c478bd9Sstevel@tonic-gate #else 63*7c478bd9Sstevel@tonic-gate is_user_allowed (user, allow, deny) 64*7c478bd9Sstevel@tonic-gate char *user, 65*7c478bd9Sstevel@tonic-gate **allow, 66*7c478bd9Sstevel@tonic-gate **deny; 67*7c478bd9Sstevel@tonic-gate #endif 68*7c478bd9Sstevel@tonic-gate { 69*7c478bd9Sstevel@tonic-gate if (bangequ(user, LOCAL_LPUSER) || bangequ(user, LOCAL_ROOTUSER)) 70*7c478bd9Sstevel@tonic-gate return (1); 71*7c478bd9Sstevel@tonic-gate 72*7c478bd9Sstevel@tonic-gate return (allowed(user, allow, deny)); 73*7c478bd9Sstevel@tonic-gate } 74*7c478bd9Sstevel@tonic-gate 75*7c478bd9Sstevel@tonic-gate /** 76*7c478bd9Sstevel@tonic-gate ** is_user_allowed_form() - CHECK USER ACCESS TO FORM 77*7c478bd9Sstevel@tonic-gate **/ 78*7c478bd9Sstevel@tonic-gate 79*7c478bd9Sstevel@tonic-gate int 80*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 81*7c478bd9Sstevel@tonic-gate is_user_allowed_form ( 82*7c478bd9Sstevel@tonic-gate char * user, 83*7c478bd9Sstevel@tonic-gate char * form 84*7c478bd9Sstevel@tonic-gate ) 85*7c478bd9Sstevel@tonic-gate #else 86*7c478bd9Sstevel@tonic-gate is_user_allowed_form (user, form) 87*7c478bd9Sstevel@tonic-gate char *user, 88*7c478bd9Sstevel@tonic-gate *form; 89*7c478bd9Sstevel@tonic-gate #endif 90*7c478bd9Sstevel@tonic-gate { 91*7c478bd9Sstevel@tonic-gate char **allow, 92*7c478bd9Sstevel@tonic-gate **deny; 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate if (loadaccess(Lp_A_Forms, form, "", &allow, &deny) == -1) 95*7c478bd9Sstevel@tonic-gate return (-1); 96*7c478bd9Sstevel@tonic-gate 97*7c478bd9Sstevel@tonic-gate return (is_user_allowed(user, allow, deny)); 98*7c478bd9Sstevel@tonic-gate } 99*7c478bd9Sstevel@tonic-gate 100*7c478bd9Sstevel@tonic-gate /** 101*7c478bd9Sstevel@tonic-gate ** is_user_allowed_printer() - CHECK USER ACCESS TO PRINTER 102*7c478bd9Sstevel@tonic-gate **/ 103*7c478bd9Sstevel@tonic-gate 104*7c478bd9Sstevel@tonic-gate int 105*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 106*7c478bd9Sstevel@tonic-gate is_user_allowed_printer ( 107*7c478bd9Sstevel@tonic-gate char * user, 108*7c478bd9Sstevel@tonic-gate char * printer 109*7c478bd9Sstevel@tonic-gate ) 110*7c478bd9Sstevel@tonic-gate #else 111*7c478bd9Sstevel@tonic-gate is_user_allowed_printer (user, printer) 112*7c478bd9Sstevel@tonic-gate char *user, 113*7c478bd9Sstevel@tonic-gate *printer; 114*7c478bd9Sstevel@tonic-gate #endif 115*7c478bd9Sstevel@tonic-gate { 116*7c478bd9Sstevel@tonic-gate char **allow, 117*7c478bd9Sstevel@tonic-gate **deny; 118*7c478bd9Sstevel@tonic-gate 119*7c478bd9Sstevel@tonic-gate if (loadaccess(Lp_A_Printers, printer, UACCESSPREFIX, &allow, &deny) == -1) 120*7c478bd9Sstevel@tonic-gate return (-1); 121*7c478bd9Sstevel@tonic-gate 122*7c478bd9Sstevel@tonic-gate return (is_user_allowed(user, allow, deny)); 123*7c478bd9Sstevel@tonic-gate } 124*7c478bd9Sstevel@tonic-gate 125*7c478bd9Sstevel@tonic-gate /** 126*7c478bd9Sstevel@tonic-gate ** is_form_allowed_printer() - CHECK FORM USE ON PRINTER 127*7c478bd9Sstevel@tonic-gate **/ 128*7c478bd9Sstevel@tonic-gate 129*7c478bd9Sstevel@tonic-gate int 130*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 131*7c478bd9Sstevel@tonic-gate is_form_allowed_printer ( 132*7c478bd9Sstevel@tonic-gate char * form, 133*7c478bd9Sstevel@tonic-gate char * printer 134*7c478bd9Sstevel@tonic-gate ) 135*7c478bd9Sstevel@tonic-gate #else 136*7c478bd9Sstevel@tonic-gate is_form_allowed_printer (form, printer) 137*7c478bd9Sstevel@tonic-gate char *form, 138*7c478bd9Sstevel@tonic-gate *printer; 139*7c478bd9Sstevel@tonic-gate #endif 140*7c478bd9Sstevel@tonic-gate { 141*7c478bd9Sstevel@tonic-gate char **allow, 142*7c478bd9Sstevel@tonic-gate **deny; 143*7c478bd9Sstevel@tonic-gate 144*7c478bd9Sstevel@tonic-gate if (loadaccess(Lp_A_Printers, printer, FACCESSPREFIX, &allow, &deny) == -1) 145*7c478bd9Sstevel@tonic-gate return (-1); 146*7c478bd9Sstevel@tonic-gate 147*7c478bd9Sstevel@tonic-gate return (allowed(form, allow, deny)); 148*7c478bd9Sstevel@tonic-gate } 149*7c478bd9Sstevel@tonic-gate 150*7c478bd9Sstevel@tonic-gate /** 151*7c478bd9Sstevel@tonic-gate ** allowed() - GENERAL ROUTINE TO CHECK ALLOW/DENY LISTS 152*7c478bd9Sstevel@tonic-gate **/ 153*7c478bd9Sstevel@tonic-gate 154*7c478bd9Sstevel@tonic-gate int 155*7c478bd9Sstevel@tonic-gate #if defined(__STDC__) 156*7c478bd9Sstevel@tonic-gate allowed ( 157*7c478bd9Sstevel@tonic-gate char * item, 158*7c478bd9Sstevel@tonic-gate char ** allow, 159*7c478bd9Sstevel@tonic-gate char ** deny 160*7c478bd9Sstevel@tonic-gate ) 161*7c478bd9Sstevel@tonic-gate #else 162*7c478bd9Sstevel@tonic-gate allowed (item, allow, deny) 163*7c478bd9Sstevel@tonic-gate char *item, 164*7c478bd9Sstevel@tonic-gate **allow, 165*7c478bd9Sstevel@tonic-gate **deny; 166*7c478bd9Sstevel@tonic-gate #endif 167*7c478bd9Sstevel@tonic-gate { 168*7c478bd9Sstevel@tonic-gate if (allow) { 169*7c478bd9Sstevel@tonic-gate if (bang_searchlist(item, allow)) 170*7c478bd9Sstevel@tonic-gate return (1); 171*7c478bd9Sstevel@tonic-gate else 172*7c478bd9Sstevel@tonic-gate return (0); 173*7c478bd9Sstevel@tonic-gate } 174*7c478bd9Sstevel@tonic-gate 175*7c478bd9Sstevel@tonic-gate if (deny) { 176*7c478bd9Sstevel@tonic-gate if (bang_searchlist(item, deny)) 177*7c478bd9Sstevel@tonic-gate return (0); 178*7c478bd9Sstevel@tonic-gate else 179*7c478bd9Sstevel@tonic-gate return (1); 180*7c478bd9Sstevel@tonic-gate } 181*7c478bd9Sstevel@tonic-gate 182*7c478bd9Sstevel@tonic-gate return (0); 183*7c478bd9Sstevel@tonic-gate } 184