getseuserbyname(3) SELinux API documentation getseuserbyname(3)

# [NAME](#NAME)

getseuserbyname - get SELinux username and level for a given Linux username

# [SYNOPSIS](#SYNOPSIS)

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

**int getseuserbyname(const char \*linuxuser, char \*\*selinuxuser, char \*\*level);**

# [DESCRIPTION](#DESCRIPTION)

**getseuserbyname**() retrieves the SELinux username and security level associated with a given Linux username. The SELinux username and security level can then be passed to other libselinux functions such as [**get\_ordered\_context\_list\_with\_level**(3)](/man/os/libselinux/get_ordered_context_list_with_level.3) and [**get\_default\_context\_with\_level**(3)](/man/os/libselinux/get_default_context_with_level.3).

The returned SELinux username and level should be freed by the caller using free.

# [RETURN VALUE](#RETURN_VALUE)

On success, 0 is returned. On failure, -1 is returned and *errno* is set appropriately.

The errors documented for the [**stat**(2)](/man/os/libselinux/stat.2) system call are also applicable here.

# [SEE ALSO](#SEE_ALSO)

[**selinux**(8)](/man/os/libselinux/selinux.8)

29 September 2005 dwalsh@redhat.com

---

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