selabel\_lookup(3) SELinux API documentation selabel\_lookup(3)

# [NAME](#NAME)

selabel\_lookup - obtain SELinux security context from a string label

# [SYNOPSIS](#SYNOPSIS)

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

**int selabel\_lookup(struct selabel\_handle \*hnd,**  
**char \*\*context,**  
**const char \*key, int type);**

**int selabel\_lookup\_raw(struct selabel\_handle \*hnd,**  
**char \*\*context,**  
**const char \*key, int type);**

# [DESCRIPTION](#DESCRIPTION)

**selabel\_lookup**() performs a lookup operation on the handle *hnd*, returning the result in the memory pointed to by *context*, which must be freed by the caller using [**freecon**(3)](/man/os/libselinux/freecon.3). The *key* and *type* parameters are the inputs to the lookup operation and are interpreted according to the specific backend that *handle* is open on.

**selabel\_lookup\_raw**() behaves identically to **selabel\_lookup**() but does not perform context translation.

# [RETURN VALUE](#RETURN_VALUE)

On success, zero is returned. On error, -1 is returned and *errno* is set appropriately.

# [ERRORS](#ERRORS)

[**ENOENT**](#ENOENT)

No context corresponding to the input *key* and *type* was found.

[**EINVAL**](#EINVAL)

The *key* and/or *type* inputs are invalid, or the context being returned failed validation, or a regular expression in the database failed to compile.

[**ENOMEM**](#ENOMEM)

An attempt to allocate memory failed.

# [AUTHOR](#AUTHOR)

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

# [SEE ALSO](#SEE_ALSO)

[**selabel\_open**(3)](/man/os/libselinux/selabel_open.3), [**selabel\_stats**(3)](/man/os/libselinux/selabel_stats.3), [**selinux\_set\_callback**(3)](/man/os/libselinux/selinux_set_callback.3), [**selinux**(8)](/man/os/libselinux/selinux.8)

18 Jun 2007

---

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