How to run pre compiled binary on android init?

Hi all,

I want the ouput of “du” command to a file on android init.

i have written a small c-program using execv system call. when i run this pre-compiled binary on device i’m getting desired ouput. But i want to run this binary on android init.

i tried by adding below service on one init file but its not executing

service my_service /system/bin/my_bin
user system
group system
disabled

on post-fs
start my_bin

kindly help me.

Thanks.

Which board is this issue related to. Do you have any error showed in dmesg (and/or logcat)? Could it be a sepolicy issue?

Hi Loic,

i’m using sdm845 based custom board.

yes im seeing SE linux denial. i’ll fix it now.

Thanks.

Hi Loic,

Below are the denials i got.

[ 642.539425] [20200116_20:46:26.349576]@3 type=1400 audit(1579187685.339:617): avc: denied { getattr } for comm=“CallMonitors-1” path="/proc/stat" dev=“proc” ino=4026532093 scontext=u:r:untrusted_app_27:s0:c209,c256,c512,c768 tcontext=u:object_r:proc_stat:s0 tclass=file permissive=1
[ 642.539466] [20200116_20:46:26.349627]@3 type=1400 audit(1579187786.339:618): avc: denied { getattr } for comm=“toybox” path="/data/evt-test/evt-sniff.cfg" dev=“sda17” ino=14 scontext=u:r:vold:s0 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=1
[ 642.541496] [20200116_20:46:26.351658]@6 audit: audit_lost=149 audit_rate_limit=5 audit_backlog_limit=64
[ 642.541500] [20200116_20:46:26.351663]@6 audit: rate limit exceeded
[ 642.541619] [20200116_20:46:26.351771]@0 type=1400 audit(1579187786.339:618): avc: denied { getattr } for comm=“toybox” path="/data/evt-test/evt-sniff.cfg" dev=“sda17” ino=14 scontext=u:r:vold:s0 tcontext=u:object_r:system_data_file:s0 tclass=file permissive=1
[ 642.541654] [20200116_20:46:26.351808]@0 type=1400 audit(1579187786.349:619): avc: denied { getattr } for comm=“toybox” path="/data/misc_de/0/storaged" dev=“sda17” ino=2899972 scontext=u:r:vold:s0 tcontext=u:object_r:storaged_data_file:s0 tclass=dir permissive=1
[ 642.541939] [20200116_20:46:26.352092]@0 type=1400 audit(1579187786.349:619): avc: denied { getattr } for comm=“toybox” path="/data/misc_de/0/storaged" dev=“sda17” ino=2899972 scontext=u:r:vold:s0 tcontext=u:object_r:storaged_data_file:s0 tclass=dir permissive=1
[ 642.541966] [20200116_20:46:26.352121]@0 type=1400 audit(1579187786.349:620): avc: denied { read } for comm=“toybox” name=“storaged” dev=“sda17” ino=2899972 scontext=u:r:vold:s0 tcontext=u:object_r:storaged_data_file:s0 tclass=dir permissive=1
[ 642.542141] [20200116_20:46:26.352296]@0 type=1400 audit(1579187786.349:620): avc: denied { read } for comm=“toybox” name=“storaged” dev=“sda17” ino=2899972 scontext=u:r:vold:s0 tcontext=u:object_r:storaged_data_file:s0 tclass=dir permissive=1
[ 642.542168] [20200116_20:46:26.352323]@0 type=1400 audit(1579187786.349:621): avc: denied { open } for comm=“toybox” path="/data/misc_de/0/storaged" dev=“sda17” ino=2899972 scontext=u:r:vold:s0 tcontext=u:object_r:storaged_data_file:s0 tclass=dir permissive=1
[ 642.542326] [20200116_20:46:26.352480]@0 type=1400 audit(1579187786.349:621): avc: denied { open } for comm=“toybox” path="/data/misc_de/0/storaged" dev=“sda17” ino=2899972 scontext=u:r:vold:s0 tcontext=u:object_r:storaged_data_file:s0 tclass=dir permissive=1
[ 642.542352] [20200116_20:46:26.352507]@0 type=1400 audit(1579187786.349:622): avc: denied { getattr } for comm=“toybox” path="/data/misc_de/0/rollback" dev=“sda17” ino=2899973 scontext=u:r:vold:s0 tcontext=u:object_r:rollback_data_file:s0 tclass=dir permissive=1

i have run audit2allow tool. got below info

#============= vold ==============
allow vold rollback_data_file:dir getattr;
allow vold storaged_data_file:dir { getattr open read };
allow vold system_data_file:file getattr;

then added this in cutsom policy.te file but build is failing throwing error:
ERROR ‘unknown type rollback_data_file’ at token ‘;’ on line 66995:
allow vold rollback_data_file:dir getattr;

seems like sepolicy_neverallows_intermediates.

how to proceed please help me.

Thanks