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

相关推荐
特立独行的猫a1 天前
HarmonyOS鸿蒙PC的QT应用开发:QT项目运行原理与 EmbeddedUIExtensionAbility介绍
qt·华为·harmonyos·openharmony·鸿蒙pc
2501_921930832 天前
Flutter for OpenHarmony三方库适配实战:file_selector文件选择详解
flutter·openharmony
2501_921930832 天前
Flutter for OpenHarmony三方库适配实战:url_launcher URL启动器
flutter·openharmony
里欧跑得慢5 天前
Flutter 组件 powersync_core 的适配 鸿蒙Harmony 实战 - 驾驭极致离线优先架构、实现鸿蒙端高性能 SQL 增量同步与数据安全治理方案
flutter·harmonyos·鸿蒙·openharmony·powersync_core
王码码20355 天前
Flutter 三方库 preact_signals 的鸿蒙化适配指南 - 掌控极致信号响应、Signals 架构实战、鸿蒙级精密状态指控专家
flutter·harmonyos·鸿蒙·openharmony·preact_signals
左手厨刀右手茼蒿6 天前
Flutter 三方库 bs58 的鸿蒙化适配指南 - 在鸿蒙系统上构建极致、高效的 Base58 数字货币与区块链数据编解码引擎
flutter·harmonyos·鸿蒙·openharmony
加农炮手Jinx6 天前
Flutter 组件 substrate_bip39 的适配 鸿蒙Harmony 实战 - 驾驭区块链级助记词原语、实现鸿蒙端金融级 BIP39 安全私钥推导方案
flutter·harmonyos·鸿蒙·openharmony·substrate_bip39
左手厨刀右手茼蒿6 天前
Flutter 组件 substrate_bip39 的适配 鸿蒙Harmony 实战 - 驾驭区块链级 BIP39 安全底座、实现鸿蒙端私钥派生与国密级密钥保护方案
flutter·harmonyos·鸿蒙·openharmony·substrate_bip39
加农炮手Jinx6 天前
Flutter 三方库 fast_base58 的鸿蒙化进阶指南 - 挑战编解码吞吐量极限、助力鸿蒙端大规模区块链与分布式存储数据处理
flutter·harmonyos·鸿蒙·openharmony·fast_base58
Industio_触觉智能6 天前
开源鸿蒙赋能水务智能化,IPC3528水务鸿蒙网关
鸿蒙系统·openharmony·rk3568·开源鸿蒙·工控机·鸿蒙水务·水务鸿蒙