[Android]用make_ext4fs 生成帶SELinux 標籤的image

Android 5.0升級後,SELinux模式已經升級爲Enforcing, 並且是everything Enforcing, 不像Android 4.4時只是幾個主要process爲Enforcing,其餘仍是permissive.android

直接舉例: 好比要生成一個10MB大小的EXT4 格式helloworld.img 對裏面的內容打上u:object_r:hello_world_t:s0的 label 首先在out 目錄下建立helloworld 文件夾 make_ext4fs -l 10485760 -S out/root/file_contexts -a helloworld out/helloworld.img out/helloworld
參數-S 用來指定file_contexts文件路徑,它會指定打什麼標籤,重要 -a 參數用來指定文件系統在android裏的掛載點,能夠使用默認的owner group等,在android_filesystem_config.h裏指定 此路徑會在-S指定的file_contexts裏用到,因此-a 必須是helloworldapp

file_contexts:
/helloworld(/.*)? u:object_r:hello_world_t:s0ci

接下來天然要加label 許可。 首先弄清楚訪問/helloworld的app是何種app, 好比system app, 那麼要在system_app.te 來增長對應的許可。 固然前提是已經增長hello_world_t 的定義。object

相關文章
相關標籤/搜索