如何在开源鸿蒙OpenHarmony开启SELinux模式?RK3566鸿蒙开发板演示

本文介绍在开源鸿蒙OpenHarmony系统下,开启/关闭SELinux权限的方法,触觉智能Purple Pi OH鸿蒙开发板演示,搭载了瑞芯微RK3566芯片,类树莓派设计,Laval官方社区主荐,已适配全新OpenHarmony5.0 Release系统!

SELinux权限状态

SELinux一共有3种状态,分别是Enforcing,Permissive和Disabled状态。

Enforcing:强制模式,违反SELinux规则的行为将被阻止并记录到日志中。

Permissive:宽容模式,违反SELinux规则的行为只会记录到日志中,一般为调试用。

Disabled:关闭SELinux权限状态。

查看SELinux权限命令如下:

C:\Users\industio>hdc shell //查看SELinux权限状态 # getenforce //此状态下SELinux权限为开启状态 Enforcing

临时修改SElinux权限临时关闭SELinux权限命令如下:

//临时关闭SElinux权限 # setenforce 0 # getenforce Permissive

注意:这样SELinux权限就会被临时关闭,但是系统重启此方法就会失效,以下展示永久修改SELinux权限的方法。

永久打开与关闭SELinux权限

方法一

在OpenHarmony系统中SELinux的config配置文件的路径

system/etc/selinux/config,如下图所示:

通过hdc命令将文件拖到本地中,命令如下:

C:\Users\industio>hdc shell mount -o remount,rw / C:\Users\industio>hdc file recv system/etc/selinux/config "本地路径"

在本地对config文件中对SELinux权限状态进行修改后,将文件推送回系统

C:\Users\industio>hdc file send "本地路径" system/etc/selinux/ FileTransfer finish, Size:624 File count = 1, time:30ms rate:20.80KB/s

注意:这样SELinux权限就会被永久的修改,重启后SELinux权限也不会因重启而改变权限状态,但是重新烧录固件此次方法依旧失效。

方法二

在SDK中修改SELinux权限路径:

/base/security/selinux_adapter/selinux.gni ,如下图所示:

命令如下:

declare_args() { //权限根据自己所需进行修改,当前为开启状态.关闭将true改为false即可 selinux_enforce = true }

修改后保存退出,将SDK全部重新编译即可。

相关推荐
坚果派·白晓明2 天前
面向新手的鸿蒙跨平台开发技术选型指南
开源鸿蒙·鸿蒙跨平台应用开发·鸿蒙跨平台应用
坚果派·白晓明2 天前
Windows 11 OpenHarmony版React Native开发环境搭建完整指南
react native·开源鸿蒙·rnoh
fakerth3 天前
【OpenHarmony】升级服务组件(UpdateService)
操作系统·openharmony
fakerth3 天前
【OpenHarmony】Updater 升级包安装组件
操作系统·openharmony
鸿蒙小白龙5 天前
OpenHarmony轻量系统智能模块开发实战指南
arm开发·openharmony·liteos
鸿蒙小白龙5 天前
OpenHarmony轻量系统(Hi3861)RTOS API开发详解
openharmony·rtos·liteos·轻量系统
夏小鱼的blog14 天前
【HarmonyOS应用开发入门】第四期:ArkTS语言基础(二)
harmonyos·openharmony
黑臂麒麟14 天前
Electron for OpenHarmony 跨平台实战开发(二):文件树组件实现与优化
electron·openharmony
爱艺江河14 天前
[鸿蒙2025领航者闯关]基于MetaStudio的数字人与鸿蒙PC本地智能体融合:金融法务合规业务的技术实现与场景创新
金融·openharmony·鸿蒙2025领航者闯关
fakerth14 天前
【OpenHarmony】Hiview架构
架构·操作系统·openharmony