Debian Codegraph @

selinux/cockpit.te

raw
1 policy_module(cockpit, 1.0.0)
2
3 ########################################
4 #
5 # Declarations
6 #
7
8 type cockpit_ws_t;
9 type cockpit_ws_exec_t;
10 init_daemon_domain(cockpit_ws_t,cockpit_ws_exec_t)
11 init_nnp_daemon_domain(cockpit_ws_t)
12
13 type cockpit_tmp_t;
14 files_tmp_file(cockpit_tmp_t)
15
16 type cockpit_tmpfs_t;
17 userdom_user_tmp_file(cockpit_tmpfs_t)
18
19 type cockpit_var_run_t;
20 files_pid_file(cockpit_var_run_t)
21 systemd_mount_dir(cockpit_var_run_t)
22 systemd_private_tmp(cockpit_var_run_t)
23
24 type cockpit_unit_file_t;
25 systemd_unit_file(cockpit_unit_file_t)
26
27 type cockpit_var_lib_t;
28 files_type(cockpit_var_lib_t)
29
30 type cockpit_session_t;
31 type cockpit_session_exec_t;
32 domain_type(cockpit_session_t)
33 domain_entry_file(cockpit_session_t,cockpit_session_exec_t)
34 init_daemon_domain(cockpit_session_t,cockpit_session_exec_t)
35
36 ########################################
37 #
38 # cockpit_ws_t local policy
39 #
40
41 allow cockpit_ws_t self:capability net_admin;
42 allow cockpit_ws_t self:process setrlimit;
43 allow cockpit_ws_t self:tcp_socket create_stream_socket_perms;
44
45 kernel_read_system_state(cockpit_ws_t)
46 dev_read_sysfs(cockpit_ws_t)
47
48 # cockpit-tls can execute cockpit-ws
49 can_exec(cockpit_ws_t,cockpit_ws_exec_t)
50
51 # systemd can execute cockpit-session
52 can_exec(init_t,cockpit_session_exec_t)
53
54 # cockpit-ws can execute cockpit-{ssh,session}
55 can_exec(cockpit_ws_t,cockpit_session_exec_t)
56 # ... and the real ssh (through beiboot/ferny)
57 gen_require(`
58 type ssh_exec_t;
59 ')
60 can_exec(cockpit_ws_t,ssh_exec_t)
61
62 # cockpit-ws can read from /dev/urandom
63 dev_read_urand(cockpit_ws_t) # for authkey
64 dev_read_rand(cockpit_ws_t) # for ssh
65
66 # cockpit-ws allows connections on websm port
67 corenet_tcp_bind_websm_port(cockpit_ws_t)
68 corenet_tcp_bind_generic_node(cockpit_ws_t)
69
70 # cockpit-ws can connect to other hosts via ssh
71 corenet_tcp_connect_ssh_port(cockpit_ws_t)
72
73 # cockpit-ws can write to its temp files
74 manage_dirs_pattern(cockpit_ws_t, cockpit_tmp_t, cockpit_tmp_t)
75 manage_files_pattern(cockpit_ws_t, cockpit_tmp_t, cockpit_tmp_t)
76 files_tmp_filetrans(cockpit_ws_t, cockpit_tmp_t, { dir file })
77
78 manage_dirs_pattern(cockpit_ws_t, cockpit_tmpfs_t, cockpit_tmpfs_t)
79 manage_files_pattern(cockpit_ws_t, cockpit_tmpfs_t, cockpit_tmpfs_t)
80 fs_tmpfs_filetrans(cockpit_ws_t, cockpit_tmpfs_t, { file })
81
82 manage_dirs_pattern(cockpit_ws_t, cockpit_var_run_t, cockpit_var_run_t)
83 manage_files_pattern(cockpit_ws_t, cockpit_var_run_t, cockpit_var_run_t)
84 manage_lnk_files_pattern(cockpit_ws_t, cockpit_var_run_t, cockpit_var_run_t)
85 manage_sock_files_pattern(cockpit_ws_t, cockpit_var_run_t, cockpit_var_run_t)
86 files_pid_filetrans(cockpit_ws_t, cockpit_var_run_t, { file dir sock_file })
87
88 manage_files_pattern(cockpit_ws_t, cockpit_var_lib_t, cockpit_var_lib_t)
89 manage_dirs_pattern(cockpit_ws_t, cockpit_var_lib_t, cockpit_var_lib_t)
90
91 allow cockpit_ws_t cockpit_unit_file_t:service manage_service_perms;
92
93 kernel_read_network_state(cockpit_ws_t)
94
95 auth_use_nsswitch(cockpit_ws_t)
96
97 corecmd_exec_bin(cockpit_ws_t)
98
99 fs_getattr_xattr_fs(cockpit_ws_t)
100 fs_read_efivarfs_files(cockpit_ws_t)
101
102 init_read_state(cockpit_ws_t)
103 init_stream_connect(cockpit_ws_t)
104
105 logging_send_syslog_msg(cockpit_ws_t)
106
107 sysnet_exec_ifconfig(cockpit_ws_t)
108
109 # cockpit-ws launches cockpit-session
110 cockpit_session_domtrans(cockpit_ws_t)
111 allow cockpit_ws_t cockpit_session_t:process signal_perms;
112
113 # cockpit-session communicates with cockpit-ws over a unix socket
114 allow cockpit_ws_t cockpit_session_t:unix_stream_socket connectto;
115 allow cockpit_session_t cockpit_ws_t:unix_stream_socket rw_stream_socket_perms;
116
117 # cockpit-tls and cockpit-ws communicate over a Unix socket
118 allow cockpit_ws_t cockpit_ws_t:unix_stream_socket { connectto create_stream_socket_perms };
119
120 optional_policy(`
121 hostname_exec(cockpit_ws_t)
122 ')
123
124 optional_policy(`
125 kerberos_use(cockpit_ws_t)
126 kerberos_etc_filetrans_keytab(cockpit_ws_t)
127 ')
128
129 optional_policy(`
130 miscfiles_dontaudit_map_generic_certs(cockpit_ws_t)
131 ')
132
133 optional_policy(`
134 systemd_exec_systemctl(cockpit_ws_t)
135 ')
136
137 optional_policy(`
138 ssh_read_user_home_files(cockpit_ws_t)
139 ')
140
141 # cockpit-ws can read ssh config drop-ins like 20-systemd-ssh-proxy.conf
142 optional_policy(`
143 gen_require(`type systemd_conf_t;')
144 read_files_pattern(cockpit_ws_t, systemd_conf_t, systemd_conf_t)
145 ')
146
147 #########################################################
148 #
149 # cockpit-session local policy
150 #
151
152 # cockpit-session changes to the actual logged in user
153 # pam_faillock chowns the state file to the target user
154 allow cockpit_session_t self:capability { chown fowner dac_override dac_read_search setgid setuid sys_admin sys_resource };
155 allow cockpit_session_t self:process { setexec setrlimit setsched signal_perms };
156
157 read_files_pattern(cockpit_session_t, cockpit_var_lib_t, cockpit_var_lib_t)
158 list_dirs_pattern(cockpit_session_t, cockpit_var_lib_t, cockpit_var_lib_t)
159
160 manage_dirs_pattern(cockpit_session_t, cockpit_tmp_t, cockpit_tmp_t)
161 manage_files_pattern(cockpit_session_t, cockpit_tmp_t, cockpit_tmp_t)
162 manage_sock_files_pattern(cockpit_session_t, cockpit_tmp_t, cockpit_tmp_t)
163 files_tmp_filetrans(cockpit_session_t, cockpit_tmp_t, { dir file sock_file })
164
165 manage_dirs_pattern(cockpit_session_t, cockpit_tmpfs_t, cockpit_tmpfs_t)
166 manage_files_pattern(cockpit_session_t, cockpit_tmpfs_t, cockpit_tmpfs_t)
167 fs_tmpfs_filetrans(cockpit_session_t, cockpit_tmpfs_t, { file })
168
169 read_files_pattern(cockpit_session_t, cockpit_var_run_t, cockpit_var_run_t)
170 list_dirs_pattern(cockpit_session_t, cockpit_var_run_t, cockpit_var_run_t)
171
172 kernel_read_network_state(cockpit_session_t)
173
174 # SELinux-restricted users can communicate with existing cockpit-session socket connection
175 gen_require(`
176 type user_t;
177 type sysadm_t;
178 ')
179 allow { user_t sysadm_t } cockpit_session_t:unix_stream_socket rw_stream_socket_perms;
180
181 # cockpit-session runs a full pam stack, including pam_selinux.so
182 auth_login_pgm_domain(cockpit_session_t)
183 # cockpit-session resseting expired passwords
184 auth_manage_passwd(cockpit_session_t)
185 auth_manage_shadow(cockpit_session_t)
186 auth_write_login_records(cockpit_session_t)
187
188 corenet_tcp_bind_ssh_port(cockpit_session_t)
189 corenet_tcp_connect_ssh_port(cockpit_session_t)
190
191 # cockpit-session can execute cockpit-bridge as the user, without setting AT_SECURE
192 userdom_spec_domtrans_all_users(cockpit_session_t)
193 userdom_noatsecure_login_userdomain(cockpit_session_t)
194 usermanage_read_crack_db(cockpit_session_t)
195
196 # pam_google_authenticator needs to create and rename files in home dir
197 userdom_manage_user_home_content(cockpit_session_t)
198
199 optional_policy(`
200 ssh_agent_signal(cockpit_session_t)
201 ')
202
203 optional_policy(`
204 sssd_dbus_chat(cockpit_session_t)
205 ')
206
207 optional_policy(`
208 userdom_signal_all_users(cockpit_session_t)
209 ')
210
211 optional_policy(`
212 unconfined_domtrans(cockpit_session_t)
213 ')
214
215 # login may read motd file through pam
216 optional_policy(`
217 gen_require(`
218 type local_login_t;
219 ')
220 cockpit_read_pid_files(local_login_t)
221 ')
222
223 optional_policy(`
224 gnome_exec_keyringd(cockpit_session_t)
225 ')
226
227 # pam_systemd requires this since systemd 258; RHEL 9 does not yet know about pidfs_t
228 optional_policy(`
229 gen_require(`
230 type pidfs_t;
231 ')
232 allow cockpit_session_t pidfs_t:filesystem getattr;
233 allow cockpit_ws_t pidfs_t:filesystem getattr;
234 ')
235
236 #########################################################
237 #
238 # Misc
239 #
240
241 # systemd can clean up cockpit's tmp files
242 manage_dirs_pattern(init_t, cockpit_tmp_t, cockpit_tmp_t)
243 manage_files_pattern(init_t, cockpit_tmp_t, cockpit_tmp_t)