1/* 2 * Policy capability support functions 3 */ 4 5#include <string.h> 6#include <sepol/policydb/polcaps.h> 7 8static const char *polcap_names[] = { 9 "network_peer_controls", /* POLICYDB_CAPABILITY_NETPEER */ 10 "open_perms", /* POLICYDB_CAPABILITY_OPENPERM */ 11 "redhat1", /* POLICYDB_CAPABILITY_REDHAT1, aka ptrace_child */ 12 "always_check_network", /* POLICYDB_CAPABILITY_ALWAYSNETWORK */ 13 NULL 14}; 15 16int sepol_polcap_getnum(const char *name) 17{ 18 int capnum; 19 20 for (capnum = 0; capnum <= POLICYDB_CAPABILITY_MAX; capnum++) { 21 if (polcap_names[capnum] == NULL) 22 continue; 23 if (strcasecmp(polcap_names[capnum], name) == 0) 24 return capnum; 25 } 26 return -1; 27} 28 29const char *sepol_polcap_getname(int capnum) 30{ 31 if (capnum > POLICYDB_CAPABILITY_MAX) 32 return NULL; 33 34 return polcap_names[capnum]; 35} 36