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