add feature switch

Signed-off-by: renwei <renwei8@huawei.com>
Change-Id: I4b9ce02a6f2ca2948f8d4e45283c187d02279cd1
This commit is contained in:
renwei 2022-10-12 11:42:05 +08:00
parent 2f03727c3f
commit 7438649669
4 changed files with 30 additions and 7 deletions

View File

@ -428,9 +428,13 @@ action("build_contexts") {
]
}
action("enforce_selinux") {
script = "scripts/enforce_selinux.sh"
outputs = [ "$target_out_dir/" ]
copy("selinux_config") {
if (selinux_enforce) {
sources = [ "$SELINUX_ROOT_DIR/config/config.enforce" ]
} else {
sources = [ "$SELINUX_ROOT_DIR/config/config.permissive" ]
}
outputs = [ "$target_out_dir/config" ]
}
ohos_prebuilt_etc("build_sepolicy") {
@ -450,12 +454,10 @@ ohos_prebuilt_etc("file_contexts_bin") {
}
ohos_prebuilt_etc("config") {
source = "$SELINUX_ROOT_DIR/config/config"
deps = [ ":selinux_config" ]
source = target_out_dir + "/config"
license_file = "$SELINUX_ROOT_DIR/LICENSE"
part_name = "selinux"
if (enforce_selinux) {
deps = [ ":enforce_selinux" ]
}
relative_install_dir = "selinux/"
}

17
config/config.permissive Normal file
View File

@ -0,0 +1,17 @@
#
# Copyright (c) 2021 北京万里红科技有限公司
#
# 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.
#
SELINUX=permissive

View File

@ -14,3 +14,7 @@
declare_args() {
selinux_build_path = "default"
}
declare_args() {
selinux_enforce = true
}