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