aboutsummaryrefslogtreecommitdiff
blob: e9f0465a17f08e4a682f0f3e409ad785e659dfb9 (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
policy_module(openvpn, 1.17.0)

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

## <desc>
##	<p>
##	Determine whether openvpn can
##	read generic user home content files.
##	</p>
## </desc>
gen_tunable(openvpn_enable_homedirs, false)

## <desc>
##	<p>
##	Determine whether openvpn can
##	connect to the TCP network.
##	</p>
## </desc>
gen_tunable(openvpn_can_network_connect, false)

attribute_role openvpn_roles;

type openvpn_t;
type openvpn_exec_t;
init_daemon_domain(openvpn_t, openvpn_exec_t)
role openvpn_roles types openvpn_t;

type openvpn_etc_t;
files_config_file(openvpn_etc_t)

type openvpn_etc_rw_t;
files_config_file(openvpn_etc_rw_t)

type openvpn_initrc_exec_t;
init_script_file(openvpn_initrc_exec_t)

type openvpn_status_t;
logging_log_file(openvpn_status_t)

type openvpn_tmp_t;
files_tmp_file(openvpn_tmp_t)

type openvpn_var_log_t;
logging_log_file(openvpn_var_log_t)

type openvpn_var_run_t;
files_pid_file(openvpn_var_run_t)

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

allow openvpn_t self:capability { dac_override dac_read_search ipc_lock net_admin setgid setuid sys_chroot sys_nice sys_tty_config };
allow openvpn_t self:process { signal getsched setsched };
allow openvpn_t self:fifo_file rw_fifo_file_perms;
allow openvpn_t self:unix_dgram_socket sendto;
allow openvpn_t self:unix_stream_socket { accept connectto listen };
allow openvpn_t self:tcp_socket server_stream_socket_perms;
allow openvpn_t self:tun_socket { create_socket_perms relabelfrom relabelto };
allow openvpn_t self:netlink_route_socket nlmsg_write;

allow openvpn_t openvpn_etc_t:dir list_dir_perms;
allow openvpn_t openvpn_etc_t:file read_file_perms;
allow openvpn_t openvpn_etc_t:lnk_file read_lnk_file_perms;

manage_files_pattern(openvpn_t, openvpn_etc_t, openvpn_etc_rw_t)
filetrans_pattern(openvpn_t, openvpn_etc_t, openvpn_etc_rw_t, file)

allow openvpn_t openvpn_status_t:file manage_file_perms;
logging_log_filetrans(openvpn_t, openvpn_status_t, file, "openvpn-status.log")

allow openvpn_t openvpn_tmp_t:file manage_file_perms;
files_tmp_filetrans(openvpn_t, openvpn_tmp_t, file)

manage_dirs_pattern(openvpn_t, openvpn_var_log_t, openvpn_var_log_t)
append_files_pattern(openvpn_t, openvpn_var_log_t, openvpn_var_log_t)
create_files_pattern(openvpn_t, openvpn_var_log_t, openvpn_var_log_t)
setattr_files_pattern(openvpn_t, openvpn_var_log_t, openvpn_var_log_t)
logging_log_filetrans(openvpn_t, openvpn_var_log_t, file)

manage_dirs_pattern(openvpn_t, openvpn_var_run_t, openvpn_var_run_t)
manage_files_pattern(openvpn_t, openvpn_var_run_t, openvpn_var_run_t)
files_pid_filetrans(openvpn_t, openvpn_var_run_t, { file dir })

can_exec(openvpn_t, openvpn_etc_t)

kernel_read_kernel_sysctls(openvpn_t)
kernel_read_net_sysctls(openvpn_t)
kernel_read_network_state(openvpn_t)
kernel_read_system_state(openvpn_t)
kernel_request_load_module(openvpn_t)

corecmd_exec_bin(openvpn_t)
corecmd_exec_shell(openvpn_t)

corenet_all_recvfrom_unlabeled(openvpn_t)
corenet_all_recvfrom_netlabel(openvpn_t)
corenet_tcp_sendrecv_generic_if(openvpn_t)
corenet_udp_sendrecv_generic_if(openvpn_t)
corenet_tcp_sendrecv_generic_node(openvpn_t)
corenet_udp_sendrecv_generic_node(openvpn_t)
corenet_tcp_bind_generic_node(openvpn_t)
corenet_udp_bind_generic_node(openvpn_t)

corenet_sendrecv_openvpn_server_packets(openvpn_t)
corenet_tcp_bind_openvpn_port(openvpn_t)
corenet_udp_bind_openvpn_port(openvpn_t)
corenet_sendrecv_openvpn_client_packets(openvpn_t)
corenet_tcp_connect_openvpn_port(openvpn_t)
corenet_tcp_sendrecv_openvpn_port(openvpn_t)
corenet_udp_sendrecv_openvpn_port(openvpn_t)

corenet_sendrecv_http_server_packets(openvpn_t)
corenet_tcp_bind_http_port(openvpn_t)
corenet_sendrecv_http_client_packets(openvpn_t)
corenet_tcp_connect_http_port(openvpn_t)
corenet_tcp_sendrecv_http_port(openvpn_t)

corenet_sendrecv_http_cache_client_packets(openvpn_t)
corenet_tcp_connect_http_cache_port(openvpn_t)
corenet_tcp_sendrecv_http_cache_port(openvpn_t)

corenet_rw_tun_tap_dev(openvpn_t)

dev_read_rand(openvpn_t)

files_read_etc_runtime_files(openvpn_t)

fs_getattr_all_fs(openvpn_t)
fs_search_auto_mountpoints(openvpn_t)

auth_use_pam(openvpn_t)

miscfiles_read_localization(openvpn_t)
miscfiles_read_all_certs(openvpn_t)

sysnet_exec_ifconfig(openvpn_t)
sysnet_manage_config(openvpn_t)
sysnet_etc_filetrans_config(openvpn_t)
sysnet_use_ldap(openvpn_t)

userdom_use_user_terminals(openvpn_t)

tunable_policy(`openvpn_enable_homedirs',`
	userdom_read_user_home_content_files(openvpn_t)
')

tunable_policy(`openvpn_enable_homedirs && use_nfs_home_dirs',`
	fs_read_nfs_files(openvpn_t)
')

tunable_policy(`openvpn_enable_homedirs && use_samba_home_dirs',`
	fs_read_cifs_files(openvpn_t)
')

tunable_policy(`openvpn_can_network_connect',`
	corenet_sendrecv_all_client_packets(openvpn_t)
	corenet_tcp_connect_all_ports(openvpn_t)
	corenet_tcp_sendrecv_all_ports(openvpn_t)
')

optional_policy(`
	daemontools_service_domain(openvpn_t, openvpn_exec_t)
')

optional_policy(`
	dbus_system_bus_client(openvpn_t)
	dbus_connect_system_bus(openvpn_t)

	optional_policy(`
		networkmanager_dbus_chat(openvpn_t)
	')
')

optional_policy(`
	systemd_use_passwd_agent(openvpn_t)
')