android 9 SELiunx許可權新增

2021-10-05 20:00:43 字數 1364 閱讀 3563

seliunx的liunx系統的安全策略,具體內容這裡就不講解了,網上資料很多。

android系統專案開發中需要對裝置節點檔案讀寫操作,遇到如下錯誤

根據log可以看出源型別system_server,目標型別sysfs,訪問類別file,缺少許可權write,然後就在原始碼對應位置新增相應許可權。

android 9 的seliunx的原始碼目錄在system/sepolicy,根據源目錄system_server,在private/system_server.te檔案中新增

allow system_server sysfs:file
並且對應修改prebuilts/api/28.0/private/system_server.te,這兩個檔案要保持一致,不然編譯會報錯;這時候編譯原始碼會報錯誤:

libsepol.report_failure: neverallow on line 31 of system/sepolicy/domain.te (or line 9133 of policy.conf) violated by allow system_server sysfs:file ;

libsepol.check_assertions: 1 neverallow failures occurred

error while expanding policy

這是因為在「system/sepolicy/domain.te」 新增了一些neverallow rules,導致編譯檢查的時候出現錯誤,新新增的sepolicy專案違反了domain.te 中規定的的總策略原則。

只需要在下面的規則中,去掉我們新增的system_server.te即可,在neverallow後的想對應的『{}』裡 利用「-xx」,排除某個,即不應有此規則,根據我的報錯則在system/sepolicy/private/domain.te

在/sys/的{}新增「-system_server」,對應修改system/sepolicy/prebuilts/api/28.0/private/domain.te,保持兩個檔案一致。

這個錯誤和我出現的錯誤很類似,它新增的許可權多了乙個r_file_perms,然後把這個許可權加到system_server.te中,編譯燒寫,驗證可以正常讀取裝置節點檔案了。

編譯,驗證成功,新增write或者read的許可權要注意open的許可權,最後使用r_file_perms、w_file_perms、rw_file_perms。

android學習雜記 9

一些小用法 監聽 edittext 輸入字數的限制 medittitle.addtextchangedlistener newtextwatcher override public voidontextchanged charsequence s,intstart,intbefore,intcoun...

Android技術週報 W9

介紹了常用的6種開源協議 gpl,lgplbsd,apache,mozilla,mit 早在android 4.4,transition 就已經引入,但在5.0才得以真正的實現。本文詳細介紹了transition的使用.本文介紹了如何檢測應用在ui執行緒的卡頓 利用ui執行緒looper列印的日誌 ...

Android菜鳥日記9 Handler佇列

android菜鳥日記9 handler佇列 handler 1.作用 訊息佇列 執行緒佇列 2.重點 handler呼叫runnable實際是並不是開新執行緒 而是放入自己的執行緒中。如果要開啟執行緒 需要使用handlerthread獲得looper物件並繫結到handler物件上。3.使用 執...