]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - refpolicy/policy/modules/services/ssh.te
clean up unused booleans
[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
45239964 9attribute ssh_server;
0404a390
CP
10
11# Type for the ssh-agent executable.
12type ssh_agent_exec_t;
8fd36732 13files_type(ssh_agent_exec_t)
0404a390
CP
14
15# ssh client executable.
16type ssh_exec_t;
8fd36732 17files_type(ssh_exec_t)
0404a390
CP
18
19type ssh_keygen_t;
20type ssh_keygen_exec_t;
e5f80603 21init_system_domain(ssh_keygen_t,ssh_keygen_exec_t)
0404a390
CP
22role system_r types ssh_keygen_t;
23
a0824843
CP
24type ssh_keysign_exec_t;
25files_type(ssh_keysign_exec_t)
26
c3812748
CP
27# real declaration moved to mls until
28# range_transition works in loadable modules
29gen_require(`
30 type sshd_exec_t;
31')
32files_type(sshd_exec_t)
33
8fd36732 34ssh_server_template(sshd)
c3812748 35ssh_server_template(sshd_extern)
9ccd96df 36
c0d1566a 37# cjp: commenting this out until typeattribute works in a conditional
0fdf3ef7 38#optional_policy(`inetd.te',`
80436b9b 39# tunable_policy(`run_ssh_inetd',`
9ff30033 40# inetd_tcp_service_domain(sshd_t,sshd_exec_t)
80436b9b 41# ',`
0fdf3ef7 42# init_daemon_domain(sshd_t,sshd_exec_t)
80436b9b 43# ')
0fdf3ef7 44#',`
80436b9b
CP
45 # These rules should match the else block
46 # of the run_ssh_inetd tunable directly above
47 init_daemon_domain(sshd_t,sshd_exec_t)
0fdf3ef7 48#')
80436b9b 49
0404a390 50type sshd_key_t;
8fd36732 51files_type(sshd_key_t)
0404a390
CP
52
53type sshd_tmp_t;
54files_tmp_file(sshd_tmp_t)
55
56#################################
57#
58# sshd local policy
59#
60# sshd_t is the domain for the sshd program.
61#
62
9ccd96df
CP
63# so a tunnel can point to another ssh tunnel
64allow sshd_t self:tcp_socket { acceptfrom connectto recvfrom };
0404a390
CP
65
66allow sshd_t sshd_tmp_t:dir create_dir_perms;
67allow sshd_t sshd_tmp_t:file create_file_perms;
68allow sshd_t sshd_tmp_t:sock_file create_file_perms;
69files_create_tmp_files(sshd_t, sshd_tmp_t, { dir file sock_file })
70
71# for X forwarding
72corenet_tcp_bind_xserver_port(sshd_t)
73
74auth_exec_pam(sshd_t)
75
76seutil_read_config(sshd_t)
77
142e9f40
CP
78ifdef(`targeted_policy',`
79 unconfined_domain_template(sshd_t)
80')
81
e5590ea5
CP
82tunable_policy(`ssh_sysadm_login',`
83 # Relabel and access ptys created by sshd
84 # ioctl is necessary for logout() processing for utmp entry and for w to
85 # display the tty.
86 # some versions of sshd on the new SE Linux require setattr
e5590ea5
CP
87 term_use_all_user_ptys(sshd_t)
88 term_setattr_all_user_ptys(sshd_t)
89 term_relabelto_all_user_ptys(sshd_t)
90
91 userdom_spec_domtrans_all_users(sshd_t)
92 userdom_signal_all_users(sshd_t)
93',`
94 userdom_spec_domtrans_unpriv_users(sshd_t)
95 userdom_signal_unpriv_users(sshd_t)
96')
97
df00b2e2
CP
98optional_policy(`rpm.te',`
99 rpm_use_script_fd(sshd_t)
100')
101
0404a390 102ifdef(`TODO',`
9ccd96df 103tunable_policy(`ssh_sysadm_login',`
bbdbdb9e
CP
104 # Relabel and access ptys created by sshd
105 # ioctl is necessary for logout() processing for utmp entry and for w to
106 # display the tty.
107 # some versions of sshd on the new SE Linux require setattr
108 allow sshd_t ptyfile:chr_file relabelto;
109
9ccd96df 110 optional_policy(`xauth.te',`
0404a390
CP
111 domain_trans(sshd_t, xauth_exec_t, userdomain)
112 ')
9ccd96df 113',`
9ccd96df 114 optional_policy(`xauth.te',`
0404a390
CP
115 domain_trans(sshd_t, xauth_exec_t, unpriv_userdomain)
116 ')
117 # Relabel and access ptys created by sshd
118 # ioctl is necessary for logout() processing for utmp entry and for w to
119 # display the tty.
120 # some versions of sshd on the new SE Linux require setattr
121 allow sshd_t userpty_type:chr_file { relabelto read write getattr ioctl setattr };
9ccd96df 122')
0404a390
CP
123') dnl endif TODO
124
125#################################
126#
127# sshd_extern local policy
128#
129# sshd_extern_t is the domain for ssh from outside our network
130#
0404a390 131
9ccd96df 132ifdef(`TODO',`
0404a390
CP
133domain_trans(sshd_extern_t, shell_exec_t, user_mini_domain)
134# Signal the user domains.
135allow sshd_extern_t user_mini_domain:process signal;
136
137ifdef(`xauth.te', `
138domain_trans(sshd_extern_t, xauth_exec_t, user_mini_domain)
139')
140
141# Relabel and access ptys created by sshd
142# ioctl is necessary for logout() processing for utmp entry and for w to
143# display the tty.
144# some versions of sshd on the new SE Linux require setattr
145allow sshd_extern_t user_mini_domain:chr_file { relabelto read write getattr ioctl setattr };
146
147# inheriting stream sockets is needed for "ssh host command" as no pty
148# is allocated
149allow user_mini_domain sshd_extern_t:unix_stream_socket rw_stream_socket_perms;
150
151optional_policy(`inetd.te',`
9ccd96df 152 tunable_policy(`run_ssh_inetd',`
0404a390 153 domain_trans(inetd_t, sshd_exec_t, sshd_extern_t)
9ccd96df 154 ',`
0404a390 155 domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
9ccd96df 156 ')
0404a390
CP
157',`
158 # These rules should match the else block
9ccd96df 159 # of the run_ssh_inetd tunable directly above
0404a390 160 domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
0404a390
CP
161')
162
163ifdef(`direct_sysadm_daemon', `
164# Direct execution by sysadm_r.
165domain_auto_trans(sysadm_t, sshd_exec_t, sshd_t)
166role_transition sysadm_r sshd_exec_t system_r;
167')
168
0404a390
CP
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
ab940a4c
CP
194fs_search_auto_mountpoints(ssh_keygen_t)
195
0404a390
CP
196dev_read_sysfs(ssh_keygen_t)
197dev_read_urand(ssh_keygen_t)
198
199term_dontaudit_use_console(ssh_keygen_t)
200
201domain_use_wide_inherit_fd(ssh_keygen_t)
202
8fd36732 203files_read_etc_files(ssh_keygen_t)
0404a390
CP
204
205init_use_fd(ssh_keygen_t)
206init_use_script_pty(ssh_keygen_t)
207
208libs_use_ld_so(ssh_keygen_t)
209libs_use_shared_libs(ssh_keygen_t)
210
211logging_send_syslog_msg(ssh_keygen_t)
212
213allow ssh_keygen_t proc_t:dir r_dir_perms;
214allow ssh_keygen_t proc_t:lnk_file read;
215
216userdom_use_sysadm_tty(ssh_keygen_t)
217userdom_dontaudit_use_unpriv_user_fd(ssh_keygen_t)
218
e5f80603
CP
219# cjp: with the old daemon_(base_)domain being broken up into
220# a daemon and system interface, this probably is not needed:
0404a390
CP
221ifdef(`direct_sysadm_daemon',`
222 userdom_dontaudit_use_sysadm_terms(ssh_keygen_t)
223')
224
225ifdef(`targeted_policy', `
226 term_dontaudit_use_unallocated_tty(ssh_keygen_t)
227 term_dontaudit_use_generic_pty(ssh_keygen_t)
228 files_dontaudit_read_root_file(ssh_keygen_t)
229')
230
ae9e2716 231optional_policy(`selinuxutil.te',`
8fd36732 232 seutil_sigchld_newrole(ssh_keygen_t)
0404a390
CP
233')
234
235optional_policy(`udev.te', `
236 udev_read_db(ssh_keygen_t)
237')
c0d1566a
CP
238
239ifdef(`TODO',`
240optional_policy(`rhgb.te', `
241 rhgb_domain(ssh_keygen_t)
242')
243')