如何在开源鸿蒙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全部重新编译即可。

相关推荐
Industio_触觉智能2 天前
【开源鸿蒙-AVCodec Kit】音视频编解码封装解封装部件介绍,转自开源鸿蒙官媒OpenAtom OpenHarmony
harmonyos·视频编解码·openharmony·开源鸿蒙
ShiMetaPi9 天前
基于M4-R1开发板的OpenHarmony开发实战丨创建第一个应用工程
嵌入式硬件·开放原子·鸿蒙系统·openharmony·开源鸿蒙·北向开发
fakerth17 天前
【OpenHarmony】sensors_miscdevice小器件模块架构
架构·操作系统·openharmony
fakerth19 天前
【OpenHarmony】医疗传感器模块架构
架构·操作系统·openharmony
fakerth20 天前
【OpenHarmony】AI引擎模块架构
人工智能·架构·openharmony
fakerth20 天前
【OpenHarmony】文件访问接口模块架构
架构·操作系统·openharmony
Industio_触觉智能20 天前
RK3576开发板/核心板应用分享之开源鸿蒙
鸿蒙·openharmony·嵌入式开发·开源鸿蒙·鸿蒙开发板·鸿蒙南向·xts
fakerth20 天前
【OpenHarmony】存储管理服务模块架构
架构·操作系统·openharmony
盆鱼宴之武冈分宴20 天前
flutter openharmony项目新手从0到1的保姆级教程
flutter·openharmony
Industio_触觉智能21 天前
开源鸿蒙6.1和8.1版本被确定为LTS建议版本,最新路标正式发布!-转自开源鸿蒙OpenHarmony社区
harmonyos·openharmony·开源鸿蒙