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