3 * Bacula Director -- User Agent Access Control List (ACL) handling
5 * Kern Sibbald, January MMIV
11 Copyright (C) 2004-2005 Kern Sibbald
13 This program is free software; you can redistribute it and/or
14 modify it under the terms of the GNU General Public License as
15 published by the Free Software Foundation; either version 2 of
16 the License, or (at your option) any later version.
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 General Public License for more details.
23 You should have received a copy of the GNU General Public
24 License along with this program; if not, write to the Free
25 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
34 * Check if access is permitted to item in acl
36 bool acl_access_ok(UAContext *ua, int acl, char *item)
38 return acl_access_ok(ua, acl, item, strlen(item));
42 /* This version expects the length of the item which we must check. */
43 bool acl_access_ok(UAContext *ua, int acl, char *item, int len)
46 /* If no console resource => default console and all is permitted */
48 Dmsg0(1400, "Root cons access OK.\n");
49 return true; /* No cons resource -> root console OK for everything */
52 alist *list = ua->cons->ACL_lists[acl];
54 return false; /* List empty, reject everything */
57 /* Special case *all* gives full access */
58 if (list->size() == 1 && strcasecmp("*all*", (char *)list->get(0)) == 0) {
62 /* Search list for item */
63 for (int i=0; i<list->size(); i++) {
64 if (strcasecmp(item, (char *)list->get(i)) == 0) {
65 Dmsg3(1400, "ACL found %s in %d %s\n", item, acl, (char *)list->get(i));