1

I've been happy using Android-x86 Nougat on my system. Thanks to everyone who made that work. I'm now trying to make one small change which is that I want to run a custom init script (a shell script) at bootup.

It seemed like a simple idea which I've done before on KitKat without problems. I modified init.rc and added a service to start my script. But what happens is on bootup, I see:

04-17 13:16:14.823  1210  1210 I init    : type=1400 audit(0.0:6): avc: denied { execute_no_trans } for path="/system/bin/mystart" dev="loop1" ino=280 scontext=u:r:init:s0 tcontext=u:object_r:system_file:s0 tclass=file permissive=1

That error is a SELinux permission error so I then proceeded to try these solutions:

  1. Disabling SElinux

    write /sys/fs/selinux/enforce 0
    

    And checked that this causes the system to be in permissive mode but at bootup, the same error still occurs.

  2. Adding a custom SELinux policy, I added:

    build/target/board/generic/sepolicy/mystart.te
    type mystart, domain;
    type mystart_exec, exec_type, file_type;
    
    init_daemon_domain(mystart)
    

    But this still doesn't allow the service to proceed.

  3. Tried to run it as a post action:

    on property:dev.bootcomplete=1
    exec u:r:shell:s0 shell shell input log adb sdcard_rw sdcard_r net_bt_admin net_bt inet net_bw_stats -- /system/bin/sh /system/bin/mystart
    

    This still hits the same avc issue.

Edit: This issue is for a boot script (not an ELF executable as in the other case) and furthermore, as I mentioned above, turning off SELinux enforce does not permit the script to be run.

0

1 Answer 1

0

The avc denial you have got states that:

init is running with its context u:r:init:0, you want it to execute /system/bin/mystart (script, binary, whatever) which is labeled as u:object_r:system_file:s0. But init isn't allowed to execute system_file in sepolicy. However you have set SELinux permissive, so it's just a warning, not actual denial.

Therefore you don't need to do anything with SELinux unless you set it enforcing. There must be some other problem with your shell script. Put set -x; exec >/data/media/0/mystart.log 2>&1 at the start of your script to see what happens when it's executed.

RELATED: How to run an executable on boot and keep it running?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .