libsepol: Shorten the policy capability enum names

Shorten "CAPABILITY" to "CAP" following the kernel naming convention.

The SELinux policy capability enum names should now follow the
"POLICYDB_CAP_XXX" format.

Signed-off-by: Richard Haines <richard_c_haines@btinternet.com>
Acked-by: James Carter <jwcart2@gmail.com>
This commit is contained in:
Richard Haines 2022-03-07 10:54:17 +00:00 committed by James Carter
parent 672d8c2c6e
commit 0d84ebcbc4
2 changed files with 20 additions and 20 deletions

View File

@ -7,17 +7,17 @@ extern "C" {
/* Policy capabilities */
enum {
POLICYDB_CAPABILITY_NETPEER,
POLICYDB_CAPABILITY_OPENPERM,
POLICYDB_CAPABILITY_EXTSOCKCLASS,
POLICYDB_CAPABILITY_ALWAYSNETWORK,
POLICYDB_CAPABILITY_CGROUPSECLABEL,
POLICYDB_CAPABILITY_NNP_NOSUID_TRANSITION,
POLICYDB_CAPABILITY_GENFS_SECLABEL_SYMLINKS,
POLICYDB_CAPABILITY_IOCTL_SKIP_CLOEXEC,
__POLICYDB_CAPABILITY_MAX
POLICYDB_CAP_NETPEER,
POLICYDB_CAP_OPENPERM,
POLICYDB_CAP_EXTSOCKCLASS,
POLICYDB_CAP_ALWAYSNETWORK,
POLICYDB_CAP_CGROUPSECLABEL,
POLICYDB_CAP_NNP_NOSUID_TRANSITION,
POLICYDB_CAP_GENFS_SECLABEL_SYMLINKS,
POLICYDB_CAP_IOCTL_SKIP_CLOEXEC,
__POLICYDB_CAP_MAX
};
#define POLICYDB_CAPABILITY_MAX (__POLICYDB_CAPABILITY_MAX - 1)
#define POLICYDB_CAP_MAX (__POLICYDB_CAP_MAX - 1)
/* Convert a capability name to number. */
extern int sepol_polcap_getnum(const char *name);

View File

@ -6,14 +6,14 @@
#include <sepol/policydb/polcaps.h>
static const char * const polcap_names[] = {
"network_peer_controls", /* POLICYDB_CAPABILITY_NETPEER */
"open_perms", /* POLICYDB_CAPABILITY_OPENPERM */
"extended_socket_class", /* POLICYDB_CAPABILITY_EXTSOCKCLASS */
"always_check_network", /* POLICYDB_CAPABILITY_ALWAYSNETWORK */
"cgroup_seclabel", /* POLICYDB_CAPABILITY_SECLABEL */
"nnp_nosuid_transition", /* POLICYDB_CAPABILITY_NNP_NOSUID_TRANSITION */
"genfs_seclabel_symlinks", /* POLICYDB_CAPABILITY_GENFS_SECLABEL_SYMLINKS */
"ioctl_skip_cloexec", /* POLICYDB_CAPABILITY_IOCTL_SKIP_CLOEXEC */
"network_peer_controls", /* POLICYDB_CAP_NETPEER */
"open_perms", /* POLICYDB_CAP_OPENPERM */
"extended_socket_class", /* POLICYDB_CAP_EXTSOCKCLASS */
"always_check_network", /* POLICYDB_CAP_ALWAYSNETWORK */
"cgroup_seclabel", /* POLICYDB_CAP_SECLABEL */
"nnp_nosuid_transition", /* POLICYDB_CAP_NNP_NOSUID_TRANSITION */
"genfs_seclabel_symlinks", /* POLICYDB_CAP_GENFS_SECLABEL_SYMLINKS */
"ioctl_skip_cloexec", /* POLICYDB_CAP_IOCTL_SKIP_CLOEXEC */
NULL
};
@ -21,7 +21,7 @@ int sepol_polcap_getnum(const char *name)
{
int capnum;
for (capnum = 0; capnum <= POLICYDB_CAPABILITY_MAX; capnum++) {
for (capnum = 0; capnum <= POLICYDB_CAP_MAX; capnum++) {
if (polcap_names[capnum] == NULL)
continue;
if (strcasecmp(polcap_names[capnum], name) == 0)
@ -32,7 +32,7 @@ int sepol_polcap_getnum(const char *name)
const char *sepol_polcap_getname(unsigned int capnum)
{
if (capnum > POLICYDB_CAPABILITY_MAX)
if (capnum > POLICYDB_CAP_MAX)
return NULL;
return polcap_names[capnum];