]>
Commit | Line | Data |
---|---|---|
0404a390 CP |
1 | |
2 | policy_module(ssh,1.0) | |
3 | ||
4 | ######################################## | |
5 | # | |
6 | # Declarations | |
7 | # | |
8 | ||
9 | # Allow ssh logins as sysadm_r:sysadm_t | |
10 | bool ssh_sysadm_login false; | |
11 | ||
12 | # Allow ssh to run from inetd instead of as a daemon. | |
13 | bool run_ssh_inetd false; | |
14 | ||
15 | # Type for the ssh-agent executable. | |
16 | type ssh_agent_exec_t; | |
17 | files_file_type(ssh_agent_exec_t) | |
18 | ||
19 | # ssh client executable. | |
20 | type ssh_exec_t; | |
21 | files_file_type(ssh_exec_t) | |
22 | ||
23 | type ssh_keygen_t; | |
24 | type ssh_keygen_exec_t; | |
25 | init_daemon_domain(ssh_keygen_t,ssh_keygen_exec_t) | |
26 | role system_r types ssh_keygen_t; | |
27 | ||
9ccd96df CP |
28 | sshd_program_domain(sshd) |
29 | ||
0404a390 CP |
30 | type sshd_exec_t; |
31 | files_file_type(sshd_exec_t) | |
32 | ||
9ccd96df CP |
33 | sshd_program_domain(sshd_extern) |
34 | ||
0404a390 CP |
35 | type sshd_key_t; |
36 | files_file_type(sshd_key_t) | |
37 | ||
38 | type sshd_tmp_t; | |
39 | files_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 |
49 | allow sshd_t self:tcp_socket { acceptfrom connectto recvfrom }; | |
0404a390 CP |
50 | |
51 | allow sshd_t sshd_tmp_t:dir create_dir_perms; | |
52 | allow sshd_t sshd_tmp_t:file create_file_perms; | |
53 | allow sshd_t sshd_tmp_t:sock_file create_file_perms; | |
54 | files_create_tmp_files(sshd_t, sshd_tmp_t, { dir file sock_file }) | |
55 | ||
56 | # for X forwarding | |
57 | corenet_tcp_bind_xserver_port(sshd_t) | |
58 | ||
59 | auth_exec_pam(sshd_t) | |
60 | ||
61 | seutil_read_config(sshd_t) | |
62 | ||
9ccd96df CP |
63 | # Allow checking users mail at login |
64 | mta_getattr_spool(sshd_t) | |
65 | ||
66 | optional_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 | 78 | ifdef(`TODO',` |
9ccd96df | 79 | tunable_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 | |
112 | tunable_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 | |
117 | dontaudit 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 | 128 | ifdef(`TODO',` |
0404a390 CP |
129 | domain_trans(sshd_extern_t, shell_exec_t, user_mini_domain) |
130 | # Signal the user domains. | |
131 | allow sshd_extern_t user_mini_domain:process signal; | |
132 | ||
133 | ifdef(`xauth.te', ` | |
134 | domain_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 | |
141 | allow 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 | |
145 | allow user_mini_domain sshd_extern_t:unix_stream_socket rw_stream_socket_perms; | |
146 | ||
147 | optional_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 | ||
159 | ifdef(`direct_sysadm_daemon', ` | |
160 | # Direct execution by sysadm_r. | |
161 | domain_auto_trans(sysadm_t, sshd_exec_t, sshd_t) | |
162 | role_transition sysadm_r sshd_exec_t system_r; | |
163 | ') | |
164 | ||
165 | # so a tunnel can point to another ssh tunnel... | |
0404a390 CP |
166 | allow sshd_t kernel_t:tcp_socket recvfrom; |
167 | allow sshd_t kernel_t:tcp_socket recvfrom; | |
168 | ||
169 | # for port forwarding | |
170 | allow userdomain sshd_t:tcp_socket { connectto recvfrom }; | |
171 | allow sshd_t userdomain:tcp_socket { acceptfrom recvfrom }; | |
172 | allow userdomain kernel_t:tcp_socket recvfrom; | |
173 | allow 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 | ||
184 | dontaudit ssh_keygen_t self:capability sys_tty_config; | |
185 | allow ssh_keygen_t self:process { sigchld sigkill sigstop signull signal }; | |
186 | ||
187 | allow ssh_keygen_t self:unix_stream_socket create_stream_socket_perms; | |
188 | ||
189 | allow ssh_keygen_t sshd_key_t:file create_file_perms; | |
190 | files_create_etc_config(ssh_keygen_t,sshd_key_t,file) | |
191 | ||
192 | kernel_read_kernel_sysctl(ssh_keygen_t) | |
193 | ||
194 | dev_read_sysfs(ssh_keygen_t) | |
195 | dev_read_urand(ssh_keygen_t) | |
196 | ||
197 | term_dontaudit_use_console(ssh_keygen_t) | |
198 | ||
199 | domain_use_wide_inherit_fd(ssh_keygen_t) | |
200 | ||
201 | files_read_generic_etc_files(ssh_keygen_t) | |
202 | ||
203 | init_use_fd(ssh_keygen_t) | |
204 | init_use_script_pty(ssh_keygen_t) | |
205 | ||
206 | libs_use_ld_so(ssh_keygen_t) | |
207 | libs_use_shared_libs(ssh_keygen_t) | |
208 | ||
209 | logging_send_syslog_msg(ssh_keygen_t) | |
210 | ||
211 | allow ssh_keygen_t proc_t:dir r_dir_perms; | |
212 | allow ssh_keygen_t proc_t:lnk_file read; | |
213 | ||
214 | userdom_use_sysadm_tty(ssh_keygen_t) | |
215 | userdom_dontaudit_use_unpriv_user_fd(ssh_keygen_t) | |
216 | ||
217 | ifdef(`direct_sysadm_daemon',` | |
218 | userdom_dontaudit_use_sysadm_terms(ssh_keygen_t) | |
219 | ') | |
220 | ||
221 | ifdef(`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 | ||
227 | optional_policy(`rhgb.te', ` | |
228 | rhgb_domain(ssh_keygen_t) | |
229 | ') | |
230 | ||
231 | optional_policy(`selinux.te',` | |
232 | seutil_newrole_sigchld(ssh_keygen_t) | |
233 | ') | |
234 | ||
235 | optional_policy(`udev.te', ` | |
236 | udev_read_db(ssh_keygen_t) | |
237 | ') | |
238 | ||
239 | ifdef(`TODO',` | |
240 | allow ssh_keygen_t autofs_t:dir { search getattr }; | |
241 | ') |