Home | History | Annotate | Download | only in src
      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 	NULL
     15 };
     16 
     17 int sepol_polcap_getnum(const char *name)
     18 {
     19 	int capnum;
     20 
     21 	for (capnum = 0; capnum <= POLICYDB_CAPABILITY_MAX; capnum++) {
     22 		if (polcap_names[capnum] == NULL)
     23 			continue;
     24 		if (strcasecmp(polcap_names[capnum], name) == 0)
     25 			return capnum;
     26 	}
     27 	return -1;
     28 }
     29 
     30 const char *sepol_polcap_getname(unsigned int capnum)
     31 {
     32 	if (capnum > POLICYDB_CAPABILITY_MAX)
     33 		return NULL;
     34 
     35 	return polcap_names[capnum];
     36 }
     37