SELinux 是Google從Android5.0開始,強制引入的一套非常嚴格的權限管理機制,主要用於增強系統的安全性。在開發中,我們經常會遇到由於SELinux造成的各種權限不足,例如下面:
avc: denied { mounton} for pid=2046 comm="mount" path="/factory" dev="mmcblk0p17" ino=1
scontext=u:r:uncrypt:s0
tcontext=u:object_r:vfat:s0tclass=dir permissive=0
由上面可知缺少mounton的權限,解決權限問題有下面的公式,
scontext tcontext:tclass avc:denied
allow uncrypt vfat:dir mounton
加入到以下文件裏面:
external/sepolicy/
這裏面有很多權限相關的操作,有時間可以去研究研究。