security\_class\_to\_string(3) SELinux API documentation security\_class\_to\_string(3)

# [NAME](#NAME)

security\_class\_to\_string, security\_av\_perm\_to\_string, string\_to\_security\_class, string\_to\_av\_perm, security\_av\_string, mode\_to\_security\_class - convert between SELinux class and permission values and string names. print\_access\_vector - display an access vector in human-readable form.

# [SYNOPSIS](#SYNOPSIS)

**#include &lt;selinux/selinux.h&gt;**

**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);**

**security\_class\_t mode\_to\_security\_class(mode\_t mode);**

**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](#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)](/man/os/libselinux/free.3).

**string\_to\_security\_class**() returns the class value corresponding to the string name *name*, or zero if no such class exists.

**mode\_to\_security\_class**() returns the class value corresponding to the specified *mode*, 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](#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](#ERRORS)

[**EINVAL**](#EINVAL)

A class or access vector argument is not recognized by the currently loaded policy.

[**ENOMEM**](#ENOMEM)

An attempt to allocate memory failed.

# [AUTHOR](#AUTHOR)

Eamon Walsh &lt;ewalsh@tycho.nsa.gov&gt;

# [SEE ALSO](#SEE_ALSO)

[**selinux**(8)](/man/os/libselinux/selinux.8), [**getcon**(3)](/man/os/libselinux/getcon.3), [**getfilecon**(3)](/man/os/libselinux/getfilecon.3) [**stat**(3)](/man/os/libselinux/stat.3)

30 Mar 2007

---

Document: security_class_to_string(3) from libselinux 3.11-r2 (Chainguard OS)
Source: https://github.com/SELinuxProject/selinux.git
