]> git.ipfire.org Git - people/stevee/selinux-policy.git/blame - policy/modules/services/ssh.te
Merge sbin_t and ls_exec_t into bin_t.
[people/stevee/selinux-policy.git] / policy / modules / services / ssh.te
CommitLineData
0404a390 1
6b19be33 2policy_module(ssh,1.5.1)
0404a390
CP
3
4########################################
5#
6# Declarations
7#
8
45239964 9attribute ssh_server;
0404a390 10
6b19be33
CP
11# Type for the ssh-agent executable.
12type ssh_agent_exec_t;
13files_type(ssh_agent_exec_t)
14
0404a390
CP
15# ssh client executable.
16type ssh_exec_t;
fb63d0b5 17corecmd_executable_file(ssh_exec_t)
0404a390 18
75beb950 19type ssh_keygen_t;
0404a390 20type ssh_keygen_exec_t;
75beb950
CP
21init_system_domain(ssh_keygen_t,ssh_keygen_exec_t)
22role system_r types ssh_keygen_t;
0404a390 23
a0824843 24type ssh_keysign_exec_t;
4c44b8d5 25corecmd_executable_file(ssh_keysign_exec_t)
a0824843 26
e070dd2d 27type sshd_exec_t;
fb63d0b5 28corecmd_executable_file(sshd_exec_t)
c3812748 29
6b19be33
CP
30ssh_server_template(sshd)
31init_daemon_domain(sshd_t,sshd_exec_t)
32
33ssh_server_template(sshd_extern)
34
375c2415
CP
35type sshd_key_t;
36files_type(sshd_key_t)
9ccd96df 37
6b19be33
CP
38type sshd_tmp_t;
39files_tmp_file(sshd_tmp_t)
40files_poly_parent(sshd_tmp_t)
e070dd2d 41
6b19be33
CP
42ifdef(`enable_mcs',`
43 init_ranged_daemon_domain(sshd_t,sshd_exec_t,s0 - mcs_systemhigh)
375c2415 44')
0404a390
CP
45
46#################################
47#
48# sshd local policy
49#
50# sshd_t is the domain for the sshd program.
51#
52
6b19be33
CP
53# so a tunnel can point to another ssh tunnel
54allow sshd_t self:netlink_route_socket r_netlink_socket_perms;
55allow sshd_t self:key { search link write };
bbdbdb9e 56
6b19be33
CP
57manage_dirs_pattern(sshd_t,sshd_tmp_t,sshd_tmp_t)
58manage_files_pattern(sshd_t,sshd_tmp_t,sshd_tmp_t)
59manage_sock_files_pattern(sshd_t,sshd_tmp_t,sshd_tmp_t)
60files_tmp_filetrans(sshd_t, sshd_tmp_t, { dir file sock_file })
44d5d93f 61
6b19be33
CP
62kernel_search_key(sshd_t)
63kernel_link_key(sshd_t)
64
65# for X forwarding
66corenet_tcp_bind_xserver_port(sshd_t)
67corenet_sendrecv_xserver_server_packets(sshd_t)
68
69ifdef(`targeted_policy',`
70 unconfined_domain(sshd_t)
71')
72
73tunable_policy(`ssh_sysadm_login',`
74 # Relabel and access ptys created by sshd
75 # ioctl is necessary for logout() processing for utmp entry and for w to
76 # display the tty.
77 # some versions of sshd on the new SE Linux require setattr
78 term_use_all_user_ptys(sshd_t)
79 term_setattr_all_user_ptys(sshd_t)
80 term_relabelto_all_user_ptys(sshd_t)
81
82 userdom_spec_domtrans_all_users(sshd_t)
83 userdom_signal_all_users(sshd_t)
84',`
85 userdom_spec_domtrans_unpriv_users(sshd_t)
86 userdom_signal_unpriv_users(sshd_t)
87
88 userdom_setattr_unpriv_users_ptys(sshd_t)
89 userdom_relabelto_unpriv_users_ptys(sshd_t)
90 userdom_use_unpriv_users_ptys(sshd_t)
91')
92
93optional_policy(`
94 daemontools_service_domain(sshd_t, sshd_exec_t)
95')
96
97optional_policy(`
98 inetd_tcp_service_domain(sshd_t, sshd_exec_t)
99')
100
101optional_policy(`
102 rpm_use_script_fds(sshd_t)
103')
104
105optional_policy(`
106 rssh_spec_domtrans_all_users(sshd_t)
107 # For reading /home/user/.ssh
108 rssh_read_all_users_ro_content(sshd_t)
109')
110
111ifdef(`TODO',`
112tunable_policy(`ssh_sysadm_login',`
113 # Relabel and access ptys created by sshd
114 # ioctl is necessary for logout() processing for utmp entry and for w to
115 # display the tty.
116 # some versions of sshd on the new SE Linux require setattr
117 allow sshd_t ptyfile:chr_file relabelto;
375c2415 118
5540e76a 119 optional_policy(`
6b19be33 120 domain_trans(sshd_t, xauth_exec_t, userdomain)
5540e76a 121 ')
6b19be33
CP
122',`
123 optional_policy(`
124 domain_trans(sshd_t, xauth_exec_t, unpriv_userdomain)
0404a390 125 ')
6b19be33
CP
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 userpty_type:chr_file { relabelto read write getattr ioctl setattr };
9ccd96df 131')
6b19be33 132') dnl endif TODO
0404a390
CP
133
134#################################
135#
136# sshd_extern local policy
137#
138# sshd_extern_t is the domain for ssh from outside our network
139#
0404a390 140
5540e76a 141ifdef(`strict_policy',`
375c2415
CP
142 ifdef(`TODO',`
143 domain_trans(sshd_extern_t, shell_exec_t, user_mini_domain)
144 # Signal the user domains.
145 allow sshd_extern_t user_mini_domain:process signal;
0404a390 146
375c2415
CP
147 ifdef(`xauth.te', `
148 domain_trans(sshd_extern_t, xauth_exec_t, user_mini_domain)
149 ')
0404a390 150
375c2415
CP
151 # Relabel and access ptys created by sshd
152 # ioctl is necessary for logout() processing for utmp entry and for w to
153 # display the tty.
154 # some versions of sshd on the new SE Linux require setattr
155 allow sshd_extern_t user_mini_domain:chr_file { relabelto read write getattr ioctl setattr };
156
157 # inheriting stream sockets is needed for "ssh host command" as no pty
158 # is allocated
159 allow user_mini_domain sshd_extern_t:unix_stream_socket rw_stream_socket_perms;
160
bb7170f6 161 optional_policy(`
375c2415
CP
162 tunable_policy(`run_ssh_inetd',`
163 domain_trans(inetd_t, sshd_exec_t, sshd_extern_t)
164 ',`
165 domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
166 ')
9ccd96df 167 ',`
375c2415
CP
168 # These rules should match the else block
169 # of the run_ssh_inetd tunable directly above
0404a390 170 domain_trans(initrc_t, sshd_exec_t, sshd_extern_t)
9ccd96df 171 ')
0404a390 172
375c2415
CP
173 ifdef(`direct_sysadm_daemon', `
174 # Direct execution by sysadm_r.
175 domain_auto_trans(sysadm_t, sshd_exec_t, sshd_t)
176 role_transition sysadm_r sshd_exec_t system_r;
177 ')
375c2415
CP
178 ') dnl endif TODO
179')
0404a390
CP
180
181########################################
182#
183# ssh_keygen local policy
184#
185
75beb950
CP
186# ssh_keygen_t is the type of the ssh-keygen program when run at install time
187# and by sysadm_t
0404a390 188
75beb950
CP
189dontaudit ssh_keygen_t self:capability sys_tty_config;
190allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal };
0404a390 191
75beb950 192allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms;
0404a390 193
c0868a7a 194allow ssh_keygen_t sshd_key_t:file manage_file_perms;
75beb950 195files_etc_filetrans(ssh_keygen_t,sshd_key_t,file)
0404a390 196
75beb950 197kernel_read_kernel_sysctls(ssh_keygen_t)
0404a390 198
75beb950 199fs_search_auto_mountpoints(ssh_keygen_t)
ab940a4c 200
75beb950
CP
201dev_read_sysfs(ssh_keygen_t)
202dev_read_urand(ssh_keygen_t)
0404a390 203
75beb950 204term_dontaudit_use_console(ssh_keygen_t)
0404a390 205
75beb950 206domain_use_interactive_fds(ssh_keygen_t)
0404a390 207
75beb950 208files_read_etc_files(ssh_keygen_t)
0404a390 209
75beb950
CP
210init_use_fds(ssh_keygen_t)
211init_use_script_ptys(ssh_keygen_t)
0404a390 212
75beb950
CP
213libs_use_ld_so(ssh_keygen_t)
214libs_use_shared_libs(ssh_keygen_t)
0404a390 215
75beb950 216logging_send_syslog_msg(ssh_keygen_t)
0404a390 217
75beb950
CP
218allow ssh_keygen_t proc_t:dir r_dir_perms;
219allow ssh_keygen_t proc_t:lnk_file read;
0404a390 220
75beb950
CP
221userdom_use_sysadm_ttys(ssh_keygen_t)
222userdom_dontaudit_use_unpriv_user_fds(ssh_keygen_t)
0404a390 223
75beb950
CP
224# cjp: with the old daemon_(base_)domain being broken up into
225# a daemon and system interface, this probably is not needed:
226ifdef(`direct_sysadm_daemon',`
227 userdom_dontaudit_use_sysadm_terms(ssh_keygen_t)
228')
0404a390 229
75beb950
CP
230ifdef(`targeted_policy',`
231 term_dontaudit_use_unallocated_ttys(ssh_keygen_t)
232 term_dontaudit_use_generic_ptys(ssh_keygen_t)
233 files_dontaudit_read_root_files(ssh_keygen_t)
234')
0404a390 235
75beb950
CP
236optional_policy(`
237 nscd_socket_use(ssh_keygen_t)
238')
0404a390 239
75beb950
CP
240optional_policy(`
241 seutil_sigchld_newrole(ssh_keygen_t)
242')
243
244optional_policy(`
245 udev_read_db(ssh_keygen_t)
c0d1566a 246')