LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Mobile
User Name
Password
Linux - Mobile This 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


Reply
  Search this Thread
Old 03-30-2016, 01:09 AM   #1
miscguy
LQ Newbie
 
Registered: Mar 2016
Posts: 1

Rep: Reputation: Disabled
[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 !
 
Old 05-15-2016, 02:19 PM   #2
business_kid
LQ Guru
 
Registered: Jan 2006
Location: Ireland
Distribution: Slackware, Slarm64 & Android
Posts: 16,093

Rep: Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301Reputation: 2301
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Unable to execute file (I have execute permission) leoecco Linux - General 1 07-20-2013 10:20 PM
Failed to Execute Init. No Init found. ihjaz Linux - Server 4 11-20-2012 03:02 AM
Unable to shutdown, reboot, halt, init 6, init 0 procfs Linux - Newbie 6 07-23-2012 02:58 AM
unable to run c program , error : cannot execute binary file soni_silver17 Linux - Software 4 03-30-2009 08:45 AM
unable to execute any program! hakim Red Hat 3 06-22-2004 10:56 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Mobile

All times are GMT -5. The time now is 03:16 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration