[REALLY DIFFICULT]Why am I unable to execute my C program during Init ?
Linux - MobileThis forum is for the discussion of all topics relating to Mobile Linux. This includes Android, Tizen, Sailfish OS, Replicant, Ubuntu Touch, webOS, and other similar projects and products.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
[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 ?
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.