1semanage-fcontext(8)                                      semanage-fcontext(8)
2
3
4

NAME

6       semanage-fcontext - SELinux Policy Management file context tool
7
8

SYNOPSIS

10       semanage  fcontext [-h] [-n] [-N] [-S STORE] [ --add ( -t TYPE -f FTYPE
11       -r RANGE -s SEUSER | -e EQUAL ) FILE_SPEC | --delete ( -t TYPE -f FTYPE
12       | -e EQUAL ) FILE_SPEC | --deleteall | --extract | --list [-C] | --mod‐
13       ify ( -t TYPE -f FTYPE -r RANGE -s SEUSER | -e EQUAL ) FILE_SPEC ]
14
15

DESCRIPTION

17       semanage is used to configure certain elements of SELinux policy  with‐
18       out  requiring  modification  to  or recompilation from policy sources.
19       semanage fcontext is used to  manage the default file  system  labeling
20       on  an  SELinux system.  This command maps file paths using regular ex‐
21       pressions to SELinux labels.
22
23       FILE_SPEC may contain either a fully qualified path, or a Perl compati‐
24       ble  regular expression (PCRE), describing fully qualified path(s). The
25       only PCRE flag in use is PCRE2_DOTALL, which causes a wildcard  '.'  to
26       match  anything,  including a new line.  Strings representing paths are
27       processed as bytes (as opposed  to  Unicode),  meaning  that  non-ASCII
28       characters are not matched by a single wildcard.
29
30       Note, that file context definitions specified using 'semanage fcontext'
31       (i.e. local file context modifications stored  in  file_contexts.local)
32       have  higher  priority  than  those  specified in policy modules.  This
33       means that whenever a match for given file path is found  in  file_con‐
34       texts.local, no other file context definitions are considered.  Entries
35       in file_contexts.local are processed from most recent one to  the  old‐
36       est,  with  first  match  being  used  (as opposed to the most specific
37       match, which is used when matching  other  file  context  definitions).
38       All regular expressions should therefore be as specific as possible, to
39       avoid unintentionally impacting other parts of the filesystem.
40
41

OPTIONS

43       -h, --help
44              show this help message and exit
45
46       -n, --noheading
47              Do not print heading when listing the specified object type
48
49       -N, --noreload
50              Do not reload policy after commit
51
52       -C, --locallist
53              List local customizations
54
55       -S STORE, --store STORE
56              Select an alternate SELinux Policy Store to manage
57
58       -a, --add
59              Add a record of the specified object type
60
61       -d, --delete
62              Delete a record of the specified object type
63
64       -m, --modify
65              Modify a record of the specified object type
66
67       -l, --list
68              List records of the specified object type
69
70       -E, --extract
71              Extract customizable commands, for use within a transaction
72
73       -D, --deleteall
74              Remove all local customizations
75
76       -e EQUAL, --equal EQUAL
77              Substitute target path with sourcepath when  generating  default
78              label.  This  is  used with fcontext. Requires source and target
79              path arguments. The context labeling for the target  subtree  is
80              made equivalent to that defined for the source.
81
82       -f [{a,f,d,c,b,s,l,p}], --ftype [{a,f,d,c,b,s,l,p}]
83              File  Type.  This is used with fcontext. Requires a file type as
84              shown in the mode field by ls, e.g. use 'd' to match only direc‐
85              tories  or  'f'  to match only regular files. The following file
86              type options can be passed:  f  (regular  file),d  (directory),c
87              (character  device),  b  (block  device),s  (socket),l (symbolic
88              link),p (named pipe).  If you do not specify a  file  type,  the
89              file type will default to "all files".
90
91
92       -s SEUSER, --seuser SEUSER
93              SELinux user name
94
95       -t TYPE, --type TYPE
96              SELinux Type for the object
97
98       -r RANGE, --range RANGE
99              MLS/MCS  Security Range (MLS/MCS Systems only) SELinux Range for
100              SELinux login mapping defaults to the SELinux user record range.
101              SELinux Range for SELinux user defaults to s0.
102
103

EXAMPLE

105       remember to run restorecon after you set the file context
106       Add file-context for everything under /web
107       # semanage fcontext -a -t httpd_sys_content_t "/web(/.*)?"
108       # restorecon -R -v /web
109
110       Substitute /home1 with /home when setting file context
111       # semanage fcontext -a -e /home /home1
112       # restorecon -R -v /home1
113
114       For home directories under top level directory, for example /disk6/home,
115       execute the following commands.
116       # semanage fcontext -a -t home_root_t "/disk6"
117       # semanage fcontext -a -e /home /disk6/home
118       # restorecon -R -v /disk6
119
120

SEE ALSO

122       selinux(8), semanage(8)
123
124

AUTHOR

126       This man page was written by Daniel Walsh <dwalsh@redhat.com>
127
128
129
130                                   20130617               semanage-fcontext(8)
Impressum