LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Mobile (https://www.linuxquestions.org/questions/linux-mobile-81/)
-   -   [REALLY DIFFICULT]Why am I unable to execute my C program during Init ? (https://www.linuxquestions.org/questions/linux-mobile-81/%5Breally-difficult%5Dwhy-am-i-unable-to-execute-my-c-program-during-init-4175576173/)

miscguy 03-30-2016 01:09 AM

[REALLY DIFFICULT]Why am I unable to execute my C program during Init ?
 
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 !

business_kid 05-15-2016 02:19 PM

No programmer here, but iirc C software was disabled for lusers in Android. It will somehow lack exec permissions. That's why everything is Java based, Java SDKs etc.

Write it in Java.


All times are GMT -5. The time now is 11:30 AM.