我正在将 AOSP 移植到自定义板,我需要/dev/ttymxc4
归u-blox
所有,以便 GPS 驱动程序可以使用它。 (没有其他任何东西需要使用它。
理想情况下,我希望在构建过程中指定这一点,而不是在运行时破解时指定。
在/dev
中管理设备节点所有权的最佳位置在哪里?
我假设当您说GPS驱动程序时,您实际上可能指的是需要与Linux内核驱动程序通信的用户空间守护程序?
传统的 Linux DAC 权限通常在 Android 启动时由 init 进程建立,通常在 AOSP 相应设备目录中的init.common.rc
等文件中建立。这也是定义守护程序(又名 init 服务)的地方。通常,您会为守护程序重用system
组,然后将设备文件chown
到使用标准 perms (如0660
或0440
)进行system
。
请记住,SELinux MAC 权限也必须在所有最新版本的 Android 中建立。建立 SELinux 权限相当复杂,但通常在设置需要与内核驱动程序通信的新守护程序时必须执行以下操作:
- 更新
file_contexts
以将标签分配给内核驱动程序创建的文件 - 添加新的 TE 文件,该文件:为守护程序建立新域,定义 init 过程中的域转换,包括新域访问必要标签的规则
看:
https://source.android.com/security/selinux/customize https://source.android.com/security/selinux/implement https://source.android.com/security/selinux/images/SELinux_Treble.pdf
例子:
https://android.googlesource.com/device/google/marlin/+/oreo-mr1-release/init.common.rc https://android.googlesource.com/device/google/marlin/+/oreo-mr1-release/sepolicy/init_radio.te
最好的方法是使用 ueventd 文件。这里: https://github.com/android/platform_system_core/blob/master/rootdir/ueventd.rc 或者您的董事会特定 uevent..RC(应位于设备树中)