如何在开源鸿蒙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 天前
Flutter 三方库 all_lint_rules_community 的鸿蒙化适配指南 - 在鸿蒙系统上构建极致、严谨、基于全量社区 Lint 规则的工业级静态代码质量与安全审计引擎
flutter·harmonyos·鸿蒙·openharmony·all_lint_rules_community
王码码20352 天前
Flutter 三方库 servicestack 的鸿蒙化适配指南 - 实现企业级 Message-based 架构集成、支持强类型 JSON 序列化与跨端服务调用同步
flutter·harmonyos·鸿蒙·openharmony·message-based
里欧跑得慢2 天前
Flutter 三方库 jsonata_dart 的鸿蒙化适配指南 - 实现高性能的 JSON 数据查询与转换、支持 JSONata 表达式引擎与端侧复杂数据清洗
flutter·harmonyos·鸿蒙·openharmony·jsonata_dart
国医中兴2 天前
Flutter 三方库 superclass 的鸿蒙化适配指南 - 支持原生高性能类构造、属性代理与深层元数据解析实战
flutter·harmonyos·鸿蒙·openharmony
加农炮手Jinx2 天前
Flutter 组件 ubuntu_service 适配鸿蒙 HarmonyOS 实战:底层系统服务治理,构建鸿蒙 Linux 子系统与守护进程交互架构
flutter·harmonyos·鸿蒙·openharmony·ubuntu_service
王码码20352 天前
Flutter 三方库 login_client 的鸿蒙化适配指南 - 打造工业级安全登录、OAuth2 自动化鉴权、鸿蒙级身份守门员
flutter·harmonyos·鸿蒙·openharmony·login_client
国医中兴3 天前
Flutter 三方库 dson 的鸿蒙化适配指南 - 极简的序列化魔法、在鸿蒙端实现反射式 JSON 映射实战
flutter·harmonyos·鸿蒙·openharmony
国医中兴3 天前
Flutter 三方库 cloudflare_r2_uploader 的鸿蒙化适配指南 - 云端存储的疾速通道、在鸿蒙端实现 R2 分段上传实战
flutter·harmonyos·鸿蒙·openharmony·cloudflare_r2_uploader
国医中兴3 天前
Flutter 三方库 weaver 的鸿蒙化适配指南 - 玩转轻量级服务发现、在鸿蒙端实现模块化治理与解构实战
flutter·harmonyos·鸿蒙·openharmony
国医中兴3 天前
Flutter 三方库 tapper 的鸿蒙化适配指南 - 单元测试的“闪电侠”、在鸿蒙端实现极简函数式测试实战
flutter·harmonyos·鸿蒙·openharmony