| 1 |
.TH "selinux_restorecon_xattr" "3" "30 July 2016" "" "SELinux API documentation" |
| 2 |
|
| 3 |
.SH "NAME" |
| 4 |
selinux_restorecon_xattr \- manage default |
| 5 |
.I security.restorecon_last |
| 6 |
extended attribute entries added by |
| 7 |
.BR selinux_restorecon (3), |
| 8 |
.BR setfiles (8) |
| 9 |
or |
| 10 |
.BR restorecon (8). |
| 11 |
|
| 12 |
.SH "SYNOPSIS" |
| 13 |
.B #include <selinux/restorecon.h> |
| 14 |
.sp |
| 15 |
.BI "int selinux_restorecon_xattr(const char *" pathname , |
| 16 |
.in +\w'int selinux_restorecon('u |
| 17 |
.br |
| 18 |
.BI "unsigned int " xattr_flags , |
| 19 |
.br |
| 20 |
.BI "struct dir_xattr ***" xattr_list ");" |
| 21 |
.in |
| 22 |
. |
| 23 |
.SH "DESCRIPTION" |
| 24 |
.BR selinux_restorecon_xattr () |
| 25 |
returns a linked list of |
| 26 |
.B dir_xattr |
| 27 |
structures containing information described below based on: |
| 28 |
.sp |
| 29 |
.RS |
| 30 |
.IR pathname |
| 31 |
containing a directory tree to be searched for |
| 32 |
.I security.restorecon_last |
| 33 |
extended attribute entries. |
| 34 |
.sp |
| 35 |
.IR xattr_flags |
| 36 |
contains options as follows: |
| 37 |
.sp |
| 38 |
.RS |
| 39 |
.sp |
| 40 |
.B SELINUX_RESTORECON_XATTR_RECURSE |
| 41 |
recursively descend directories. |
| 42 |
.sp |
| 43 |
.B SELINUX_RESTORECON_XATTR_DELETE_NONMATCH_DIGESTS |
| 44 |
delete non-matching digests from each directory in |
| 45 |
.IR pathname . |
| 46 |
.sp |
| 47 |
.B SELINUX_RESTORECON_XATTR_DELETE_ALL_DIGESTS |
| 48 |
delete all digests from each directory in |
| 49 |
.IR pathname . |
| 50 |
.sp |
| 51 |
.B SELINUX_RESTORECON_XATTR_IGNORE_MOUNTS |
| 52 |
do not read |
| 53 |
.B /proc/mounts |
| 54 |
to obtain a list of non-seclabel mounts to be excluded from the search. |
| 55 |
.br |
| 56 |
Setting |
| 57 |
.B SELINUX_RESTORECON_XATTR_IGNORE_MOUNTS |
| 58 |
is useful where there is a non-seclabel fs mounted with a seclabel fs mounted |
| 59 |
on a directory below this. |
| 60 |
.RE |
| 61 |
.sp |
| 62 |
.I xattr_list |
| 63 |
is the returned pointer to a linked list of |
| 64 |
.B dir_xattr |
| 65 |
structures, each containing the following information: |
| 66 |
.sp |
| 67 |
.RS |
| 68 |
.ta 4n 16n 24n |
| 69 |
.nf |
| 70 |
struct dir_xattr { |
| 71 |
char *directory; |
| 72 |
char *digest; /* Printable hex encoded string */ |
| 73 |
enum digest_result result; |
| 74 |
struct dir_xattr *next; |
| 75 |
}; |
| 76 |
.fi |
| 77 |
.ta |
| 78 |
.RE |
| 79 |
.sp |
| 80 |
The |
| 81 |
.B result |
| 82 |
entry is enumerated as follows: |
| 83 |
.RS |
| 84 |
.ta 4n 16n 24n |
| 85 |
.nf |
| 86 |
enum digest_result { |
| 87 |
MATCH = 0, |
| 88 |
NOMATCH, |
| 89 |
DELETED_MATCH, |
| 90 |
DELETED_NOMATCH, |
| 91 |
ERROR |
| 92 |
}; |
| 93 |
.fi |
| 94 |
.ta |
| 95 |
.RE |
| 96 |
.sp |
| 97 |
.I xattr_list |
| 98 |
must be set to |
| 99 |
.B NULL |
| 100 |
before calling |
| 101 |
.BR selinux_restorecon_xattr (3). |
| 102 |
The caller is responsible for freeing the returned |
| 103 |
.I xattr_list |
| 104 |
entries in the linked list. |
| 105 |
.RE |
| 106 |
.sp |
| 107 |
See the |
| 108 |
.B NOTES |
| 109 |
section for more information. |
| 110 |
|
| 111 |
.SH "RETURN VALUE" |
| 112 |
On success, zero is returned. On error, \-1 is returned and |
| 113 |
.I errno |
| 114 |
is set appropriately. |
| 115 |
|
| 116 |
.SH "NOTES" |
| 117 |
.IP "1." 4 |
| 118 |
By default |
| 119 |
.BR selinux_restorecon_xattr (3) |
| 120 |
will use the default set of specfiles described in |
| 121 |
.BR files_contexts (5) |
| 122 |
to calculate the initial SHA1 digest to be used for comparison. |
| 123 |
To change this default behavior |
| 124 |
.BR selabel_open (3) |
| 125 |
must be called specifying the required |
| 126 |
.B SELABEL_OPT_PATH |
| 127 |
and setting the |
| 128 |
.B SELABEL_OPT_DIGEST |
| 129 |
option to a non-NULL value. |
| 130 |
.BR selinux_restorecon_set_sehandle (3) |
| 131 |
is then called to set the handle to be used by |
| 132 |
.BR selinux_restorecon_xattr (3). |
| 133 |
.IP "2." 4 |
| 134 |
By default |
| 135 |
.BR selinux_restorecon_xattr (3) |
| 136 |
reads |
| 137 |
.B /proc/mounts |
| 138 |
to obtain a list of non-seclabel mounts to be excluded from searches unless the |
| 139 |
.B SELINUX_RESTORECON_XATTR_IGNORE_MOUNTS |
| 140 |
flag has been set. |
| 141 |
.IP "3." 4 |
| 142 |
.B RAMFS |
| 143 |
and |
| 144 |
.B TMPFS |
| 145 |
filesystems do not support the |
| 146 |
.IR security.restorecon_last |
| 147 |
extended attribute and are automatically excluded from searches. |
| 148 |
.IP "4." 4 |
| 149 |
By default |
| 150 |
.B stderr |
| 151 |
is used to log output messages and errors. This may be changed by calling |
| 152 |
.BR selinux_set_callback (3) |
| 153 |
with the |
| 154 |
.B SELINUX_CB_LOG |
| 155 |
.I type |
| 156 |
option. |
| 157 |
|
| 158 |
.SH "SEE ALSO" |
| 159 |
.BR selinux_restorecon (3) |
| 160 |
.br |
| 161 |
.BR selinux_restorecon_set_sehandle (3), |
| 162 |
.br |
| 163 |
.BR selinux_restorecon_default_handle (3), |
| 164 |
.br |
| 165 |
.BR selinux_restorecon_set_exclude_list (3), |
| 166 |
.br |
| 167 |
.BR selinux_restorecon_set_alt_rootpath (3), |
| 168 |
.br |
| 169 |
.BR selinux_set_callback (3) |