我像这样使用SELinux:
SELinux.restoreconRecursive(new File("/data/data/com.my.app"));
我失败了:
07-27 19:21:11.890 W/SELinux ( 5182): SELinux: Could not look up information for package com.my.app, cannot restorecon .
07-27 19:21:11.890 E/SELinux ( 5182): SELinux: Could not set context for /data/data/com.my.app: Socket operation on non-socket
07-27 19:21:11.890 E/SELinux ( 5182): SELinux: Could not read /data/data/com.my.app: Permission denied.
在此操作之前,文件如下所示:
drwxrwx--x u0_a126 u0_a126 u:object_r:app_data_file:s0 cache
我使用adb恢复默认值,它应该是:
drwxrwx--x u0_a126 u0_a126 u:object_r:app_data_file:s0:c512,c768 cache
这就是为什么在我的代码中使用restorecon。 PLZ帮我解决了这个例外。
答案 0 :(得分:0)
我已经解决了这个问题。 因为另一个SELinux权限:
allow backuprestore selinuxfs:file { write };
allow backuprestore kernel:security { check_context };
allow backuprestore app_data_file:dir { relabelfrom relabelto};
allow backuprestore app_data_file:file { relabelfrom relabelto};