| 1 |
.TH "setfiles" "8" "10 June 2016" "" "SELinux User Command" |
| 2 |
.SH "NAME" |
| 3 |
setfiles \- set SELinux file security contexts. |
| 4 |
|
| 5 |
.SH "SYNOPSIS" |
| 6 |
.B setfiles |
| 7 |
.RB [ \-c |
| 8 |
.IR policy ] |
| 9 |
.RB [ \-d ] |
| 10 |
.RB [ \-l ] |
| 11 |
.RB [ \-m ] |
| 12 |
.RB [ \-n ] |
| 13 |
.RB [ \-e |
| 14 |
.IR directory ] |
| 15 |
.RB [ \-p ] |
| 16 |
.RB [ \-s ] |
| 17 |
.RB [ \-v ] |
| 18 |
.RB [ \-W ] |
| 19 |
.RB [ \-F ] |
| 20 |
.RB [ \-I | \-D ] |
| 21 |
.I spec_file |
| 22 |
.IR pathname \ ... |
| 23 |
|
| 24 |
.SH "DESCRIPTION" |
| 25 |
This manual page describes the |
| 26 |
.BR setfiles |
| 27 |
program. |
| 28 |
.P |
| 29 |
This program is primarily used to initialize the security context |
| 30 |
fields (extended attributes) on one or more filesystems (or parts of |
| 31 |
them). Usually it is initially run as part of the SELinux installation |
| 32 |
process (a step commonly known as labeling). |
| 33 |
.P |
| 34 |
It can also be run at any other time to correct inconsistent labels, to add |
| 35 |
support for newly-installed policy or, by using the |
| 36 |
.B \-n |
| 37 |
option, to passively |
| 38 |
check whether the file contexts are all set as specified by the active policy |
| 39 |
(default behavior) or by some other policy (see the |
| 40 |
.B \-c |
| 41 |
option). |
| 42 |
.P |
| 43 |
If a file object does not have a context, |
| 44 |
.B setfiles |
| 45 |
will write the default |
| 46 |
context to the file object's extended attributes. If a file object has a |
| 47 |
context, |
| 48 |
.B setfiles |
| 49 |
will only modify the type portion of the security context. |
| 50 |
The |
| 51 |
.B \-F |
| 52 |
option will force a replacement of the entire context. |
| 53 |
.SH "OPTIONS" |
| 54 |
.TP |
| 55 |
.B \-c |
| 56 |
check the validity of the contexts against the specified binary policy. |
| 57 |
.TP |
| 58 |
.B \-d |
| 59 |
show what specification matched each file (do not abort validation |
| 60 |
after ABORT_ON_ERRORS errors). |
| 61 |
.TP |
| 62 |
.BI \-e \ directory |
| 63 |
directory to exclude (repeat option for more than one directory). |
| 64 |
.TP |
| 65 |
.BI \-f \ infilename |
| 66 |
.I infilename |
| 67 |
contains a list of files to be processed. Use |
| 68 |
.RB \*(lq \- \*(rq |
| 69 |
for |
| 70 |
.BR stdin . |
| 71 |
.TP |
| 72 |
.B \-F |
| 73 |
Force reset of context to match file_context for customizable files, and the |
| 74 |
default file context, changing the user, role, range portion as well as the |
| 75 |
type. |
| 76 |
.TP |
| 77 |
.B \-h, \-? |
| 78 |
display usage information and exit. |
| 79 |
.TP |
| 80 |
.B \-i |
| 81 |
ignore files that do not exist. |
| 82 |
.TP |
| 83 |
.B \-I |
| 84 |
ignore digest to force checking of labels even if the stored SHA1 digest |
| 85 |
matches the specfiles SHA1 digest. The digest will then be updated provided |
| 86 |
there are no errors. See the |
| 87 |
.B NOTES |
| 88 |
section for further details. |
| 89 |
.TP |
| 90 |
.B \-D |
| 91 |
Set or update any directory SHA1 digests. Use this option to |
| 92 |
enable usage of the |
| 93 |
.IR security.restorecon_last |
| 94 |
extended attribute. |
| 95 |
.TP |
| 96 |
.B \-l |
| 97 |
log changes in file labels to syslog. |
| 98 |
.TP |
| 99 |
.B \-m |
| 100 |
do not read |
| 101 |
.B /proc/mounts |
| 102 |
to obtain a list of non-seclabel mounts to be excluded from relabeling checks. |
| 103 |
Setting this option is useful where there is a non-seclabel fs mounted with a |
| 104 |
seclabel fs mounted on a directory below this. |
| 105 |
.TP |
| 106 |
.B \-n |
| 107 |
don't change any file labels (passive check). |
| 108 |
.TP |
| 109 |
.BI \-o \ outfilename |
| 110 |
Deprecated - This option is no longer supported. |
| 111 |
.TP |
| 112 |
.B \-p |
| 113 |
show progress by printing the number of files in 1k blocks unless relabeling the entire |
| 114 |
OS, that will then show the approximate percentage complete. Note that the |
| 115 |
.B \-p |
| 116 |
and |
| 117 |
.B \-v |
| 118 |
options are mutually exclusive. |
| 119 |
.TP |
| 120 |
.B \-q |
| 121 |
Deprecated, was only used to stop printing inode association parameters. |
| 122 |
.TP |
| 123 |
.BI \-r \ rootpath |
| 124 |
use an alternate root path. Used in meta-selinux for OpenEmbedded/Yocto builds |
| 125 |
to label files under |
| 126 |
.I rootpath |
| 127 |
as if they were at |
| 128 |
.B / |
| 129 |
.TP |
| 130 |
.B \-s |
| 131 |
take a list of files from standard input instead of using a pathname from the |
| 132 |
command line (equivalent to |
| 133 |
.RB \*(lq "\-f \-" \*(rq |
| 134 |
). |
| 135 |
.TP |
| 136 |
.B \-v |
| 137 |
show changes in file labels and output any inode association parameters. |
| 138 |
Note that the |
| 139 |
.B \-v |
| 140 |
and |
| 141 |
.B \-p |
| 142 |
options are mutually exclusive. |
| 143 |
.TP |
| 144 |
.B \-W |
| 145 |
display warnings about entries that had no matching files by outputting the |
| 146 |
.BR selabel_stats (3) |
| 147 |
results. |
| 148 |
.TP |
| 149 |
.B \-0 |
| 150 |
the separator for the input items is assumed to be the null character |
| 151 |
(instead of the white space). The quotes and the backslash characters are |
| 152 |
also treated as normal characters that can form valid input. |
| 153 |
This option finally also disables the end of file string, which is treated |
| 154 |
like any other argument. Useful when input items might contain white space, |
| 155 |
quote marks or backslashes. The |
| 156 |
.B -print0 |
| 157 |
option of GNU |
| 158 |
.B find |
| 159 |
produces input suitable for this mode. |
| 160 |
|
| 161 |
.SH "ARGUMENTS" |
| 162 |
.TP |
| 163 |
.I spec_file |
| 164 |
The specification file which contains lines of the following form: |
| 165 |
.sp |
| 166 |
.RS |
| 167 |
.I regexp |
| 168 |
.RI [ type ] |
| 169 |
.IR context \ | |
| 170 |
.B <<none>> |
| 171 |
.RS |
| 172 |
The regular expression is anchored at both ends. The optional |
| 173 |
.I type |
| 174 |
field specifies the file type as shown in the mode field by the |
| 175 |
.BR ls (1) |
| 176 |
program, e.g. |
| 177 |
.B \-\- |
| 178 |
to match only regular files or |
| 179 |
.B \-d |
| 180 |
to match only |
| 181 |
directories. The |
| 182 |
.I context |
| 183 |
can be an ordinary security context or the |
| 184 |
string |
| 185 |
.B <<none>> |
| 186 |
to specify that the file is not to have its context |
| 187 |
changed. |
| 188 |
.br |
| 189 |
The last matching specification is used. If there are multiple hard |
| 190 |
links to a file that match different specifications and those |
| 191 |
specifications indicate different security contexts, then a warning is |
| 192 |
displayed but the file is still labeled based on the last matching |
| 193 |
specification other than |
| 194 |
.BR <<none>> \|. |
| 195 |
.RE |
| 196 |
.RE |
| 197 |
.TP |
| 198 |
.IR pathname \ ... |
| 199 |
The pathname for the root directory of each file system to be relabeled |
| 200 |
or a specific directory within a filesystem that should be recursively |
| 201 |
descended and relabeled or the pathname of a file that should be |
| 202 |
relabeled. |
| 203 |
Not used if the |
| 204 |
.B \-f |
| 205 |
or the |
| 206 |
.B \-s |
| 207 |
option is used. |
| 208 |
|
| 209 |
.SH "NOTES" |
| 210 |
.IP "1." 4 |
| 211 |
.B setfiles |
| 212 |
follows symbolic links and operates recursively on directories. |
| 213 |
.IP "2." 4 |
| 214 |
If the |
| 215 |
.I pathname |
| 216 |
specifies the root directory and the |
| 217 |
.B \-v |
| 218 |
option is set and the audit system is running, then an audit event is |
| 219 |
automatically logged stating that a "mass relabel" took place using the |
| 220 |
message label |
| 221 |
.BR FS_RELABEL . |
| 222 |
.IP "3." 4 |
| 223 |
To improve performance when relabeling file systems recursively |
| 224 |
the |
| 225 |
.B \-D |
| 226 |
option to |
| 227 |
.B setfiles |
| 228 |
will cause it to store a SHA1 digest of the |
| 229 |
.B spec_file |
| 230 |
set in an extended attribute named |
| 231 |
.IR security.restorecon_last |
| 232 |
on the directory specified in each |
| 233 |
.IR pathname \ ... |
| 234 |
once the relabeling has been completed successfully. This digest will be |
| 235 |
checked should |
| 236 |
.B setfiles |
| 237 |
.B \-D |
| 238 |
be rerun |
| 239 |
with the same |
| 240 |
.I spec_file |
| 241 |
and |
| 242 |
.I pathname |
| 243 |
parameters. See |
| 244 |
.BR selinux_restorecon (3) |
| 245 |
for further details. |
| 246 |
.sp |
| 247 |
The |
| 248 |
.B \-I |
| 249 |
option will ignore the SHA1 digest from each directory specified in |
| 250 |
.IR pathname \ ... |
| 251 |
and provided the |
| 252 |
.B \-n |
| 253 |
option is NOT set, files will be relabeled as required with the digest then |
| 254 |
being updated provided there are no errors. |
| 255 |
|
| 256 |
.SH "AUTHOR" |
| 257 |
This man page was written by Russell Coker <[email protected]>. |
| 258 |
The program was written by Stephen Smalley <[email protected]> |
| 259 |
|
| 260 |
.SH "SEE ALSO" |
| 261 |
.BR restorecon (8), |
| 262 |
.BR load_policy (8), |
| 263 |
.BR checkpolicy (8) |