From b04b7944381228cd1c661438cd5ffd174fe80c89 Mon Sep 17 00:00:00 2001 From: Quang Luong Date: Mon, 31 Jul 2017 17:09:42 -0700 Subject: uml: add adb support, add eth0 script sepolicies After running UML, it is now possible to connect with adb using $ adb connect 192.168.0.253 Added init.eth0.sh script to configure tuntap connection to host. Modified init.uml.rc to run init.eth0.sh on boot. Added SELinux rules for init.eth0.sh to run during init. === To run === Install UML utilities $ sudo apt-get install uml-utilities $ sudo mv /usr/lib/uml/uml_net /usr/bin/uml_net $ sudo chmod +x /usr/bin/uml_net Compile UML userspace $ . build/envsetup.sh $ lunch uml-userdebug $ make -j40 Compile UML Kernel on Android-4.9 branch $ ARCH=um SUBARCH=x86_64 scripts/kconfig/merge_config.sh arch/um/configs/x86_64_defconfig kernel/configs/android-base.config kernel/configs/android-recommended.config $ make ARCH=um SUBARCH=x86_64 CROSS_COMPILE= -j40 Run UML: $ ./vmlinux initrd=ramdisk.img ubda=system.img ubdb=userdata.img \ androidboot.hardware=uml mem=256M umid=uml eth0=tuntap,,,192.168.0.254 Connect with adb: $ adb connect 192.168.0.253 Test: manual Bug: 32523022 Change-Id: Iaafc0aa701ff7d777226168a078c0a3712a3e6b8 Signed-off-by: Quang Luong --- BoardConfig.mk | 3 +++ init.eth0.sh | 2 ++ init.uml.rc | 3 +++ sepolicy/file_contexts | 1 + sepolicy/init_eth0.te | 10 ++++++++++ uml.mk | 1 + 6 files changed, 20 insertions(+) create mode 100755 init.eth0.sh create mode 100644 sepolicy/file_contexts create mode 100644 sepolicy/init_eth0.te diff --git a/BoardConfig.mk b/BoardConfig.mk index b6eb431..807b290 100644 --- a/BoardConfig.mk +++ b/BoardConfig.mk @@ -20,3 +20,6 @@ TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true BOARD_SYSTEMIMAGE_PARTITION_SIZE := 786432000 BOARD_USERDATAIMAGE_PARTITION_SIZE := 576716800 BOARD_FLASH_BLOCK_SIZE := 512 + +BOARD_SEPOLICY_DIRS += \ + device/generic/uml/sepolicy diff --git a/init.eth0.sh b/init.eth0.sh new file mode 100755 index 0000000..39fc008 --- /dev/null +++ b/init.eth0.sh @@ -0,0 +1,2 @@ +#!/system/bin/sh +ifconfig eth0 192.168.0.253 up \ No newline at end of file diff --git a/init.uml.rc b/init.uml.rc index e5b5d7d..ea12191 100644 --- a/init.uml.rc +++ b/init.uml.rc @@ -1,2 +1,5 @@ on fs mount_all ./fstab.uml + +on boot + exec -- /system/bin/init.eth0.sh \ No newline at end of file diff --git a/sepolicy/file_contexts b/sepolicy/file_contexts new file mode 100644 index 0000000..3eabb35 --- /dev/null +++ b/sepolicy/file_contexts @@ -0,0 +1 @@ +/system/bin/init.eth0.sh u:object_r:init_eth0_exec:s0 \ No newline at end of file diff --git a/sepolicy/init_eth0.te b/sepolicy/init_eth0.te new file mode 100644 index 0000000..45fd56d --- /dev/null +++ b/sepolicy/init_eth0.te @@ -0,0 +1,10 @@ +type init_eth0, domain; +type init_eth0_exec, exec_type, file_type; + +init_daemon_domain(init_eth0) + +allow init_eth0 self:capability { net_admin net_raw }; +allow init_eth0 self:udp_socket { create ioctl }; +allowxperm init_eth0 self:udp_socket ioctl priv_sock_ioctls; +allow init_eth0 shell_exec:file { execute getattr read }; +allow init_eth0 toolbox_exec:file { execute execute_no_trans getattr open read }; diff --git a/uml.mk b/uml.mk index a7fa7f7..32240fa 100644 --- a/uml.mk +++ b/uml.mk @@ -27,3 +27,4 @@ PRODUCT_CHARACTERISTICS := nosdcard PRODUCT_COPY_FILES += $(LOCAL_PATH)/fstab.uml:root/fstab.uml PRODUCT_COPY_FILES += $(LOCAL_PATH)/init.uml.rc:root/init.uml.rc PRODUCT_COPY_FILES += $(LOCAL_PATH)/surfaceflinger.rc:system/etc/init/surfaceflinger.rc +PRODUCT_COPY_FILES += $(LOCAL_PATH)/init.eth0.sh:system/bin/init.eth0.sh -- cgit v1.2.3