1selabel_file(5)            SELinux API documentation           selabel_file(5)
2
3
4

NAME

6       selabel_file  -  userspace SELinux labeling interface and configuration
7       file format for the file contexts backend
8

SYNOPSIS

10       #include <selinux/label.h>
11
12       int selabel_lookup(struct selabel_handle *hnd,
13                          char **context,
14                          const char *path, int mode);
15
16       int selabel_lookup_raw(struct selabel_handle *hnd,
17                          char **context,
18                          const char *path, int mode);
19

DESCRIPTION

21       The file contexts backend maps  from  pathname/mode  combinations  into
22       security  contexts. It is used to find the appropriate context for each
23       file when relabeling a file system. The returned context must be  freed
24       using freecon(3).
25       selabel_lookup(3)  describes  the  function  with  its return and error
26       codes, however the following errno is clarified further  for  the  file
27       contexts backend:
28
29              ENOENT No context corresponding to the path and mode was found -
30                     This will also be returned when the file contexts  series
31                     of files have a context of <<none>> against the path (see
32                     the FILE FORMAT section).
33
34       The path argument should be set to the full pathname of the file  whose
35       assigned  context  is being checked. The mode argument should be set to
36       the mode bits of the file, as determined by lstat(2). mode may be zero,
37       however full matching may not occur.
38
39       Any  messages  generated  by  selabel_lookup(3)  are  sent to stderr by
40       default, although this can be changed by selinux_set_callback(3).
41
42       selabel_lookup_raw(3) behaves identically to selabel_lookup(3) but does
43       not perform context translation.
44
45       The  FILES  section details the configuration files used to determine a
46       file context.
47

OPTIONS

49       In addition to the global options described  in  selabel_open(3),  this
50       backend recognizes the following options:
51
52              SELABEL_OPT_PATH
53                     A  non-null  value  for this option specifies a path to a
54                     file that will be opened in lieu  of  the  standard  file
55                     contexts  file.  This value is also used as the base name
56                     for determining the names of local customization files.
57
58              SELABEL_OPT_BASEONLY
59                     A non-null value for this option indicates that any local
60                     customizations  to  the  file  contexts mapping should be
61                     ignored.
62
63              SELABEL_OPT_SUBSET
64                     A non-null value for this option is interpreted as a path
65                     prefix, for example "/etc".  Only file context specifica‐
66                     tions with starting with a first  component  that  prefix
67                     matches  the  given prefix are loaded.  This may increase
68                     lookup performance, however any attempt to look up a path
69                     not  starting with the given prefix may fail.  This opti‐
70                     mization  is  no  longer  required  due  to  the  use  of
71