Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

selinux_set_mapping(3) [centos man page]

selinux_set_mapping(3)					     SELinux API documentation					    selinux_set_mapping(3)

selinux_set_mapping - establish dynamic object class and permission mapping SYNOPSIS
#include <selinux/selinux.h> struct security_class_mapping { const char *name; const char *perms[]; }; int selinux_set_mapping(struct security_class_mapping *map); DESCRIPTION
selinux_set_mapping() establishes a mapping from a user-provided ordering of object classes and permissions to the numbers actually used by the loaded system policy. Use of this function is highly preferred over the generated constants in the libselinux header files, as this method allows the policy's class and permission values to change over time. After the mapping is established, all libselinux functions that operate on class and permission values take the user-provided numbers, which are determined as follows: The map argument consists of an array of security_class_mapping structures, which must be terminated by a structure having a NULL name field. Except for this last structure, the name field should refer to the string name of an object class, and the corresponding perms field should refer to an array of permission bit names terminated by a NULL string. The object classes named in the mapping and the bit indexes of each set of permission bits named in the mapping are numbered in order starting from 1. These numbers are the values that should be passed to subsequent libselinux calls. RETURN VALUE
Zero is returned on success. On error, -1 is returned and errno is set appropriately. ERRORS
EINVAL One of the class or permission names requested in the mapping is not present in the loaded policy. ENOMEM An attempt to allocate memory failed. EXAMPLE
struct security_class_mapping map[] = { { "file", { "create", "unlink", "read", "write", NULL } }, { "socket", { "bind", NULL } }, { "process", { "signal", NULL } }, { NULL } }; if (selinux_set_mapping(map) < 0) exit(1); In this example, after the call has succeeded, classes file, socket, and process will be identified by 1, 2 and 3, respectively. Permis- sions create, unlink, read, and write (for the file class) will be identified by 1, 2, 4, and 8 respectively. Classes and permissions not listed in the mapping cannot be used. AUTHOR
Eamon Walsh <> SEE ALSO
avc_open(8), selinux(8) 12 Jun 2008 selinux_set_mapping(3)

Check Out this Related Man Page

security_class_to_string(3)				     SELinux API documentation				       security_class_to_string(3)

security_class_to_string, security_av_perm_to_string, string_to_security_class, string_to_av_perm, security_av_string - convert between SELinux class and permission values and string names. print_access_vector - display an access vector in human-readable form. SYNOPSIS
#include <selinux/selinux.h> #include <selinux/flask.h> const char * security_class_to_string(security_class_t tclass); const char * security_av_perm_to_string(security_class_t tclass, access_vector_t av); int security_av_string(security_class_t tclass, access_vector_t av, char **result); security_class_t string_to_security_class(const char *name); access_vector_t string_to_av_perm(security_class_t tclass, const char *name); void print_access_vector(security_class_t tclass, access_vector_t av); DESCRIPTION
security_class_to_string returns a string name for class tclass, or NULL if the class is invalid. The returned string must not be modified or freed. security_av_perm_to_string returns a string name for the access vector bit av of class tclass, or NULL if either argument is invalid. The returned string must not be modified or freed. security_av_string computes a full access vector string representation using tclass and av, which may have multiple bits set. The string is returned in the memory pointed to by result, and should be freed by the caller using free(3). string_to_security_class returns the class value corresponding to the string name name, or zero if no such class exists. string_to_av_perm returns the access vector bit corresponding to the string name name and security class tclass, or zero if no such value exists. print_access_vector displays an access vector in human-readable form on the standard output stream. RETURN VALUE
security_av_string returns zero on success or -1 on error with errno set appropriately. print_access_vector does not return a value. All other functions return zero or NULL on error. ERRORS
EINVAL A class or access vector argument is not recognized by the currently loaded policy. ENOMEM An attempt to allocate memory failed. AUTHOR
Eamon Walsh <> SEE ALSO
selinux(8), getcon(3), getfilecon(3) 30 Mar 2007 security_class_to_string(3)
Man Page