avc_context_to_sid(3)
π avc_context_to_sid β SELinux security ID's, but make it make sense π
okay bestie, welcome to the avc_context_to_sid(3) page from the SELinux API documentation β¨ this is a manual page, section 3, and we're gonna get you fluent in SID's, no cap π«Ά
πΈ NAME πΈ
avc_context_to_sid, avc_sid_to_context, avc_get_initial_sid β obtain and manipulate SELinux security ID's π
like, the whole girl squad of SID functions, all in one page π
β¨ SYNOPSIS β¨
#include <selinux/selinux.h>
#include <selinux/avc.h>
int avc_context_to_sid(const char *ctx, security_id_t *sid);
int avc_sid_to_context(security_id_t sid, char **ctx);
int avc_get_initial_sid(const char *name, security_id_t *sid);
look at those includes, they're literally iconic π copy them exactly, don't get cute with them.
π¦ DESCRIPTION π¦
Security ID's (SID's) are opaque representations of security contexts, managed by the userspace AVC. so likeβ¦ you don't get to peek inside them, bestie. they're mysterious on purpose. main character energy π§
avc_context_to_sid() returns a SID for the given context, and it puts it in the memory referenced by sid. context in, SID out, slay β¨
avc_sid_to_context() returns a copy of the context represented by sid, and it puts it in the memory referenced by ctx. and yes, it's a copy β you gotta free it yourself with freecon(3) or that memory is gonna haunt you fr fr π
avc_get_initial_sid() returns a SID for the kernel initial security identifier specified by name. the kernel said "here's my initial SID" and we said "yes queen" π
π« RETURN VALUE π«
avc_context_to_sid() and avc_sid_to_context() return zero on success. π
on error, -1 is returned and errno is set appropriately. so check your errno, bestie, it's trying to tell you something π
π ERRORS π
ENOMEMβ an attempt to allocate memory failed. the malloc said "not today" ππ
π₯ NOTES π₯
as of libselinux version 2.0.86, SID's are no longer reference counted. periodt.
a SID will be valid from the time it is first obtained until the next call to avc_destroy(3). that's the whole lifespan, no extensions, no takebacks π
and the sidget(3) and sidput(3) functions β formerly used to adjust the reference count β are no-ops and are deprecated. they're giving retired. they show up, they do nothing, they leave π don't build your whole personality on them.
π AUTHOR π
Eamon Walsh <ewalsh@tycho.nsa.gov> β thank you for your service, legend π«Ά
π SEE ALSO π
avc_init(3), avc_has_perm(3), avc_cache_stats(3), avc_add_callback(3), getcon(3), freecon(3), selinux(8)
and that's the whole page, bestie π this one dropped way back on 27 May 2004 as part of the SELinux API documentation β and yeah, avc_context_to_sid(3) is still out here being useful, we love a timeless icon β go forth and SID responsibly ππΈπ¦
π¦ 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
- debian trixie: libselinux1-dev 3.8.1-1 Β· LicenseRef-public-domain
- 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 questing: libselinux1-dev 3.8.1-1build1
- ubuntu resolute: libselinux-dev 3.9-4build1 Β· LicenseRef-public-domain
- ubuntu stonking: libselinux-dev 3.11-2.1 Β· LicenseRef-public-domain
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms