3 // Copyright (C) 2003 Enrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; version 2 of the License.
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 # define DECLARECAP(X,Y) { #X, VC_##X }
30 # define DECLARECAP(X,Y) { #X, Y }
34 char const * const id;
37 DECLARECAP(CAP_CHOWN, 0),
38 DECLARECAP(CAP_DAC_OVERRIDE, 1),
39 DECLARECAP(CAP_DAC_READ_SEARCH, 2),
40 DECLARECAP(CAP_FOWNER, 3),
41 DECLARECAP(CAP_FSETID, 4),
42 DECLARECAP(CAP_KILL, 5),
43 DECLARECAP(CAP_SETGID, 6),
44 DECLARECAP(CAP_SETUID, 7),
45 DECLARECAP(CAP_SETPCAP, 8),
46 DECLARECAP(CAP_LINUX_IMMUTABLE, 9),
47 DECLARECAP(CAP_NET_BIND_SERVICE, 10),
48 DECLARECAP(CAP_NET_BROADCAST, 11),
49 DECLARECAP(CAP_NET_ADMIN, 12),
50 DECLARECAP(CAP_NET_RAW, 13),
51 DECLARECAP(CAP_IPC_LOCK, 14),
52 DECLARECAP(CAP_IPC_OWNER, 15),
53 DECLARECAP(CAP_SYS_MODULE, 16),
54 DECLARECAP(CAP_SYS_RAWIO, 17),
55 DECLARECAP(CAP_SYS_CHROOT, 18),
56 DECLARECAP(CAP_SYS_PTRACE, 19),
57 DECLARECAP(CAP_SYS_PACCT, 20),
58 DECLARECAP(CAP_SYS_ADMIN, 21),
59 DECLARECAP(CAP_SYS_BOOT, 22),
60 DECLARECAP(CAP_SYS_NICE, 23),
61 DECLARECAP(CAP_SYS_RESOURCE, 24),
62 DECLARECAP(CAP_SYS_TIME, 25),
63 DECLARECAP(CAP_SYS_TTY_CONFIG, 26),
64 DECLARECAP(CAP_MKNOD, 27),
65 DECLARECAP(CAP_LEASE, 28),
66 { "CAP_QUOTACTL", 29 },
70 vc_text2cap(char const *str)
73 if (strncmp(str, "CAP_", 4)==0) str += 4;
75 for (i=0; i<sizeof(CAP2BIT)/sizeof(CAP2BIT[0]); ++i)
76 if (strcmp(CAP2BIT[i].id+4, str)==0) return CAP2BIT[i].bit;
82 vc_cap2text(unsigned int bit)
84 if ((size_t)bit>=sizeof(CAP2BIT)/sizeof(CAP2BIT[0])) return 0;
85 return CAP2BIT[bit].id;