]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - refpolicy/policy/modules/services/ssh.te
bump versions for release.
[people/stevee/selinux-policy.git] / refpolicy / policy / modules / services / ssh.te
CommitLineData
0404a390 1
d3d27022 2policy_module(ssh,1.2.0)
0404a390
CP
3
4########################################
5#
6# Declarations
7#
8
45239964 9attribute ssh_server;
0404a390 10
0404a390
CP
11# ssh client executable.
12type ssh_exec_t;
8fd36732 13files_type(ssh_exec_t)
0404a390 14
0404a390 15type ssh_keygen_exec_t;
375c2415 16files_type(ssh_keygen_exec_t)
0404a390 17
a0824843
CP
18type ssh_keysign_exec_t;
19files_type(ssh_keysign_exec_t)
20
c3812748
CP
21# real declaration moved to mls until
22# range_transition works in loadable modules
23gen_require(`
24 type sshd_exec_t;
25')
26files_type(sshd_exec_t)
27
375c2415
CP
28type sshd_key_t;
29files_type(sshd_key_t)
9ccd96df 30
375c2415
CP
31ifdef(`targeted_policy',`
32 unconfined_alias_domain(sshd_t)
33 init_system_domain(sshd_t,sshd_exec_t)
2d13f729
CP
34
35 type sshd_var_run_t;
36 files_type(sshd_var_run_t)
b488014f
CP
37
38 # FIXME
39 typeattribute ssh_exec_t entry_type;
40 typeattribute ssh_keygen_exec_t entry_type;
41 typeattribute ssh_keysign_exec_t entry_type;
375c2415
CP
42',`
43 # Type for the ssh-agent executable.
44 type ssh_agent_exec_t;
45 files_type(ssh_agent_exec_t)
46
47 type ssh_keygen_t;
48 init_system_domain(ssh_keygen_t,ssh_keygen_exec_t)
49 role system_r types ssh_keygen_t;
50
51 ssh_server_template(sshd)
52 ssh_server_template(sshd_extern)
53
54 # cjp: commenting this out until typeattribute works in a conditional
1328802a 55# optional_policy(`inetd',`
375c2415
CP
56# tunable_policy(`run_ssh_inetd',`
57# inetd_tcp_service_domain(sshd_t,sshd_exec_t)
58# ',`
59# init_daemon_domain(sshd_t,sshd_exec_t)
60# ')
80436b9b 61# ',`
375c2415
CP
62 # These rules should match the else block
63 # of the run_ssh_inetd tunable directly above
64 init_daemon_domain(sshd_t,sshd_exec_t)
80436b9b 65# ')
0404a390 66
375c2415
CP
67 type sshd_tmp_t;
68 files_tmp_file(sshd_tmp_t)
69')
0404a390
CP
70
71#################################
72#
73# sshd local policy
74#
75# sshd_t is the domain for the sshd program.
76#
77
375c2415
CP
78ifdef(`targeted_policy',`',`
79 # so a tunnel can point to another ssh tunnel
80 allow sshd_t self:tcp_socket { acceptfrom connectto recvfrom };
0404a390 81
375c2415
CP
82 allow sshd_t sshd_tmp_t:dir create_dir_perms;
83 allow sshd_t sshd_tmp_t:file create_file_perms;
84 allow sshd_t sshd_tmp_t:sock_file create_file_perms;
9d594986 85 files_filetrans_tmp(sshd_t, sshd_tmp_t, { dir file sock_file })
0404a390 86
375c2415
CP
87 # for X forwarding
88 corenet_tcp_bind_xserver_port(sshd_t)
0404a390 89
bf080a46
CP
90 mls_file_read_up(sshd_t)
91 mls_file_write_down(sshd_t)
92 mls_file_upgrade(sshd_t)
93 mls_file_downgrade(sshd_t)
94 mls_process_set_level(sshd_t)
95
375c2415 96 auth_exec_pam(sshd_t)
e5590ea5 97
375c2415 98 seutil_read_config(sshd_t)
e5590ea5 99
375c2415
CP
100 tunable_policy(`ssh_sysadm_login',`
101 # Relabel and access ptys created by sshd
102 # ioctl is necessary for logout() processing for utmp entry and for w to
103 # display the tty.
104 # some versions of sshd on the new SE Linux require setattr
105 term_use_all_user_ptys(sshd_t)
106 term_setattr_all_user_ptys(sshd_t)
107 term_relabelto_all_user_ptys(sshd_t)
108
109 userdom_spec_domtrans_all_users(sshd_t)
110 userdom_signal_all_users(sshd_t)
111 ',`
112 userdom_spec_domtrans_unpriv_users(sshd_t)
113 userdom_signal_unpriv_users(sshd_t)
114 ')
bbdbdb9e 115
44d5d93f
CP
116 optional_policy(`daemontools',`
117 daemontools_service_domain(sshd_t, sshd_exec_t)
118 ')
119
1328802a 120 optional_policy(`rpm',`
375c2415 121 rpm_use_script_fd(sshd_t)
0404a390 122 ')
375c2415
CP
123
124 ifdef(`TODO',`
125 tunable_policy(`ssh_sysadm_login',`
126 # Relabel and access ptys created by sshd
127 # ioctl is necessary for logout() processing for utmp entry and for w to
128 # display the tty.
129 # some versions of sshd on the new SE Linux require setattr
130 allow sshd_t ptyfile:chr_file relabelto;
131
1328802a 132 optional_policy(`xauth',`
375c2415
CP
133 domain_trans(sshd_t, xauth_exec_t, userdomain)
134 ')
135 ',`
1328802a 136 optional_policy(`xauth',`
375c2415
CP
137 domain_trans(sshd_t, xauth_exec_t, unpriv_userdomain)
138 ')
139 # Relabel and access ptys created by sshd
140 # ioctl is necessary for logout() processing for utmp entry and for w to
141 # display the tty.
142 # some versions of sshd on the new SE Linux require setattr
143 allow sshd_t userpty_type:chr_file { relabelto read write getattr ioctl setattr };
0404a390 144 ')
375c2415 145 ') dnl endif TODO
9ccd96df 146')
0404a390
CP
147
148#################################
149#
150# sshd_extern local policy
151#
152# sshd_extern_t is the domain for ssh from outside our network
153#
0404a390 154
375c2415
CP
155ifdef(`targeted_policy',`',`
156 ifdef(`TODO',`
157 domain_trans(sshd_extern_t, shell_exec_t, user_mini_domain)
158 # Signal the user domains.
159 allow sshd_extern_t user_mini_domain:process signal;
0404a390 160
375c2415
CP
161 ifdef(`xauth.te', `
162 domain_trans(sshd_extern_t, xauth_exec_t, user_mini_domain)
163 ')
0404a390 164
375c2415
CP
165 # Relabel and access ptys created by sshd
166 # ioctl is necessary for logout() processing for utmp entry and for w to
167 # display the tty.
168 # some versions of sshd on the new SE Linux require setattr
169 allow sshd_extern_t user_mini_domain:chr_file { relabelto read write getattr ioctl setattr };
170
171 # inheriting stream sockets is needed for "ssh host command" as no pty
172 # is allocated
173 allow user_mini_domain sshd_extern_t:unix_stream_socket rw_stream_socket_perms;
174
1328802a 175 optional_policy(`inetd',`
375c2415
CP
176 tunable_policy(`run_ssh_inetd',`
177 domain_trans(inetd_t, sshd_exec_t, sshd_extern_t)
178 ',`
179 domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
180 ')
9ccd96df 181 ',`
375c2415
CP
182 # These rules should match the else block
183 # of the run_ssh_inetd tunable directly above
0404a390 184 domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
9ccd96df 185 ')
0404a390 186
375c2415
CP
187 ifdef(`direct_sysadm_daemon', `
188 # Direct execution by sysadm_r.
189 domain_auto_trans(sysadm_t, sshd_exec_t, sshd_t)
190 role_transition sysadm_r sshd_exec_t system_r;
191 ')
0404a390 192
375c2415
CP
193 # for port forwarding
194 allow userdomain sshd_t:tcp_socket { connectto recvfrom };
195 allow sshd_t userdomain:tcp_socket { acceptfrom recvfrom };
196 allow userdomain kernel_t:tcp_socket recvfrom;
197 allow sshd_t kernel_t:tcp_socket recvfrom;
198 ') dnl endif TODO
199')
0404a390
CP
200
201########################################
202#
203# ssh_keygen local policy
204#
205
375c2415
CP
206ifdef(`targeted_policy',`',`
207 # ssh_keygen_t is the type of the ssh-keygen program when run at install time
208 # and by sysadm_t
0404a390 209
375c2415
CP
210 dontaudit ssh_keygen_t self:capability sys_tty_config;
211 allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal };
0404a390 212
375c2415 213 allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms;
0404a390 214
375c2415 215 allow ssh_keygen_t sshd_key_t:file create_file_perms;
9d594986 216 files_filetrans_etc(ssh_keygen_t,sshd_key_t,file)
0404a390 217
375c2415 218 kernel_read_kernel_sysctl(ssh_keygen_t)
0404a390 219
375c2415 220 fs_search_auto_mountpoints(ssh_keygen_t)
ab940a4c 221
375c2415
CP
222 dev_read_sysfs(ssh_keygen_t)
223 dev_read_urand(ssh_keygen_t)
0404a390 224
375c2415 225 term_dontaudit_use_console(ssh_keygen_t)
0404a390 226
375c2415 227 domain_use_wide_inherit_fd(ssh_keygen_t)
0404a390 228
375c2415 229 files_read_etc_files(ssh_keygen_t)
0404a390 230
375c2415
CP
231 init_use_fd(ssh_keygen_t)
232 init_use_script_pty(ssh_keygen_t)
0404a390 233
375c2415
CP
234 libs_use_ld_so(ssh_keygen_t)
235 libs_use_shared_libs(ssh_keygen_t)
0404a390 236
375c2415 237 logging_send_syslog_msg(ssh_keygen_t)
0404a390 238
375c2415
CP
239 allow ssh_keygen_t proc_t:dir r_dir_perms;
240 allow ssh_keygen_t proc_t:lnk_file read;
0404a390 241
375c2415
CP
242 userdom_use_sysadm_tty(ssh_keygen_t)
243 userdom_dontaudit_use_unpriv_user_fd(ssh_keygen_t)
0404a390 244
375c2415
CP
245 # cjp: with the old daemon_(base_)domain being broken up into
246 # a daemon and system interface, this probably is not needed:
247 ifdef(`direct_sysadm_daemon',`
248 userdom_dontaudit_use_sysadm_terms(ssh_keygen_t)
249 ')
0404a390 250
375c2415
CP
251 ifdef(`targeted_policy', `
252 term_dontaudit_use_unallocated_tty(ssh_keygen_t)
253 term_dontaudit_use_generic_pty(ssh_keygen_t)
254 files_dontaudit_read_root_file(ssh_keygen_t)
255 ')
0404a390 256
1328802a 257 optional_policy(`selinuxutil',`
375c2415
CP
258 seutil_sigchld_newrole(ssh_keygen_t)
259 ')
0404a390 260
1328802a 261 optional_policy(`udev',`
375c2415
CP
262 udev_read_db(ssh_keygen_t)
263 ')
c0d1566a 264')