getseuserbyname(3)
π getseuserbyname(3) β the SELinux API doc page, bestie edition
okay so you're poking around in selinux land and you found getseuserbyname?? slay, let's get you fluent. this is a page from the SELinux API documentation, and it's literally the glow-up translator between your regular Linux username and your SELinux username + level. no cap. π¦
β¨ NAME β¨
getseuserbyname β get the SELinux username and level for a given Linux username π
πΈ SYNOPSIS πΈ
#include <selinux/selinux.h>
int getseuserbyname(const char *linuxuser, char **selinuxuser, char **level);
that's it, that's the whole vibe. one function, three args, main character energy. π
π DESCRIPTION π
okay so getseuserbyname() goes and fetches the SELinux username and the security level that are associated with a given Linux username. like, you hand it a normal login name and it hands you back the SELinux-flavoured identity that goes with it. so iconic of it. β¨
and the tea is: once you have that SELinux username and security level, you can pass them along to other libselinux functions β the page literally name-drops get_ordered_context_list_with_level(3) and get_default_context_with_level(3) as the besties you'd send them to. π«Ά
real talk though β the returned SELinux username and level should be freed by the caller using free. not me letting you leak memory, bestie, please free them. π
π RETURN VALUE π
- on the slay path:
0is returned. periodt. - on the not-slay path:
-1is returned, anderrnois set appropriately. π
also, the errors documented for the stat(2) system call are applicable here too β so if you know your stat(2) errno lore, it transfers. iykyk. π
π SEE ALSO π
π§ cute sign-off π§
this lil gem was written by dwalsh@redhat.com and dated 29 September 2005 β yeah it's been serving SELinux realness since 2005 and it still ate. π
β¨ take care of those free calls and you're golden, bestie. ππ¦π
π¦ where this page comes from
- alpine 3.24: libselinux-doc 3.10-r1 Β· Public-Domain
- centos-stream 10: libselinux-devel 3.11-3.el10 Β· LicenseRef-Fedora-Public-Domain
- centos-stream 9: libselinux-devel 3.6-5.el9 Β· Public Domain
- centos-stream 9: libselinux-devel 3.6-5.el9 Β· Public Domain
- debian bookworm: libselinux1-dev 3.4-1+b6
- fedora 43: libselinux-devel 3.9-5.fc43 Β· LicenseRef-Fedora-Public-Domain
- fedora 43: libselinux-devel 3.9-5.fc43 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-devel 3.10-1.fc44 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-devel 3.10-1.fc44 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-devel 3.11-2.fc44 Β· LicenseRef-Fedora-Public-Domain
- fedora 44: libselinux-devel 3.11-2.fc44 Β· LicenseRef-Fedora-Public-Domain
- nixos 26.05: libselinux 3.10
- nixpkgs unstable: libselinux 3.11
- opensuse-leap 16.0: libselinux-devel 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: libselinux-devel 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: libselinux-devel 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- opensuse-leap 16.0: libselinux-devel 3.8.1-160000.4.1 Β· SUSE-Public-Domain
- ubuntu jammy: libselinux1-dev 3.3-1build2
- ubuntu noble: libselinux1-dev 3.5-2ubuntu2 Β· LicenseRef-public-domain
- ubuntu noble: libselinux1-dev 3.5-2ubuntu2.1 Β· LicenseRef-public-domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms