selabel_lookup(3) — Linux manual page


selabel_lookup(3)         SELinux API documentation        selabel_lookup(3)

NAME         top

       selabel_lookup - obtain SELinux security context from a string label

SYNOPSIS         top

       #include <selinux/selinux.h>
       #include <selinux/label.h>

       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         top

       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).  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         top

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

ERRORS         top

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

       EINVAL The key and/or type inputs are invalid, or the context being
              returned failed validation.

       ENOMEM An attempt to allocate memory failed.

AUTHOR         top

       Eamon Walsh <>

SEE ALSO         top

       selabel_open(3), selabel_stats(3), selinux_set_callback(3),

COLOPHON         top

       This page is part of the selinux (Security-Enhanced Linux user-space
       libraries and tools) project.  Information about the project can be
       found at ⟨⟩.  If you
       have a bug report for this manual page, see
       ⟨⟩.  This
       page was obtained from the project's upstream Git repository
       ⟨⟩ on 2020-09-18.  (At that
       time, the date of the most recent commit that was found in the repos‐
       itory was 2020-09-17.)  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 is not part
       of the original manual page), send a mail to

                                 18 Jun 2007               selabel_lookup(3)

Pages that refer to this page: matchpathcon(3)matchpathcon_fini(3)matchpathcon_index(3)matchpathcon_init(3)selabel_close(3)selabel_open(3)selabel_stats(3)file_contexts(5)file_contexts.homedirs(5)file_contexts.local(5)file_contexts.subs(5)file_contexts.subs_dist(5)media(5)selabel_db(5)selabel_file(5)selabel_media(5)selabel_x(5)sepgsql_contexts(5)x_contexts(5)