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