---
name: "security_class_to_string"
section: "3"
platform: "linux"
package: "libselinux1-dev"
version: "3.8.1-1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/security_class_to_string"
---

# security\_class\_to\_string(3)

convert between SELinux class and permission values and string names. print\_access\_vector - display an access vector in human-readable form.

## 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

**#include \<selinux/selinux.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***);**

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

**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)](/free/3.md).

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

**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 \<ewalsh@tycho.nsa.gov\>

## SEE ALSO

[**selinux**(8)](/selinux/8.md), [**getcon**(3)](/getcon/3.md), [**getfilecon**(3)](/getfilecon/3.md) [**stat**(3)](/stat/3.md)
