]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - refpolicy/policy/modules/services/ssh.te
initial commit of segenxml. add support in Makefile
[people/stevee/selinux-policy.git] / refpolicy / policy / modules / services / ssh.te
CommitLineData
0404a390
CP
1
2policy_module(ssh,1.0)
3
4########################################
5#
6# Declarations
7#
8
9# Allow ssh logins as sysadm_r:sysadm_t
10bool ssh_sysadm_login false;
11
12# Allow ssh to run from inetd instead of as a daemon.
13bool run_ssh_inetd false;
14
15# Type for the ssh-agent executable.
16type ssh_agent_exec_t;
17files_file_type(ssh_agent_exec_t)
18
19# ssh client executable.
20type ssh_exec_t;
21files_file_type(ssh_exec_t)
22
23type ssh_keygen_t;
24type ssh_keygen_exec_t;
25init_daemon_domain(ssh_keygen_t,ssh_keygen_exec_t)
26role system_r types ssh_keygen_t;
27
9ccd96df
CP
28sshd_program_domain(sshd)
29
0404a390
CP
30type sshd_exec_t;
31files_file_type(sshd_exec_t)
32
9ccd96df
CP
33sshd_program_domain(sshd_extern)
34
0404a390
CP
35type sshd_key_t;
36files_file_type(sshd_key_t)
37
38type sshd_tmp_t;
39files_tmp_file(sshd_tmp_t)
40
41#################################
42#
43# sshd local policy
44#
45# sshd_t is the domain for the sshd program.
46#
47
9ccd96df
CP
48# so a tunnel can point to another ssh tunnel
49allow sshd_t self:tcp_socket { acceptfrom connectto recvfrom };
0404a390
CP
50
51allow sshd_t sshd_tmp_t:dir create_dir_perms;
52allow sshd_t sshd_tmp_t:file create_file_perms;
53allow sshd_t sshd_tmp_t:sock_file create_file_perms;
54files_create_tmp_files(sshd_t, sshd_tmp_t, { dir file sock_file })
55
56# for X forwarding
57corenet_tcp_bind_xserver_port(sshd_t)
58
59auth_exec_pam(sshd_t)
60
61seutil_read_config(sshd_t)
62
9ccd96df
CP
63# Allow checking users mail at login
64mta_getattr_spool(sshd_t)
65
66optional_policy(`inetd.te',`
67 tunable_policy(`run_ssh_inetd',`
68 inetd_service_domain(sshd_t,sshd_exec_t)
69 ',`
70 init_daemon_domain(sshd_t,sshd_exec_t)
71 ')
72',`
73 # These rules should match the else block
74 # of the run_ssh_inetd tunable directly above
75 init_daemon_domain(sshd_t,sshd_exec_t)
76')
77
0404a390 78ifdef(`TODO',`
9ccd96df 79tunable_policy(`ssh_sysadm_login',`
0404a390
CP
80 userdom_spec_domtrans_all_users(sshd_t)
81 userdom_signal_all_users(sshd_t)
82
9ccd96df 83 optional_policy(`xauth.te',`
0404a390
CP
84 domain_trans(sshd_t, xauth_exec_t, userdomain)
85 ')
86 # Relabel and access ptys created by sshd
87 # ioctl is necessary for logout() processing for utmp entry and for w to
88 # display the tty.
89 # some versions of sshd on the new SE Linux require setattr
90 allow sshd_t ptyfile:chr_file { relabelto read write getattr ioctl setattr };
91 # inheriting stream sockets is needed for "ssh host command" as no pty
92 # is allocated
93 allow userdomain sshd_t:unix_stream_socket rw_stream_socket_perms;
9ccd96df 94',`
0404a390
CP
95 userdom_spec_domtrans_unpriv_users(sshd_t)
96 userdom_signal_unpriv_users(sshd_t)
97
9ccd96df 98 optional_policy(`xauth.te',`
0404a390
CP
99 domain_trans(sshd_t, xauth_exec_t, unpriv_userdomain)
100 ')
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 allow sshd_t userpty_type:chr_file { relabelto read write getattr ioctl setattr };
106 # inheriting stream sockets is needed for "ssh host command" as no pty
107 # is allocated
108 allow userdomain sshd_t:unix_stream_socket rw_stream_socket_perms;
9ccd96df
CP
109')
110
111# this goes to inetd
112tunable_policy(`run_ssh_inetd',`
113 corenet_tcp_bind_ssh_port(inetd_t)
114')
0404a390
CP
115
116# for when the network connection breaks after running newrole -r sysadm_r
117dontaudit sshd_t sysadm_devpts_t:chr_file setattr;
118
0404a390
CP
119') dnl endif TODO
120
121#################################
122#
123# sshd_extern local policy
124#
125# sshd_extern_t is the domain for ssh from outside our network
126#
0404a390 127
9ccd96df 128ifdef(`TODO',`
0404a390
CP
129domain_trans(sshd_extern_t, shell_exec_t, user_mini_domain)
130# Signal the user domains.
131allow sshd_extern_t user_mini_domain:process signal;
132
133ifdef(`xauth.te', `
134domain_trans(sshd_extern_t, xauth_exec_t, user_mini_domain)
135')
136
137# Relabel and access ptys created by sshd
138# ioctl is necessary for logout() processing for utmp entry and for w to
139# display the tty.
140# some versions of sshd on the new SE Linux require setattr
141allow sshd_extern_t user_mini_domain:chr_file { relabelto read write getattr ioctl setattr };
142
143# inheriting stream sockets is needed for "ssh host command" as no pty
144# is allocated
145allow user_mini_domain sshd_extern_t:unix_stream_socket rw_stream_socket_perms;
146
147optional_policy(`inetd.te',`
9ccd96df 148 tunable_policy(`run_ssh_inetd',`
0404a390 149 domain_trans(inetd_t, sshd_exec_t, sshd_extern_t)
9ccd96df 150 ',`
0404a390 151 domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
9ccd96df 152 ')
0404a390
CP
153',`
154 # These rules should match the else block
9ccd96df 155 # of the run_ssh_inetd tunable directly above
0404a390 156 domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
0404a390
CP
157')
158
159ifdef(`direct_sysadm_daemon', `
160# Direct execution by sysadm_r.
161domain_auto_trans(sysadm_t, sshd_exec_t, sshd_t)
162role_transition sysadm_r sshd_exec_t system_r;
163')
164
165# so a tunnel can point to another ssh tunnel...
0404a390
CP
166allow sshd_t kernel_t:tcp_socket recvfrom;
167allow sshd_t kernel_t:tcp_socket recvfrom;
168
169# for port forwarding
170allow userdomain sshd_t:tcp_socket { connectto recvfrom };
171allow sshd_t userdomain:tcp_socket { acceptfrom recvfrom };
172allow userdomain kernel_t:tcp_socket recvfrom;
173allow sshd_t kernel_t:tcp_socket recvfrom;
174') dnl endif TODO
175
176########################################
177#
178# ssh_keygen local policy
179#
180
181# ssh_keygen_t is the type of the ssh-keygen program when run at install time
182# and by sysadm_t
183
184dontaudit ssh_keygen_t self:capability sys_tty_config;
185allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal };
186
187allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms;
188
189allow ssh_keygen_t sshd_key_t:file create_file_perms;
190files_create_etc_config(ssh_keygen_t,sshd_key_t,file)
191
192kernel_read_kernel_sysctl(ssh_keygen_t)
193
194dev_read_sysfs(ssh_keygen_t)
195dev_read_urand(ssh_keygen_t)
196
197term_dontaudit_use_console(ssh_keygen_t)
198
199domain_use_wide_inherit_fd(ssh_keygen_t)
200
201files_read_generic_etc_files(ssh_keygen_t)
202
203init_use_fd(ssh_keygen_t)
204init_use_script_pty(ssh_keygen_t)
205
206libs_use_ld_so(ssh_keygen_t)
207libs_use_shared_libs(ssh_keygen_t)
208
209logging_send_syslog_msg(ssh_keygen_t)
210
211allow ssh_keygen_t proc_t:dir r_dir_perms;
212allow ssh_keygen_t proc_t:lnk_file read;
213
214userdom_use_sysadm_tty(ssh_keygen_t)
215userdom_dontaudit_use_unpriv_user_fd(ssh_keygen_t)
216
217ifdef(`direct_sysadm_daemon',`
218 userdom_dontaudit_use_sysadm_terms(ssh_keygen_t)
219')
220
221ifdef(`targeted_policy', `
222 term_dontaudit_use_unallocated_tty(ssh_keygen_t)
223 term_dontaudit_use_generic_pty(ssh_keygen_t)
224 files_dontaudit_read_root_file(ssh_keygen_t)
225')
226
227optional_policy(`rhgb.te', `
228 rhgb_domain(ssh_keygen_t)
229')
230
231optional_policy(`selinux.te',`
232 seutil_newrole_sigchld(ssh_keygen_t)
233')
234
235optional_policy(`udev.te', `
236 udev_read_db(ssh_keygen_t)
237')
238
239ifdef(`TODO',`
240allow ssh_keygen_t autofs_t:dir { search getattr };
241')