aboutsummaryrefslogtreecommitdiff
blob: a1044f312a7c1e296733b3753faa0063e94f71cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
policy_module(phpfpm, 1.1)

#######################################
#
# Declarations
#

## <desc>
## <p>
## Allow phpfpm to use LDAP services
## </p>
## </desc>
gen_tunable(phpfpm_use_ldap, false)

## <desc>
## <p>
## Allow phpfpm to send syslog messages
## </p>
## </desc>
gen_tunable(phpfpm_send_syslog_msg, false)

## <desc>
## <p>
## Allow phpfpm to execute shells. This
## is needed by some webapps.
## </p>
## </desc>
gen_tunable(phpfpm_exec_shell, false)

## <desc>
## <p>
## Allow phpfpm to connect to http ports.
## </p>
## </desc>
gen_tunable(phpfpm_connect_http, false)

## <desc>
## <p>
## Allow phpfpm to connect to pop ports.
## </p>
## </desc>
gen_tunable(phpfpm_connect_pop, false)

## <desc>
## <p>
## Allow phpfpm to connect to redis ports.
## </p>
## </desc>
gen_tunable(phpfpm_connect_redis, false)

## <desc>
## <p>
## Allow phpfpm to connect to sieve ports.
## </p>
## </desc>
gen_tunable(phpfpm_connect_sieve, false)

## <desc>
## <p>
## Allow phpfpm to connect to smtp ports.
## </p>
## </desc>
gen_tunable(phpfpm_connect_smtp, false)

type phpfpm_t;
type phpfpm_exec_t;
init_daemon_domain(phpfpm_t, phpfpm_exec_t)

type phpfpm_tmp_t;
files_tmp_file(phpfpm_tmp_t)

type phpfpm_runtime_t alias phpfpm_var_run_t;
files_runtime_file(phpfpm_runtime_t)

type phpfpm_log_t;
logging_log_file(phpfpm_log_t)

#######################################
#
# Local policy
#


allow phpfpm_t self:process signal;
allow phpfpm_t self:capability { setuid setgid kill };
allow phpfpm_t self:fifo_file rw_fifo_file_perms;
allow phpfpm_t self:tcp_socket rw_stream_socket_perms;
allow phpfpm_t self:udp_socket connected_socket_perms;
allow phpfpm_t self:unix_stream_socket { accept create_stream_socket_perms };
allow phpfpm_t self:unix_dgram_socket { create_socket_perms };
dontaudit phpfpm_t self:capability net_admin;

manage_files_pattern(phpfpm_t, phpfpm_log_t, phpfpm_log_t)
logging_log_filetrans(phpfpm_t, phpfpm_log_t, file)

manage_files_pattern(phpfpm_t, phpfpm_tmp_t, phpfpm_tmp_t)
manage_dirs_pattern(phpfpm_t, phpfpm_tmp_t, phpfpm_tmp_t)
files_tmp_filetrans(phpfpm_t, phpfpm_tmp_t, {file dir})

manage_files_pattern(phpfpm_t, phpfpm_runtime_t, phpfpm_runtime_t)
files_runtime_filetrans(phpfpm_t, phpfpm_runtime_t, { file sock_file })

manage_sock_files_pattern(phpfpm_t, phpfpm_runtime_t, phpfpm_runtime_t)

kernel_read_kernel_sysctls(phpfpm_t)

corecmd_search_bin(phpfpm_t)

corenet_tcp_bind_all_unreserved_ports(phpfpm_t)
corenet_tcp_bind_generic_node(phpfpm_t)
corenet_tcp_bind_generic_port(phpfpm_t)

dev_read_rand(phpfpm_t)
dev_read_urand(phpfpm_t)

files_read_etc_files(phpfpm_t)
files_read_usr_files(phpfpm_t)
files_search_var_lib(phpfpm_t)

fs_getattr_xattr_fs(phpfpm_t)

miscfiles_read_localization(phpfpm_t)

sysnet_dns_name_resolve(phpfpm_t)
sysnet_read_config(phpfpm_t)

userdom_search_user_home_dirs(phpfpm_t)

apache_append_all_ra_content(phpfpm_t)
apache_manage_all_rw_content(phpfpm_t)
apache_read_sys_content(phpfpm_t)
apache_dontaudit_search_modules(phpfpm_t)

optional_policy(`
	apache_map_sys_content(phpfpm_t)
')

optional_policy(`
	mysql_stream_connect(phpfpm_t)
	mysql_tcp_connect(phpfpm_t)
')

optional_policy(`
	postgresql_stream_connect(phpfpm_t)
	postgresql_tcp_connect(phpfpm_t)
')

optional_policy(`
	snmp_read_snmp_var_lib_files(phpfpm_t)
')

optional_policy(`
	tunable_policy(`phpfpm_use_ldap',`
		sysnet_use_ldap(phpfpm_t)
	')
')

tunable_policy(`phpfpm_exec_shell',`
	corecmd_exec_shell(phpfpm_t)
')

tunable_policy(`phpfpm_connect_http',`
	corenet_tcp_connect_http_port(phpfpm_t)
')

tunable_policy(`phpfpm_connect_pop',`
	corenet_tcp_connect_pop_port(phpfpm_t)
')

tunable_policy(`phpfpm_connect_redis',`
	corenet_tcp_connect_redis_port(phpfpm_t)
')

tunable_policy(`phpfpm_connect_sieve',`
	corenet_tcp_connect_sieve_port(phpfpm_t)
')

tunable_policy(`phpfpm_connect_smtp',`
	corenet_tcp_connect_smtp_port(phpfpm_t)
')

tunable_policy(`phpfpm_send_syslog_msg',`
	logging_send_syslog_msg(phpfpm_t)
')