kernel目录下的security/tomoyo内容copy来
#
Define
kernel
config
for
inline
building
#
rsync ----这一行定位用的
PRODUCT_PACKAGES +=
\
tomoyo-init
\
tomoyo-conf
\
macd
\
mac
\
tomoyo-editpolicy-agent
\
rsync
service
macd
/system/bin/macd
class
core
socket
macd
stream
0660
root
system
system/tomoyo内容copy来
添加内核编译选项,首先找到编译内核的文件
具体位置查找方法:device目录下,BoardConfig.mk文件中有两行:
TARGET_KERNEL_CONFIG
:=
cyanogenmod_hammerhead_defconfig
A文件
TARGET_KERNEL_SOURCE :=
kernel/lge/hammerhead
B文件
TARGET_KERNEL_SOURCE
locate A文件,它就是编译内核的文件,通常在kernel目录下的arch/arm/configs/下
在该文件中添加以下内容:
CONFIG_SECURITY_TOMOYO=y
CONFIG_SECURITY_TOMOYO_MAX_ACCEPT_ENTRY=2048
CONFIG_SECURITY_TOMOYO_MAX_AUDIT_LOG=1024
CONFIG_SECURITY_TOMOYO_POLICY_LOADER="/sbin/tomoyo-init"
CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER="/init"
CONFIG_DEFAULT_SECURITY_TOMOYO=y
CONFIG_DEFAULT_SECURITY="tomoyo"
CONFIG_SECURITY_TOMOYO_MAX_ACCEPT_ENTRY=2048
CONFIG_SECURITY_TOMOYO_MAX_AUDIT_LOG=1024
CONFIG_SECURITY_TOMOYO_POLICY_LOADER="/sbin/tomoyo-init"
CONFIG_SECURITY_TOMOYO_ACTIVATION_TRIGGER="/init"
CONFIG_DEFAULT_SECURITY_TOMOYO=y
CONFIG_DEFAULT_SECURITY="tomoyo"
同时确保
CONFIG_KEYS=y
CONFIG_SECURITY=y
CONFIG_SECURITYFS=y
CONFIG_NET=y
CONFIG_SECURITYFS=y
CONFIG_NET=y
#CONFIG_SECURITY_SELINUX is not set
#CONFIG_DEFAULT_SECURITY_SELINUX is not set
vender/cm/config/common.mk 里添加一段
PRODUCT_PACKAGES
system/core/rootdir/init.rc 里添加macd的相关内容,不过暂时macd还没用上呢
这样,tomoyo应该移植完成了,编译一下
如果完成后手机里出现/security/目录,里面有策略文件
/sys/kernel/security/目录下出现tomoyo目录,里面有策略文件
则tomoyo移植成功
排错方法:
检查内核编译选项是否打开:
cp A文件 B/.config
在kernel目录,该设备的目录下,make menuconfig,查看tomoyo选项是否选中,如果没有,请手动去内核编译文件查错,不要在make menuconfig的时候直接选中tomoyo,因为会出很多奇怪的编译错误。
查看内核中是否已经编译了tomoyo:
adb shell到手机上
grep -r tomoyo /proc/kallsyms
如果有结果,那么证明tomoyo已经成功编译到内核中了
这时考虑是否common.mk中有问题了。