導航:首頁 > 編程系統 > 安卓永久禁用selinux

安卓永久禁用selinux

發布時間:2024-04-09 19:19:17

⑴ 小米關閉selinux好處

作用:最大限度地減小系統中服務進程可訪問的資源(最小許可權原則)。

工作模式 :

enforcing:強制模式。違反 SELinux 規則的行為將被阻止並記錄到日誌中。

permissive:寬容模式。違反 SELinux 規則的行為只會記錄到日誌中。一般為調試用。

disabled:關閉 SELinux

關閉方法 :

  1. 臨時關閉:關機重啟都會失效

2.永久關閉:關機重啟都會有效(檢查selinux系統是否被成功關閉)

⑵ 關閉selinux功能 不小心Ctrl+Z怎麼辦

再重新關閉一次就可以了。
永久關閉selinux的辦法:指令:vim /etc/selinux/config,然後找到SELINUX=enforcing,改為disabled。ctrl+z是撤銷快捷鍵,而ctrl+z的反快捷鍵是Ctrl+Y;CTRL+Y快捷鍵的作用就是用來恢復上一步的操作,與CTRL+Z快捷鍵的作用剛好相反。比較常見的就是我們在打字輸入錯誤的時候,但是在刪除的時候手按太快了,把正確的文字也刪除了,那麼只需要按 CTRL+Z 就能恢復上一步誤刪的文字。如果 CTRL+Z 按多了一次,那麼我可以再次刪除或者直接按 CTRL+Y 來恢復。

⑶ 用sed修改伺服器的selinux為disabled狀態

1、首先,使用setenforce命令進行設置,在selinux狀態的時候出現這個提示:setenforce: SELinux is disabled,然後讓selinux徹底的關閉。

安卓代碼能不能實現關閉SElinux許可權

不可以
1.3 方法1:adb在線修改

關閉 seLinux:

打開:

Enforcing:seLinux已經打開;
Permissive:seLinux已經關閉;

1.4 方法2: 從kernel中徹底關閉 (用於開機初始化時的seLinux許可權問題,要重編bootimage)

修改LINUX/android/kernel/arch/arm64/configs/XXXdefconfig文件(找相應config文件)
去掉CONFIG_SECURITY_SELINUX=y 的配置項

2. 在sepolicy中添加相應許可權

2.1 修改依據:
log 信息:
avc: denied { 操作許可權 } for pid=7201 comm=「進程名」 scontext=u:r:源類型:s0 tcontext=u:r:目標類型:s0 tclass=訪問類別 permissive=0

2.2 修改步驟:
找相應的「源類型.te 」文件

有兩個位置可能存在相應的te文件:

位置一:LINUX/android/external/sepolicy
位置二:LINUX/android/device/qcom/sepolicy/common

2.3 按如下格式在該文件中添加:

allow 源類型 目標類型:訪問類別 {許可權};

2.4 舉例
Kernel Log:
avc: denied { execheap } for pid=7201 comm="com..input" scontext=u:r:untrusted_app:s0tcontext=u:r:untrusted_app:s0tclass=processpermissive=0

修改:
在LINUX/android/external/sepolicy/untrusted_app.te 中添加:

[java] view plain
<span style="font-size:24px;color:#009900;">allow untrusted_app untrusted_app:process { execheap };</span>

備注:
在這個例子中,由於源類型和目標類型都是untreated_app, 所以也可以寫成:

[java] view plain
<span style="font-size:24px;color:#009900;">allow untrusted_app self:process { execheap };</span>

3. 添加許可權後的neverallowed沖突

3.1 編譯報錯:
libsepol.check_assertion_helper: neverallow on line xxx ofexternal/sepolicy/domain.te ……

3.2 原因:
新添加的sepolicy項目違反了domain.te 中規定的的總策略原則。所以該條許可權策略不能添加,如果強行添加的話有CTS測試失敗的風險。

3.3 解決方法:
1.從運行log中找到要訪問的目標名稱,一般是name欄位後的名稱
avc: denied { read write } for pid=303 comm="mediaserver"name="tfa9890"dev="tmpfs" ino=3880 scontext=u:r:mediaserver:s0tcontext=u:object_r:device:s0tclass=chr_file permissive=0

2.找到相應的*_contexts文件。

一般有file_contexts, genfs_contexts, property_contexts, service_contexts 等文件

3.在contexts文件中指定要訪問的目標為一個「源類型 」有許可權訪問的「目標類型」
如:在file_contexts中添加: /dev/tfa9890 u:object_r:audio_device:s0

3.4 舉例
添加許可權:
在mediaserver.te中添加allow mediaserver device:chr_file { read write open};

編譯報錯:
libsepol.check_assertion_helper: neverallow on line 258 ofexternal/sepolicy/domain.te (or line 5252 of policy.conf) violated byallow mediaserver device:chr_file { read write open};

違反了domain.te 258的:
neverallow {domain –unconfineddomain –ueventd } device:chr_file { open read write}

運行Log:
avc: denied { read write } for pid=303 comm="mediaserver"name="tfa9890" dev="tmpfs" ino=3880 scontext=u:r:mediaserver:s0 tcontext=u:object_r:device:s0tclass=chr_file permissive=0

修改步驟:

1.目標名稱是: tfa9890, 其在系統中的路徑是: /dev/tfa9890, 是audio相關的設備文件
2.源類型是mediaserver, 在mediaserver.te 文件中發現其具有 audio_device 目標類型的許可權
3.所以在file_contexts 中添加 「/dev/tfa9890 u:object_r:audio_device:s0」 可以解決問題

⑸ 安卓關閉selinux好處

你好朋友
1. 禁止selinux

1.1 在內核中關閉selinux編譯選項CONFIG_SECURITY_SELINUX
1.2 還可以在system.prop中定義ro.boot.selinux=disable
這兩種方法都可以禁用selinux,也可以設置成ro.boot.selinux=permissive
寬容模式
1.3 可以通過setenforce1開啟enforce模式,setenforce 0為permissive模式
getenforce獲取當前模式

2. 所有安全策略最終編譯成sepolicy文件放在root目錄下,init進程啟動後會讀取/sepolicy策略文件,並通過/sys/fs/selinux/load節點
把策略文件內容寫入內核

3 安全上下文存放root目錄
/etc/security/mac_permissions.xml
/file_contexts //系統中所有file_contexts安全上下文
/seapp_contexts //app安全上下文
/property_contexts //屬性的安全上下文
/service_contexts //service文件安全上下文

genfs_contexts //虛擬文件系統安全上下文

4. app在/data/data/文件的安全上下文設置過程
1. 根據uid,pkgname,seinfo在seapp_contexts中匹配.
2. 根據匹配到的contexts,重新設置給相對應文件

5. 系統中所有的object class 定義在external/sepolicy/security_classes中.
object class使用在allow語句中,object class所具有的操作定義在external/sepolicy/access_vectors
文件中

6 allow語句
allow語句用來許可權設置
rule_name source_type target_type : class perm_set

rule_name : 有allow,neverallow
source_type : 許可權主體,表示source_type對target_type有perm_set描述的許可權
如:
allow zygote init:process sigchld
允許zygote域裡面的進程可對init域的進程發送sigchld信號

typeattribute表示把屬性和type關聯起來

7 role定義
Android系統中的role定義在external/sepolicy/roles中,
目前只定義了r

8 socket使用
以/data/misc/wifi/sockets/wlan0 socket來說明使用方法
1. 定義socket type
type wpa_socket ,file_type
2. 指定安全上下文
/data/misc/wifi/sockets(/.*)? u:object_r:wpa_socket:s0
給/data/misc/wifi/sockets目錄下所有的文件統一指定安全上下文為wpa_socket
3.聲明socket使用許可權
在進程te中使用unix_socket_send(clientdomain, wpa, serverdomain)即可建立socket連接

9binder使用
在使用binder進程的te中根據情況使用如下宏:
binder_use(domain)//允許domain域中的進程使用binder通信
binder_call(clientdomain, serverdomain)//允許clientdomain和serverdomain域中的進程通信
binder_service(domain)//標志domain為service端

10 文件的使用
以/dev/wmtWifi來說明:
1.定義type
type wmtWifi_device dev_type //dev_type用來標志/dev/下的文件
2.給/dev/wmtWifi指定完全上下文
/dev/wmtWifi(/.*)? u:object_r:wmtWifi_device:s0

3.進程許可權設置
在進程te文件中allow許可權
allow netd wmtWifi_device:chr_file { write open };

11 property 屬性設置
以藍牙的各種屬性來說明
1.定義type
type bluetooth_prop, property_type;
2設置安全上下文
bluetooth. u:object_r:bluetooth_prop:s0
3進程許可權設置
allow bluetooth bluetooth_prop:property_service set;

5 專業詞彙
MLS :Multi-Level Security
RBAC :Role Based Access Control
DAC :Discretionary Access Control
MAC :Mandatory Access Control
TEAC :Type Enforcement Accesc Control
望採納祝你好運

閱讀全文

與安卓永久禁用selinux相關的資料

熱點內容
win10如何修改hosts文件 瀏覽:971
iphone的未接來電 瀏覽:134
如何新建一個文件夾word文檔 瀏覽:74
零售商運用了什麼樣的大數據 瀏覽:557
榮耀分身微信清理es文件瀏覽器 瀏覽:682
linux賬戶設置密碼 瀏覽:69
查看資料庫各表記錄數 瀏覽:968
linux查看文件的行數 瀏覽:692
fpga約束文件如何自動生成 瀏覽:377
linux打開的文件數 瀏覽:973
win8修改公用網路 瀏覽:324
linuxlcrt 瀏覽:30
編程里res是什麼意思 瀏覽:616
dm80082版本固件 瀏覽:37
蘋果手機用什麼可以打開psd文件 瀏覽:627
服務號和小程序的區別 瀏覽:888
360手機助手qq文件位置 瀏覽:693
如何學習數碼編程 瀏覽:60
微信消息發布出去 瀏覽:377
windows文件名一個個消失 瀏覽:907

友情鏈接