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