3 * Bacula Director -- User Agent Access Control List (ACL) handling
5 * Kern Sibbald, January MMIV
10 Bacula® - The Network Backup Solution
12 Copyright (C) 2004-2006 Free Software Foundation Europe e.V.
14 The main author of Bacula is Kern Sibbald, with contributions from
15 many others, a complete list can be found in the file AUTHORS.
16 This program is Free Software; you can redistribute it and/or
17 modify it under the terms of version two of the GNU General Public
18 License as published by the Free Software Foundation plus additions
19 that are listed in the file LICENSE.
21 This program is distributed in the hope that it will be useful, but
22 WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
26 You should have received a copy of the GNU General Public License
27 along with this program; if not, write to the Free Software
28 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
31 Bacula® is a registered trademark of John Walker.
32 The licensor of Bacula is the Free Software Foundation Europe
33 (FSFE), Fiduciary Program, Sumatrastrasse 25, 8006 Zürich,
34 Switzerland, email:ftf@fsfeurope.org.
41 * Check if access is permitted to item in acl
43 bool acl_access_ok(UAContext *ua, int acl, char *item)
45 return acl_access_ok(ua, acl, item, strlen(item));
49 /* This version expects the length of the item which we must check. */
50 bool acl_access_ok(UAContext *ua, int acl, char *item, int len)
53 /* If no console resource => default console and all is permitted */
55 Dmsg0(1400, "Root cons access OK.\n");
56 return true; /* No cons resource -> root console OK for everything */
59 alist *list = ua->cons->ACL_lists[acl];
60 if (!list) { /* empty list */
61 if (len == 0 && acl == Where_ACL) {
62 return true; /* Empty list for Where => empty where */
64 return false; /* List empty, reject everything */
67 /* Special case *all* gives full access */
68 if (list->size() == 1 && strcasecmp("*all*", (char *)list->get(0)) == 0) {
72 /* Search list for item */
73 for (int i=0; i<list->size(); i++) {
74 if (strcasecmp(item, (char *)list->get(i)) == 0) {
75 Dmsg3(1400, "ACL found %s in %d %s\n", item, acl, (char *)list->get(i));