-
Notifications
You must be signed in to change notification settings - Fork 1
/
ohos_policy-add-selinux-policy.patch
251 lines (246 loc) · 11.8 KB
/
ohos_policy-add-selinux-policy.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
From 521c6a63387b24a3d79184f49e112ea58cb94939 Mon Sep 17 00:00:00 2001
From: Francesco Pham <[email protected]>
Date: Mon, 4 Mar 2024 14:12:04 +0100
Subject: [PATCH] ohos_policy: Add selinux policy for kanto and mosquitto
services
some selinux policy are needed for kanto and mosquitto services to properly run.
Related issue: https://gitlab.eclipse.org/eclipse/oniro-core/ohos-planning/-/issues/41
Related issue: https://gitlab.eclipse.org/eclipse/oniro-core/ohos-planning/-/issues/47
Signed-off-by: Francesco Pham <[email protected]>
---
sepolicy/ohos_policy/kanto/public/kanto.te | 21 +++++++++++
.../ohos_policy/kanto/system/file_contexts | 17 +++++++++
sepolicy/ohos_policy/kanto/system/init.te | 16 +++++++++
sepolicy/ohos_policy/kanto/system/kanto.te | 25 +++++++++++++
.../ohos_policy/mosquitto/public/mosquitto.te | 21 +++++++++++
.../mosquitto/system/file_contexts | 17 +++++++++
sepolicy/ohos_policy/mosquitto/system/init.te | 16 +++++++++
.../ohos_policy/mosquitto/system/mosquitto.te | 36 +++++++++++++++++++
8 files changed, 169 insertions(+)
create mode 100644 sepolicy/ohos_policy/kanto/public/kanto.te
create mode 100644 sepolicy/ohos_policy/kanto/system/file_contexts
create mode 100644 sepolicy/ohos_policy/kanto/system/init.te
create mode 100644 sepolicy/ohos_policy/kanto/system/kanto.te
create mode 100644 sepolicy/ohos_policy/mosquitto/public/mosquitto.te
create mode 100644 sepolicy/ohos_policy/mosquitto/system/file_contexts
create mode 100644 sepolicy/ohos_policy/mosquitto/system/init.te
create mode 100644 sepolicy/ohos_policy/mosquitto/system/mosquitto.te
diff --git a/sepolicy/ohos_policy/kanto/public/kanto.te b/sepolicy/ohos_policy/kanto/public/kanto.te
new file mode 100644
index 00000000..25944902
--- /dev/null
+++ b/sepolicy/ohos_policy/kanto/public/kanto.te
@@ -0,0 +1,21 @@
+# Copyright (c) 2024 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+##################
+## Type define: ##
+##################
+type kanto, sadomain, domain;
+
+type kanto_exec, exec_attr, file_attr, system_file_attr;
+type data_kanto_file, file_attr, data_file_attr;
+init_daemon_domain(kanto);
diff --git a/sepolicy/ohos_policy/kanto/system/file_contexts b/sepolicy/ohos_policy/kanto/system/file_contexts
new file mode 100644
index 00000000..e58a652b
--- /dev/null
+++ b/sepolicy/ohos_policy/kanto/system/file_contexts
@@ -0,0 +1,17 @@
+# Copyright (c) 2024 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+/system/bin/suite-connector u:object_r:kanto_exec:s0
+
+/data/log/kanto(/.*)? u:object_r:data_kanto_file:s0
+
diff --git a/sepolicy/ohos_policy/kanto/system/init.te b/sepolicy/ohos_policy/kanto/system/init.te
new file mode 100644
index 00000000..7bb06a8e
--- /dev/null
+++ b/sepolicy/ohos_policy/kanto/system/init.te
@@ -0,0 +1,16 @@
+# Copyright (c) 2024 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+allow init kanto:file { getattr open read relabelto setattr };
+allow init kanto:dir { getattr open read relabelto setattr search };
+allow init kanto:process { getattr rlimitinh siginh transition };
diff --git a/sepolicy/ohos_policy/kanto/system/kanto.te b/sepolicy/ohos_policy/kanto/system/kanto.te
new file mode 100644
index 00000000..5a247eda
--- /dev/null
+++ b/sepolicy/ohos_policy/kanto/system/kanto.te
@@ -0,0 +1,25 @@
+# Copyright (c) 2024 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+allow kanto dev_console_file:chr_file { read write };
+allow kanto debug_param:file { map open read };
+allow kanto kanto:tcp_socket { create setopt bind listen connect getopt getattr write read };
+allow kanto port:tcp_socket { name_bind name_connect };
+allow kanto node:tcp_socket { node_bind };
+allow kanto kanto:udp_socket { create setopt connect getattr write read };
+allow kanto hilog_param:file { map open read };
+allow kanto dev_unix_socket:dir { search };
+allow kanto data_file:dir { search };
+allow kanto data_log:file { read write create append open ioctl getattr };
+allow kanto data_log:dir { write add_name };
+allow kanto system_etc_file:dir { watch };
diff --git a/sepolicy/ohos_policy/mosquitto/public/mosquitto.te b/sepolicy/ohos_policy/mosquitto/public/mosquitto.te
new file mode 100644
index 00000000..23484355
--- /dev/null
+++ b/sepolicy/ohos_policy/mosquitto/public/mosquitto.te
@@ -0,0 +1,21 @@
+# Copyright (c) 2024 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+##################
+## Type define: ##
+##################
+type mosquitto, sadomain, domain;
+
+type mosquitto_exec, exec_attr, file_attr, system_file_attr;
+type data_mosquitto_file, file_attr, data_file_attr;
+init_daemon_domain(mosquitto);
diff --git a/sepolicy/ohos_policy/mosquitto/system/file_contexts b/sepolicy/ohos_policy/mosquitto/system/file_contexts
new file mode 100644
index 00000000..a84ec086
--- /dev/null
+++ b/sepolicy/ohos_policy/mosquitto/system/file_contexts
@@ -0,0 +1,17 @@
+# Copyright (c) 2024 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+/system/bin/mosquitto u:object_r:mosquitto_exec:s0
+
+/data/log/mosquitto(/.*)? u:object_r:data_mosquitto_file:s0
+
diff --git a/sepolicy/ohos_policy/mosquitto/system/init.te b/sepolicy/ohos_policy/mosquitto/system/init.te
new file mode 100644
index 00000000..e6940ad8
--- /dev/null
+++ b/sepolicy/ohos_policy/mosquitto/system/init.te
@@ -0,0 +1,16 @@
+# Copyright (c) 2024 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+allow init mosquitto:file { getattr open read relabelto setattr };
+allow init mosquitto:dir { getattr open read relabelto setattr search };
+allow init mosquitto:process { getattr rlimitinh siginh transition };
diff --git a/sepolicy/ohos_policy/mosquitto/system/mosquitto.te b/sepolicy/ohos_policy/mosquitto/system/mosquitto.te
new file mode 100644
index 00000000..9dd84f49
--- /dev/null
+++ b/sepolicy/ohos_policy/mosquitto/system/mosquitto.te
@@ -0,0 +1,36 @@
+# Copyright (c) 2024 Huawei Device Co., Ltd.
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# avc: denied { read write } for pid=1690 comm="mosquitto" path="/dev/console" dev="tmpfs" ino=40 scontext=u:r:mosquitto:s0 tcontext=u:object_r:dev_console_file:s0 tclass=chr_file permissive=0
+allow mosquitto dev_console_file:chr_file { read write };
+
+# avc: denied { read } for pid=1690 comm="mosquitto" name="u:object_r:debug_param:s0" dev="tmpfs" ino=73 scontext=u:r:mosquitto:s0 tcontext=u:object_r:debug_param:s0 tclass=file permissive=0
+allow mosquitto debug_param:file { map open read };
+
+# avc: denied { create } for pid=1648 comm="mosquitto" scontext=u:r:mosquitto:s0 tcontext=u:r:mosquitto:s0 tclass=tcp_socket permissive=0
+allow mosquitto mosquitto:tcp_socket { create setopt bind listen accept getattr read write };
+allow mosquitto port:tcp_socket { name_bind };
+allow mosquitto node:tcp_socket { node_bind };
+
+# avc: denied { read } for pid=1648 comm="mosquitto" name="u:object_r:hilog_param:s0" dev="tmpfs" ino=69 scontext=u:r:mosquitto:s0 tcontext=u:object_r:hilog_param:s0 tclass=file permissive=0
+allow mosquitto hilog_param:file { map open read };
+
+# avc: denied { search } for pid=1648 comm="mosquitto" name="socket" dev="tmpfs" ino=43 scontext=u:r:mosquitto:s0 tcontext=u:object_r:dev_unix_socket:s0 tclass=dir permissive=0
+allow mosquitto dev_unix_socket:dir { search };
+
+# avc: denied { search } for pid=1621 comm="mosquitto" name="/" dev="mmcblk0p14" ino=3 scontext=u:r:mosquitto:s0 tcontext=u:object_r:data_file:s0 tclass=dir permissive=0
+allow mosquitto data_file:dir { search };
+
+# avc: denied { write } for pid=1714 comm="mosquitto" name="mosquitto" dev="mmcblk0p14" ino=23 scontext=u:r:mosquitto:s0 tcontext=u:object_r:data_log:s0 tclass=dir permissive=0
+allow mosquitto data_log:file { read write create append open ioctl getattr };
+allow mosquitto data_log:dir { write add_name };
--
2.25.1