aboutsummaryrefslogtreecommitdiff
blob: 2183147cde23a6f95b0f84721593b2914750407a (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
policy_module(qemu, 1.9.1)

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

## <desc>
##	<p>
##	Determine whether qemu has full
##	access to the network.
##	</p>
## </desc>
gen_tunable(qemu_full_network, false)

attribute_role qemu_roles;
roleattribute system_r qemu_roles;

type qemu_exec_t;
application_executable_file(qemu_exec_t)

virt_domain_template(qemu)
role qemu_roles types qemu_t;

type qemu_unit_t;
init_unit_file(qemu_unit_t)

type qemu_var_run_t;
files_pid_file(qemu_var_run_t);

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

kernel_read_crypto_sysctls(qemu_t)

dev_read_sysfs(qemu_t)

allow qemu_t qemu_var_run_t:sock_file create_sock_file_perms;
files_pid_filetrans(qemu_t, qemu_var_run_t, sock_file)

tunable_policy(`qemu_full_network',`
	corenet_udp_sendrecv_generic_if(qemu_t)
	corenet_udp_sendrecv_generic_node(qemu_t)
	corenet_udp_sendrecv_all_ports(qemu_t)
	corenet_udp_bind_generic_node(qemu_t)
	corenet_udp_bind_all_ports(qemu_t)
	corenet_tcp_bind_all_ports(qemu_t)
	corenet_tcp_connect_all_ports(qemu_t)
')

optional_policy(`
	fs_manage_xenfs_files(qemu_t)

	dev_rw_xen(qemu_t)

	xen_stream_connect_xenstore(qemu_t)
	xen_append_log(qemu_t)
	xen_pid_filetrans(qemu_t, qemu_var_run_t, sock_file)
')

optional_policy(`
	xserver_user_x_domain_template(qemu, qemu_t, qemu_tmpfs_t)
')

########################################
#
# Unconfined local policy
#

optional_policy(`
	type unconfined_qemu_t;
	typealias unconfined_qemu_t alias qemu_unconfined_t;
	application_type(unconfined_qemu_t)
	unconfined_domain(unconfined_qemu_t)

	allow unconfined_qemu_t self:process { execstack execmem };
	allow unconfined_qemu_t qemu_exec_t:file execmod;
')

ifdef(`distro_gentoo',`

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

	# VNC/GDB support
	allow qemu_t self:tcp_socket create_stream_socket_perms;
	allow qemu_t self:udp_socket create_socket_perms;

	# Network related socket
	allow qemu_t qemu_var_run_t:sock_file manage_sock_file_perms;

	files_pid_filetrans(qemu_t, qemu_var_run_t, sock_file)

	optional_policy(`
		vde_connect(qemu_t)
	')

	#################################
	#
	# QEMU Guest Agent policy
	#
	type qemu_ga_t;
	type qemu_ga_exec_t;
	init_system_domain(qemu_ga_t, qemu_ga_exec_t)

	type qemu_ga_log_t;
	logging_log_file(qemu_ga_log_t)

	type qemu_ga_run_t;
	files_pid_file(qemu_ga_run_t)

	allow qemu_ga_t self:capability sys_admin;
	allow qemu_ga_t self:unix_dgram_socket create_socket_perms;

	manage_dirs_pattern(qemu_ga_t, qemu_ga_log_t, qemu_ga_log_t)
	append_files_pattern(qemu_ga_t, qemu_ga_log_t, qemu_ga_log_t)
	create_files_pattern(qemu_ga_t, qemu_ga_log_t, qemu_ga_log_t)
	setattr_files_pattern(qemu_ga_t, qemu_ga_log_t, qemu_ga_log_t)
	logging_log_filetrans(qemu_ga_t, qemu_ga_log_t, { dir file })

	allow qemu_ga_t qemu_ga_run_t:file manage_file_perms;
	files_pid_filetrans(qemu_ga_t, qemu_ga_run_t, file)

	corecmd_exec_bin(qemu_ga_t)
	corecmd_exec_shell(qemu_ga_t)

	miscfiles_read_localization(qemu_ga_t)

	userdom_use_user_terminals(qemu_ga_t)

	term_use_virtio_console(qemu_ga_t)
')