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

相关推荐
北京麟卓7 天前
卓奕引擎×OrangePi 5B开发板 | 面向开源鸿蒙的一站式安卓兼容验证方案
openharmony·安卓应用兼容
Industio_触觉智能9 天前
开源鸿蒙OpenHarmony再进阶,OneConnect规范即将升级为国家级行业标准
嵌入式硬件·物联网·硬件架构·智能硬件·openharmony·开源鸿蒙
北京麟卓10 天前
鸿蒙平板生态建设遇阻?卓奕引擎:安卓应用快速迁移+迁移成本直降80%以上
openharmony·安卓兼容
donoot13 天前
一次 Nginx 502 问题的深度排查:从 SELinux 到容器网络
nginx·docker·selinux·反向代理·502 bad gateway
STCNXPARM19 天前
Android selinux详解
android·selinux
阿pin19 天前
Android随笔-SELinux是什么?
android·selinux
Industio_触觉智能1 个月前
瑞芯微RK3576落地智能农业新生态,鸿蒙农机平板应用场景拓展
嵌入式硬件·openharmony·开源鸿蒙·核心板·鸿蒙开发板·rk3576·农机平板
fakerth1 个月前
【OpenHarmony】communication_ipc模块
操作系统·openharmony
阿钱真强道1 个月前
29 鸿蒙LiteOS RK2206 Socket编程实战 UDP通信+LWIP原理全解析
udp·socket·鸿蒙·liteos·开源鸿蒙·瑞芯微·rk2206
故渊at1 个月前
第六板块:Android 安全与权限体系 | 第十九篇:SELinux 强制访问控制与沙箱机制
android·安全·访问控制·selinux·权限体系·沙箱机制