• 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 	NULL
12 };
13 
sepol_polcap_getnum(const char * name)14 int sepol_polcap_getnum(const char *name)
15 {
16 	int capnum;
17 
18 	for (capnum = 0; capnum <= POLICYDB_CAPABILITY_MAX; capnum++) {
19 		if (polcap_names[capnum] == NULL)
20 			continue;
21 		if (strcasecmp(polcap_names[capnum], name) == 0)
22 			return capnum;
23 	}
24 	return -1;
25 }
26 
sepol_polcap_getname(int capnum)27 const char *sepol_polcap_getname(int capnum)
28 {
29 	if (capnum > POLICYDB_CAPABILITY_MAX)
30 		return NULL;
31 
32 	return polcap_names[capnum];
33 }
34