1postgresql_selinux(8) SELinux Policy postgresql postgresql_selinux(8)
2
3
4
6 postgresql_selinux - Security Enhanced Linux Policy for the postgresql
7 processes
8
10 Security-Enhanced Linux secures the postgresql processes via flexible
11 mandatory access control.
12
13 The postgresql processes execute with the postgresql_t SELinux type.
14 You can check if you have these processes running by executing the ps
15 command with the -Z qualifier.
16
17 For example:
18
19 ps -eZ | grep postgresql_t
20
21
22
24 The postgresql_t SELinux type can be entered via the postgresql_exec_t
25 file type.
26
27 The default entrypoint paths for the postgresql_t domain are the fol‐
28 lowing:
29
30 /usr/bin/(se)?postgres, /usr/bin/initdb(.sepgsql)?, /usr/lib/post‐
31 gresql/bin/.*, /usr/bin/pg_ctl, /usr/libexec/postgresql-ctl,
32 /usr/bin/postgresql-check-db-dir,
33 /usr/lib/pgsql/test/regress/pg_regress
34
36 SELinux defines process types (domains) for each process running on the
37 system
38
39 You can see the context of a process using the -Z option to ps
40
41 Policy governs the access confined processes have to files. SELinux
42 postgresql policy is very flexible allowing users to setup their post‐
43 gresql processes in as secure a method as possible.
44
45 The following process types are defined for postgresql:
46
47 postgresql_t
48
49 Note: semanage permissive -a postgresql_t can be used to make the
50 process type postgresql_t permissive. SELinux does not deny access to
51 permissive process types, but the AVC (SELinux denials) messages are
52 still generated.
53
54
56 SELinux policy is customizable based on least access required. post‐
57 gresql policy is extremely flexible and has several booleans that allow
58 you to manipulate the policy and run postgresql with the tightest
59 access possible.
60
61
62
63 If you want to allow postgresql to use ssh and rsync for point-in-time
64 recovery, you must turn on the postgresql_can_rsync boolean. Disabled
65 by default.
66
67 setsebool -P postgresql_can_rsync 1
68
69
70
71 If you want to allow transmit client label to foreign database, you
72 must turn on the postgresql_selinux_transmit_client_label boolean. Dis‐
73 abled by default.
74
75 setsebool -P postgresql_selinux_transmit_client_label 1
76
77
78
79 If you want to deny user domains applications to map a memory region as
80 both executable and writable, this is dangerous and the executable
81 should be reported in bugzilla, you must turn on the deny_execmem bool‐
82 ean. Enabled by default.
83
84 setsebool -P deny_execmem 1
85
86
87
88 If you want to determine whether exim can connect to databases, you
89 must turn on the exim_can_connect_db boolean. Disabled by default.
90
91 setsebool -P exim_can_connect_db 1
92
93
94
95 If you want to allow all domains to execute in fips_mode, you must turn
96 on the fips_mode boolean. Enabled by default.
97
98 setsebool -P fips_mode 1
99
100
101
102 If you want to determine whether ftpd can connect to databases over the
103 TCP network, you must turn on the ftpd_connect_db boolean. Disabled by
104 default.
105
106 setsebool -P ftpd_connect_db 1
107
108
109
110 If you want to allow HTTPD scripts and modules to connect to databases
111 over the network, you must turn on the httpd_can_network_connect_db
112 boolean. Disabled by default.
113
114 setsebool -P httpd_can_network_connect_db 1
115
116
117
118 If you want to allow confined applications to run with kerberos, you
119 must turn on the kerberos_enabled boolean. Disabled by default.
120
121 setsebool -P kerberos_enabled 1
122
123
124
125 If you want to allow system to run with NIS, you must turn on the
126 nis_enabled boolean. Disabled by default.
127
128 setsebool -P nis_enabled 1
129
130
131
132 If you want to allow PowerDNS to connect to databases over the network,
133 you must turn on the pdns_can_network_connect_db boolean. Disabled by
134 default.
135
136 setsebool -P pdns_can_network_connect_db 1
137
138
139
141 SELinux defines port types to represent TCP and UDP ports.
142
143 You can see the types associated with a port by using the following
144 command:
145
146 semanage port -l
147
148
149 Policy governs the access confined processes have to these ports.
150 SELinux postgresql policy is very flexible allowing users to setup
151 their postgresql processes in as secure a method as possible.
152
153 The following port types are defined for postgresql:
154
155
156 postgresql_port_t
157
158
159
160 Default Defined Ports:
161 tcp 5432,9898
162
164 The SELinux process type postgresql_t can manage files labeled with the
165 following file types. The paths listed are the default paths for these
166 file types. Note the processes UID still need to have DAC permissions.
167
168 cluster_conf_t
169
170 /etc/cluster(/.*)?
171
172 cluster_var_lib_t
173
174 /var/lib/pcsd(/.*)?
175 /var/lib/cluster(/.*)?
176 /var/lib/openais(/.*)?
177 /var/lib/pengine(/.*)?
178 /var/lib/corosync(/.*)?
179 /usr/lib/heartbeat(/.*)?
180 /var/lib/heartbeat(/.*)?
181 /var/lib/pacemaker(/.*)?
182
183 cluster_var_run_t
184
185 /var/run/crm(/.*)?
186 /var/run/cman_.*
187 /var/run/rsctmp(/.*)?
188 /var/run/aisexec.*
189 /var/run/heartbeat(/.*)?
190 /var/run/corosync-qnetd(/.*)?
191 /var/run/corosync-qdevice(/.*)?
192 /var/run/corosync.pid
193 /var/run/cpglockd.pid
194 /var/run/rgmanager.pid
195 /var/run/cluster/rgmanager.sk
196
197 faillog_t
198
199 /var/log/btmp.*
200 /var/log/faillog.*
201 /var/log/tallylog.*
202 /var/run/faillock(/.*)?
203
204 hugetlbfs_t
205
206 /dev/hugepages
207 /usr/lib/udev/devices/hugepages
208
209 lastlog_t
210
211 /var/log/lastlog.*
212
213 postgresql_db_t
214
215 /var/lib/pgsql(/.*)?
216 /var/lib/sepgsql(/.*)?
217 /var/lib/postgres(ql)?(/.*)?
218 /usr/share/jonas/pgsql(/.*)?
219 /usr/lib/pgsql/test/regress(/.*)?
220
221 postgresql_lock_t
222
223
224 postgresql_log_t
225
226 /var/lib/pgsql/.*.log
227 /var/log/rhdb/rhdb(/.*)?
228 /var/log/postgresql(/.*)?
229 /var/log/postgres.log.*
230 /var/lib/pgsql/logfile(/.*)?
231 /var/lib/pgsql/data/log(/.*)?
232 /var/log/sepostgresql.log.*
233 /var/lib/pgsql/data/pg_log(/.*)?
234 /var/lib/sepgsql/pgstartup.log
235
236 postgresql_var_run_t
237
238 /var/run/postgresql(/.*)?
239
240 root_t
241
242 /sysroot/ostree/deploy/.*-atomic/deploy(/.*)?
243 /
244 /initrd
245
246 security_t
247
248 /selinux
249
250
252 SELinux requires files to have an extended attribute to define the file
253 type.
254
255 You can see the context of a file using the -Z option to ls
256
257 Policy governs the access confined processes have to these files.
258 SELinux postgresql policy is very flexible allowing users to setup
259 their postgresql processes in as secure a method as possible.
260
261 EQUIVALENCE DIRECTORIES
262
263
264 postgresql policy stores data with multiple different file context
265 types under the /var/lib/pgsql directory. If you would like to store
266 the data in a different directory you can use the semanage command to
267 create an equivalence mapping. If you wanted to store this data under
268 the /srv directory you would execute the following command:
269
270 semanage fcontext -a -e /var/lib/pgsql /srv/pgsql
271 restorecon -R -v /srv/pgsql
272
273 postgresql policy stores data with multiple different file context
274 types under the /var/lib/sepgsql directory. If you would like to store
275 the data in a different directory you can use the semanage command to
276 create an equivalence mapping. If you wanted to store this data under
277 the /srv directory you would execute the following command:
278
279 semanage fcontext -a -e /var/lib/sepgsql /srv/sepgsql
280 restorecon -R -v /srv/sepgsql
281
282 STANDARD FILE CONTEXT
283
284 SELinux defines the file context types for the postgresql, if you
285 wanted to store files with these types in a diffent paths, you need to
286 execute the semanage command to sepecify alternate labeling and then
287 use restorecon to put the labels on disk.
288
289 semanage fcontext -a -t postgresql_var_run_t '/srv/mypostgresql_con‐
290 tent(/.*)?'
291 restorecon -R -v /srv/mypostgresql_content
292
293 Note: SELinux often uses regular expressions to specify labels that
294 match multiple files.
295
296 The following file types are defined for postgresql:
297
298
299
300 postgresql_db_t
301
302 - Set files with the postgresql_db_t type, if you want to treat the
303 files as postgresql database content.
304
305
306 Paths:
307 /var/lib/pgsql(/.*)?, /var/lib/sepgsql(/.*)?, /var/lib/post‐
308 gres(ql)?(/.*)?, /usr/share/jonas/pgsql(/.*)?,
309 /usr/lib/pgsql/test/regress(/.*)?
310
311
312 postgresql_etc_t
313
314 - Set files with the postgresql_etc_t type, if you want to store post‐
315 gresql files in the /etc directories.
316
317
318 Paths:
319 /etc/postgresql(/.*)?, /etc/sysconfig/pgsql(/.*)?
320
321
322 postgresql_exec_t
323
324 - Set files with the postgresql_exec_t type, if you want to transition
325 an executable to the postgresql_t domain.
326
327
328 Paths:
329 /usr/bin/(se)?postgres, /usr/bin/initdb(.sepgsql)?, /usr/lib/post‐
330 gresql/bin/.*, /usr/bin/pg_ctl, /usr/libexec/postgresql-ctl,
331 /usr/bin/postgresql-check-db-dir,
332 /usr/lib/pgsql/test/regress/pg_regress
333
334
335 postgresql_initrc_exec_t
336
337 - Set files with the postgresql_initrc_exec_t type, if you want to
338 transition an executable to the postgresql_initrc_t domain.
339
340
341
342 postgresql_lock_t
343
344 - Set files with the postgresql_lock_t type, if you want to treat the
345 files as postgresql lock data, stored under the /var/lock directory
346
347
348
349 postgresql_log_t
350
351 - Set files with the postgresql_log_t type, if you want to treat the
352 data as postgresql log data, usually stored under the /var/log direc‐
353 tory.
354
355
356 Paths:
357 /var/lib/pgsql/.*.log, /var/log/rhdb/rhdb(/.*)?, /var/log/post‐
358 gresql(/.*)?, /var/log/postgres.log.*, /var/lib/pgsql/log‐
359 file(/.*)?, /var/lib/pgsql/data/log(/.*)?, /var/log/sepost‐
360 gresql.log.*, /var/lib/pgsql/data/pg_log(/.*)?,
361 /var/lib/sepgsql/pgstartup.log
362
363
364 postgresql_tmp_t
365
366 - Set files with the postgresql_tmp_t type, if you want to store post‐
367 gresql temporary files in the /tmp directories.
368
369
370
371 postgresql_unit_file_t
372
373 - Set files with the postgresql_unit_file_t type, if you want to treat
374 the files as postgresql unit content.
375
376
377
378 postgresql_var_run_t
379
380 - Set files with the postgresql_var_run_t type, if you want to store
381 the postgresql files under the /run or /var/run directory.
382
383
384
385 Note: File context can be temporarily modified with the chcon command.
386 If you want to permanently change the file context you need to use the
387 semanage fcontext command. This will modify the SELinux labeling data‐
388 base. You will need to use restorecon to apply the labels.
389
390
392 semanage fcontext can also be used to manipulate default file context
393 mappings.
394
395 semanage permissive can also be used to manipulate whether or not a
396 process type is permissive.
397
398 semanage module can also be used to enable/disable/install/remove pol‐
399 icy modules.
400
401 semanage port can also be used to manipulate the port definitions
402
403 semanage boolean can also be used to manipulate the booleans
404
405
406 system-config-selinux is a GUI tool available to customize SELinux pol‐
407 icy settings.
408
409
411 This manual page was auto-generated using sepolicy manpage .
412
413
415 selinux(8), postgresql(8), semanage(8), restorecon(8), chcon(1), sepol‐
416 icy(8), setsebool(8)
417
418
419
420postgresql 21-03-26 postgresql_selinux(8)