NAME |SYNOPSIS |DESCRIPTION |RETURN VALUE |ERRORS |NOTES |AUTHOR |SEE ALSO |COLOPHON | |
avc_context_to_sid(3) SELinux API documentationavc_context_to_sid(3)avc_context_to_sid, avc_sid_to_context, avc_get_initial_sid - obtain and manipulate SELinux security ID's
#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_tsid, char **ctx);int avc_get_initial_sid(const char *name, security_id_t *sid);
Security ID's (SID's) are opaque representations of security contexts, managed by the userspace AVC.avc_context_to_sid() returns a SID for the givencontext in the memory referenced bysid.avc_sid_to_context() returns a copy of the context represented bysid in the memory referenced byctx. The user must free the copy withfreecon(3).avc_get_initial_sid() returns a SID for the kernel initial security identifier specified byname.
avc_context_to_sid() andavc_sid_to_context() return zero on success. On error, -1 is returned anderrno is set appropriately.
ENOMEMAn attempt to allocate memory failed.
As of libselinux version 2.0.86, SID's are no longer reference counted. A SID will be valid from the time it is first obtained until the next call toavc_destroy(3). Thesidget(3) andsidput(3) functions, formerly used to adjust the reference count, are no-ops and are deprecated.
Eamon Walsh <ewalsh@tycho.nsa.gov>
avc_init(3),avc_has_perm(3),avc_cache_stats(3),avc_add_callback(3),getcon(3),freecon(3),selinux(8)
This page is part of theselinux (Security-Enhanced Linux user- space libraries and tools) project. Information about the project can be found at ⟨https://github.com/SELinuxProject/selinux/wiki⟩. If you have a bug report for this manual page, see ⟨https://github.com/SELinuxProject/selinux/wiki/Contributing⟩. This page was obtained from the project's upstream Git repository ⟨https://github.com/SELinuxProject/selinux⟩ on 2025-08-11. (At that time, the date of the most recent commit that was found in the repository was 2025-08-04.) If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.org 27 May 2004avc_context_to_sid(3)Pages that refer to this page:avc_add_callback(3), avc_cache_stats(3), avc_compute_create(3), avc_context_to_sid(3), avc_has_perm(3), avc_open(3)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |