| 1 |
# This file is part of kiwi |
| 2 |
# Copyright (C) 2026 Neal Gompa |
| 3 |
# |
| 4 |
# This program is free software; you can redistribute it and/or modify |
| 5 |
# it under the terms of the GNU General Public License as published by |
| 6 |
# the Free Software Foundation; either version 3 of the License, or |
| 7 |
# (at your option) any later version. |
| 8 |
# |
| 9 |
# This program is distributed in the hope that it will be useful, |
| 10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
# GNU Library General Public License for more details. |
| 13 |
# |
| 14 |
# You should have received a copy of the GNU General Public License |
| 15 |
# along with this. If not, see <https://www.gnu.org/licenses/>. |
| 16 |
|
| 17 |
|
| 18 |
## <summary>policy for kiwi</summary> |
| 19 |
|
| 20 |
######################################## |
| 21 |
## <summary> |
| 22 |
## Execute kiwi_exec_t in the kiwi domain. |
| 23 |
## </summary> |
| 24 |
## <param name="domain"> |
| 25 |
## <summary> |
| 26 |
## Domain allowed to transition. |
| 27 |
## </summary> |
| 28 |
## </param> |
| 29 |
# |
| 30 |
interface(`kiwi_domtrans',` |
| 31 |
gen_require(` |
| 32 |
type kiwi_t, kiwi_exec_t; |
| 33 |
') |
| 34 |
|
| 35 |
corecmd_search_bin($1) |
| 36 |
domtrans_pattern($1, kiwi_exec_t, kiwi_t) |
| 37 |
') |
| 38 |
|
| 39 |
###################################### |
| 40 |
## <summary> |
| 41 |
## Execute kiwi in the caller domain. |
| 42 |
## </summary> |
| 43 |
## <param name="domain"> |
| 44 |
## <summary> |
| 45 |
## Domain allowed access. |
| 46 |
## </summary> |
| 47 |
## </param> |
| 48 |
# |
| 49 |
interface(`kiwi_exec',` |
| 50 |
gen_require(` |
| 51 |
type kiwi_exec_t; |
| 52 |
') |
| 53 |
|
| 54 |
corecmd_search_bin($1) |
| 55 |
can_exec($1, kiwi_exec_t) |
| 56 |
') |
| 57 |
|
| 58 |
######################################## |
| 59 |
## <summary> |
| 60 |
## Execute kiwi in the kiwi domain, and |
| 61 |
## allow the specified role the kiwi domain. |
| 62 |
## </summary> |
| 63 |
## <param name="domain"> |
| 64 |
## <summary> |
| 65 |
## Domain allowed to transition |
| 66 |
## </summary> |
| 67 |
## </param> |
| 68 |
## <param name="role"> |
| 69 |
## <summary> |
| 70 |
## The role to be allowed the kiwi domain. |
| 71 |
## </summary> |
| 72 |
## </param> |
| 73 |
# |
| 74 |
interface(`kiwi_run',` |
| 75 |
gen_require(` |
| 76 |
type kiwi_t; |
| 77 |
attribute_role kiwi_roles; |
| 78 |
') |
| 79 |
|
| 80 |
kiwi_domtrans($1) |
| 81 |
roleattribute $2 kiwi_roles; |
| 82 |
') |
| 83 |
|
| 84 |
######################################## |
| 85 |
## <summary> |
| 86 |
## Role access for kiwi |
| 87 |
## </summary> |
| 88 |
## <param name="role"> |
| 89 |
## <summary> |
| 90 |
## Role allowed access |
| 91 |
## </summary> |
| 92 |
## </param> |
| 93 |
## <param name="domain"> |
| 94 |
## <summary> |
| 95 |
## User domain for the role |
| 96 |
## </summary> |
| 97 |
## </param> |
| 98 |
# |
| 99 |
interface(`kiwi_role',` |
| 100 |
gen_require(` |
| 101 |
type kiwi_t; |
| 102 |
attribute_role kiwi_roles; |
| 103 |
') |
| 104 |
|
| 105 |
roleattribute $1 kiwi_roles; |
| 106 |
|
| 107 |
kiwi_domtrans($2) |
| 108 |
|
| 109 |
ps_process_pattern($2, kiwi_t) |
| 110 |
allow $2 kiwi_t:process { signull signal sigkill }; |
| 111 |
') |
| 112 |
|
| 113 |
######################################## |
| 114 |
## <summary> |
| 115 |
## kiwi nnp / nosuid transitions to domain |
| 116 |
## </summary> |
| 117 |
## <param name="domain"> |
| 118 |
## <summary> |
| 119 |
## Domain to be allowed to transition into. |
| 120 |
## </summary> |
| 121 |
## </param> |
| 122 |
# |
| 123 |
interface(`kiwi_nnp_nosuid_trans',` |
| 124 |
gen_require(` |
| 125 |
type kiwi_t; |
| 126 |
class process2 { nnp_transition nosuid_transition }; |
| 127 |
') |
| 128 |
|
| 129 |
allow kiwi_t $1:process2 {nnp_transition nosuid_transition}; |
| 130 |
') |