1 /* 2 * Policy capability support functions 3 */ 4 5 #include <string.h> 6 #include <sepol/policydb/polcaps.h> 7 8 static const char * const polcap_names[] = { 9 "network_peer_controls", /* POLICYDB_CAP_NETPEER */ 10 "open_perms", /* POLICYDB_CAP_OPENPERM */ 11 "extended_socket_class", /* POLICYDB_CAP_EXTSOCKCLASS */ 12 "always_check_network", /* POLICYDB_CAP_ALWAYSNETWORK */ 13 "cgroup_seclabel", /* POLICYDB_CAP_SECLABEL */ 14 "nnp_nosuid_transition", /* POLICYDB_CAP_NNP_NOSUID_TRANSITION */ 15 "genfs_seclabel_symlinks", /* POLICYDB_CAP_GENFS_SECLABEL_SYMLINKS */ 16 "ioctl_skip_cloexec", /* POLICYDB_CAP_IOCTL_SKIP_CLOEXEC */ 17 NULL 18 }; 19 sepol_polcap_getnum(const char * name)20int sepol_polcap_getnum(const char *name) 21 { 22 int capnum; 23 24 for (capnum = 0; capnum <= POLICYDB_CAP_MAX; capnum++) { 25 if (polcap_names[capnum] == NULL) 26 continue; 27 if (strcasecmp(polcap_names[capnum], name) == 0) 28 return capnum; 29 } 30 return -1; 31 } 32 sepol_polcap_getname(unsigned int capnum)33const char *sepol_polcap_getname(unsigned int capnum) 34 { 35 if (capnum > POLICYDB_CAP_MAX) 36 return NULL; 37 38 return polcap_names[capnum]; 39 } 40