Hi everybody,

I created a C program to kill the ADB process upon detecting an incoming ADB connection.

But I am having difficulties in initializing it in the init.rc file which is part of the initrd.img located within the boot-img of an AOSP Marshmallow MMB29V build image.

Below is my edit made to the init.rc
on init
chmod 777 /sbin/check_usb
chown root root /sbin/check_usb

service disableadb /sbin/check_usb
class main
seclabel u:r:disableadb:s0


My C program check_usb is located in /sbin/system and I tested it by executing ./sbin/system/check_usb with an ADB shell and the program executed fine.

I also modified the init.usb.rc file as shown below (note i added the line "start disableadb" which should trigger upon an incoming ADB connection):

on property:sys.usb.config=accessory,adb && property:sys.usb.configfs=0
start disableadb


However when i compile the initramfs and updated into my boot.img and fastboot flash back to the device and ADB shell the device, I observed an error (command : "dmesg | grep disableadb") . Error msg is below :
init : cannot setexeccon ('u:r:disableadb:s0') Invalid argument

I believed I am not configuring SELinux properly for my daemon to execute within the Android Init environment. If so how do i configure such that I could allow my daemon to execute correctly within the Android Init environment ?

Can someone point me the right direction please?

Much appreciated !