]>
Commit | Line | Data |
---|---|---|
1 | ||
2 | policy_module(ssh,1.0) | |
3 | ||
4 | ######################################## | |
5 | # | |
6 | # Declarations | |
7 | # | |
8 | ||
9 | attribute ssh_server; | |
10 | ||
11 | # Type for the ssh-agent executable. | |
12 | type ssh_agent_exec_t; | |
13 | files_type(ssh_agent_exec_t) | |
14 | ||
15 | # ssh client executable. | |
16 | type ssh_exec_t; | |
17 | files_type(ssh_exec_t) | |
18 | ||
19 | type ssh_keygen_t; | |
20 | type ssh_keygen_exec_t; | |
21 | init_system_domain(ssh_keygen_t,ssh_keygen_exec_t) | |
22 | role system_r types ssh_keygen_t; | |
23 | ||
24 | type ssh_keysign_exec_t; | |
25 | files_type(ssh_keysign_exec_t) | |
26 | ||
27 | # real declaration moved to mls until | |
28 | # range_transition works in loadable modules | |
29 | gen_require(` | |
30 | type sshd_exec_t; | |
31 | ') | |
32 | files_type(sshd_exec_t) | |
33 | ||
34 | ssh_server_template(sshd) | |
35 | ssh_server_template(sshd_extern) | |
36 | ||
37 | # cjp: commenting this out until typeattribute works in a conditional | |
38 | #optional_policy(`inetd.te',` | |
39 | # tunable_policy(`run_ssh_inetd',` | |
40 | # inetd_tcp_service_domain(sshd_t,sshd_exec_t) | |
41 | # ',` | |
42 | # init_daemon_domain(sshd_t,sshd_exec_t) | |
43 | # ') | |
44 | #',` | |
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) | |
48 | #') | |
49 | ||
50 | type sshd_key_t; | |
51 | files_type(sshd_key_t) | |
52 | ||
53 | type sshd_tmp_t; | |
54 | files_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 | ||
63 | # so a tunnel can point to another ssh tunnel | |
64 | allow sshd_t self:tcp_socket { acceptfrom connectto recvfrom }; | |
65 | ||
66 | allow sshd_t sshd_tmp_t:dir create_dir_perms; | |
67 | allow sshd_t sshd_tmp_t:file create_file_perms; | |
68 | allow sshd_t sshd_tmp_t:sock_file create_file_perms; | |
69 | files_create_tmp_files(sshd_t, sshd_tmp_t, { dir file sock_file }) | |
70 | ||
71 | # for X forwarding | |
72 | corenet_tcp_bind_xserver_port(sshd_t) | |
73 | ||
74 | auth_exec_pam(sshd_t) | |
75 | ||
76 | seutil_read_config(sshd_t) | |
77 | ||
78 | ifdef(`targeted_policy',` | |
79 | unconfined_domain_template(sshd_t) | |
80 | ') | |
81 | ||
82 | tunable_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 | |
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 | ||
98 | optional_policy(`rpm.te',` | |
99 | rpm_use_script_fd(sshd_t) | |
100 | ') | |
101 | ||
102 | ifdef(`TODO',` | |
103 | tunable_policy(`ssh_sysadm_login',` | |
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 | ||
110 | optional_policy(`xauth.te',` | |
111 | domain_trans(sshd_t, xauth_exec_t, userdomain) | |
112 | ') | |
113 | ',` | |
114 | optional_policy(`xauth.te',` | |
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 }; | |
122 | ') | |
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 | # | |
131 | ||
132 | ifdef(`TODO',` | |
133 | domain_trans(sshd_extern_t, shell_exec_t, user_mini_domain) | |
134 | # Signal the user domains. | |
135 | allow sshd_extern_t user_mini_domain:process signal; | |
136 | ||
137 | ifdef(`xauth.te', ` | |
138 | domain_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 | |
145 | allow 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 | |
149 | allow user_mini_domain sshd_extern_t:unix_stream_socket rw_stream_socket_perms; | |
150 | ||
151 | optional_policy(`inetd.te',` | |
152 | tunable_policy(`run_ssh_inetd',` | |
153 | domain_trans(inetd_t, sshd_exec_t, sshd_extern_t) | |
154 | ',` | |
155 | domain_trans(initrc_t, sshd_exec_t, sshd_extern_t) | |
156 | ') | |
157 | ',` | |
158 | # These rules should match the else block | |
159 | # of the run_ssh_inetd tunable directly above | |
160 | domain_trans(initrc_t, sshd_exec_t, sshd_extern_t) | |
161 | ') | |
162 | ||
163 | ifdef(`direct_sysadm_daemon', ` | |
164 | # Direct execution by sysadm_r. | |
165 | domain_auto_trans(sysadm_t, sshd_exec_t, sshd_t) | |
166 | role_transition sysadm_r sshd_exec_t system_r; | |
167 | ') | |
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 | fs_search_auto_mountpoints(ssh_keygen_t) | |
195 | ||
196 | dev_read_sysfs(ssh_keygen_t) | |
197 | dev_read_urand(ssh_keygen_t) | |
198 | ||
199 | term_dontaudit_use_console(ssh_keygen_t) | |
200 | ||
201 | domain_use_wide_inherit_fd(ssh_keygen_t) | |
202 | ||
203 | files_read_etc_files(ssh_keygen_t) | |
204 | ||
205 | init_use_fd(ssh_keygen_t) | |
206 | init_use_script_pty(ssh_keygen_t) | |
207 | ||
208 | libs_use_ld_so(ssh_keygen_t) | |
209 | libs_use_shared_libs(ssh_keygen_t) | |
210 | ||
211 | logging_send_syslog_msg(ssh_keygen_t) | |
212 | ||
213 | allow ssh_keygen_t proc_t:dir r_dir_perms; | |
214 | allow ssh_keygen_t proc_t:lnk_file read; | |
215 | ||
216 | userdom_use_sysadm_tty(ssh_keygen_t) | |
217 | userdom_dontaudit_use_unpriv_user_fd(ssh_keygen_t) | |
218 | ||
219 | # cjp: with the old daemon_(base_)domain being broken up into | |
220 | # a daemon and system interface, this probably is not needed: | |
221 | ifdef(`direct_sysadm_daemon',` | |
222 | userdom_dontaudit_use_sysadm_terms(ssh_keygen_t) | |
223 | ') | |
224 | ||
225 | ifdef(`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 | ||
231 | optional_policy(`selinuxutil.te',` | |
232 | seutil_sigchld_newrole(ssh_keygen_t) | |
233 | ') | |
234 | ||
235 | optional_policy(`udev.te', ` | |
236 | udev_read_db(ssh_keygen_t) | |
237 | ') | |
238 | ||
239 | ifdef(`TODO',` | |
240 | optional_policy(`rhgb.te', ` | |
241 | rhgb_domain(ssh_keygen_t) | |
242 | ') | |
243 | ') |