16cd6a6acSopenharmony_ci/* 26cd6a6acSopenharmony_ci * Policy capability support functions 36cd6a6acSopenharmony_ci */ 46cd6a6acSopenharmony_ci 56cd6a6acSopenharmony_ci#include <string.h> 66cd6a6acSopenharmony_ci#include <sepol/policydb/polcaps.h> 76cd6a6acSopenharmony_ci 86cd6a6acSopenharmony_cistatic const char * const polcap_names[] = { 96cd6a6acSopenharmony_ci "network_peer_controls", /* POLICYDB_CAP_NETPEER */ 106cd6a6acSopenharmony_ci "open_perms", /* POLICYDB_CAP_OPENPERM */ 116cd6a6acSopenharmony_ci "extended_socket_class", /* POLICYDB_CAP_EXTSOCKCLASS */ 126cd6a6acSopenharmony_ci "always_check_network", /* POLICYDB_CAP_ALWAYSNETWORK */ 136cd6a6acSopenharmony_ci "cgroup_seclabel", /* POLICYDB_CAP_SECLABEL */ 146cd6a6acSopenharmony_ci "nnp_nosuid_transition", /* POLICYDB_CAP_NNP_NOSUID_TRANSITION */ 156cd6a6acSopenharmony_ci "genfs_seclabel_symlinks", /* POLICYDB_CAP_GENFS_SECLABEL_SYMLINKS */ 166cd6a6acSopenharmony_ci "ioctl_skip_cloexec", /* POLICYDB_CAP_IOCTL_SKIP_CLOEXEC */ 176cd6a6acSopenharmony_ci NULL 186cd6a6acSopenharmony_ci}; 196cd6a6acSopenharmony_ci 206cd6a6acSopenharmony_ciint sepol_polcap_getnum(const char *name) 216cd6a6acSopenharmony_ci{ 226cd6a6acSopenharmony_ci int capnum; 236cd6a6acSopenharmony_ci 246cd6a6acSopenharmony_ci for (capnum = 0; capnum <= POLICYDB_CAP_MAX; capnum++) { 256cd6a6acSopenharmony_ci if (polcap_names[capnum] == NULL) 266cd6a6acSopenharmony_ci continue; 276cd6a6acSopenharmony_ci if (strcasecmp(polcap_names[capnum], name) == 0) 286cd6a6acSopenharmony_ci return capnum; 296cd6a6acSopenharmony_ci } 306cd6a6acSopenharmony_ci return -1; 316cd6a6acSopenharmony_ci} 326cd6a6acSopenharmony_ci 336cd6a6acSopenharmony_ciconst char *sepol_polcap_getname(unsigned int capnum) 346cd6a6acSopenharmony_ci{ 356cd6a6acSopenharmony_ci if (capnum > POLICYDB_CAP_MAX) 366cd6a6acSopenharmony_ci return NULL; 376cd6a6acSopenharmony_ci 386cd6a6acSopenharmony_ci return polcap_names[capnum]; 396cd6a6acSopenharmony_ci} 40