[MOD] Universal Init.d Injector v3.1 [Deprecated]

Search This thread

Zackptg5

Recognized Developer
Sep 18, 2014
4,086
6,679
zackptg5.com
This is a flashable zip that enables init.d scripts to run depending on the root method you have installed.
To uninstall, just flash the zip again and it'll restore everything to how it was before

If magisk:
Boot scripts will be installed that will run all exectuable scripts in init.d as post-fs-data except any that end in '-ls' which will be run as late start. Also note that if you're trying to create the init.d folder, the original directory when using magisk is actually /sbin/.core/mirror/system/etc. It goes without saying that this could break safetynet (honestly though, just copy your script to /sbin/.core/img/.core/service.d or post-fs-data.d instead and set permissions to 0755 rather than creating an init.d directory - using the in-house magisk solution is always the better option. Magisk users have almost no reason to create an init.d directory)

The rest of this is for non-magisk/supersu installs
Otherwise: the boot img and part of the system will be modified to enable init.d support.
What it does:
  • Search for sysinit in any rc file. If found and seclabel is intact and equal to target seclabel for my init rc script, then that seclabel will be set to permissive in sepolicy if needbe instead of using my solution
  • If sysinit with seclabel isn't found, a custom rc file and system/bin/script file will be installed and sepolicy will be patched accordingly to add init.d support. Init.d scripts will be run the same way as with magisk installs above
  • Adds magiskpolicy to sbin. It's more up to date and complete than setools so why not?
If there is an error on unpacking your boot image, check the binary inclusion section here to see if your device needs one: https://github.com/osm0sis/AnyKernel3#-binary-inclusion
If it does, place it in addon/AnyKernel3/tools/arm (or x86 - whichever your architecture is - probably arm)

I am not responsible for any oddities that happen to your device because of this, use common sense. For example, if you know your device has a weird boot img, check first.

BACKUP BOOT AND SYSTEM PARTITIONS BEFORE FLASHING

Compatibility: Any device magisk is compatible with

Confirmed working (boot img method):
Nexus 5x
Verizon LG G2
Oneplus 3/3T
Oneplus 5T
Nexus 9
Redmi Note
Zuk Edge
Axon 7 (A2017U)
Nexus 5
SM-N900T
SM-T350
LeEco Pro 3

Confirm your device works and I'll add it to the list! :)

Special thanks to: @osm0sis, @CosmicDan, @Ricky Divjakovski, @JustArchi

Source: https://github.com/Zackptg5/Init.d-Injector

Download
 
Last edited:

CosmicDan

Senior Member
Jun 19, 2009
5,862
7,697
34
Sydney
Xiaomi Poco F1
Good stuff :good:

Good idea with the removal of other/old init.d capabilities. It's annoying that so many ROM's/kernels claim to have init.d but they're fake or hacky (well, I guess the sepolicy injection is pretty hacky too lol). You might also want to consider looking for install-recovery hijack method of init.d and disabling that too - shouldn't be too hard, just check if the file exists in known locations and grep for init.d. The harder part though is what to actually *do* if found - probably best to comment-out the line that contains "run-parts" and/or "init.d" rather than erase the whole file.
 

Zackptg5

Recognized Developer
Sep 18, 2014
4,086
6,679
zackptg5.com
Good stuff :good:

Good idea with the removal of other/old init.d capabilities. It's annoying that so many ROM's/kernels claim to have init.d but they're fake or hacky (well, I guess the sepolicy injection is pretty hacky too lol). You might also want to consider looking for install-recovery hijack method of init.d and disabling that too - shouldn't be too hard, just check if the file exists in known locations and grep for init.d. The harder part though is what to actually *do* if found - probably best to comment-out the line that contains "run-parts" and/or "init.d" rather than erase the whole file.
Good idea, I'll look into that. Thanks!
 

Zackptg5

Recognized Developer
Sep 18, 2014
4,086
6,679
zackptg5.com
Just updated to v1.2. I added support for pixels and nexus5x/6p avb-signing. I haven't been able to test it out myself as my bullhead doesn't even need signing to work so any feedback would be great. Also updated the OP on how to modify this for any weird boot imgs you may have

Edit: No point in spamming the thread with another post: updated to v1.3. Just adds capability to remove any init.d stuff present from install-recovery.sh. Thanks to @CosmicDan for pointing it out
 
Last edited:

CosmicDan

Senior Member
Jun 19, 2009
5,862
7,697
34
Sydney
Xiaomi Poco F1
Works fine on Redmi Note (a MediaTek Helio X20 device) running MIUI 9 (Android 6.0).

One tiny detail, maybe just do an mkdir /system/etc/init.d after the patch succeeds, if it doesn't already exist. I could imagine that some other zips could check for the existence of this folder for a simple way to determine if init.d is supported.
 

Zackptg5

Recognized Developer
Sep 18, 2014
4,086
6,679
zackptg5.com
Works fine on Redmi Note (a MediaTek Helio X20 device) running MIUI 9 (Android 6.0).

One tiny detail, maybe just do an mkdir /system/etc/init.d after the patch succeeds, if it doesn't already exist. I could imagine that some other zips could check for the existence of this folder for a simple way to determine if init.d is supported.

Sweet, I already have that in the sysinit script but it would make more sense to move that to the installer so I'll put that into the next version. Thanks!
 

Metabolic12

Senior Member
Oct 12, 2016
329
189
Erie, CO
You should probably add Samsung to the weird/hexed/Satan kernels. Tried flashing your zip and recovery came back with Invalid Partition upon failure, my device is a Galaxy Note 5 running RR 7.1.2. I do love the idea and your work though bro. Thanks.
 

Zackptg5

Recognized Developer
Sep 18, 2014
4,086
6,679
zackptg5.com
You should probably add Samsung to the weird/hexed/Satan kernels. Tried flashing your zip and recovery came back with Invalid Partition upon failure, my device is a Galaxy Note 5 running RR 7.1.2. I do love the idea and your work though bro. Thanks.
I tried to originally but it was basically impossible to detect all bootimg types and they need extract binaries which if I included them all, would make the zip over 70mb. I updated the op a few days ago with instructions on how to add support for weird boot imgs (it's basically adding a few files to the zip)
 

Metabolic12

Senior Member
Oct 12, 2016
329
189
Erie, CO
I completely understand, I wasn't gonna ask you to include my kernel regardless that's rather selfish, and I did follow your guide in the OP to get it to work. I was just suggesting maybe add Samsung kernels next to LG in your OP. Great work bro, thank you.

I tried to originally but it was basically impossible to detect all bootimg types and they need extract binaries which if I included them all, would make the zip over 70mb. I updated the op a few days ago with instructions on how to add support for weird boot imgs (it's basically adding a few files to the zip)


---------- Post added at 02:58 AM ---------- Previous post was at 02:51 AM ----------

I'm a retard, I read the OP wrong earlier. Disregard the adding Samsung part ha.

I tried to originally but it was basically impossible to detect all bootimg types and they need extract binaries which if I included them all, would make the zip over 70mb. I updated the op a few days ago with instructions on how to add support for weird boot imgs (it's basically adding a few files to the zip)
 

CosmicDan

Senior Member
Jun 19, 2009
5,862
7,697
34
Sydney
Xiaomi Poco F1
The boot img is not part of the system partition so that's systemless. However, it installs an addon.d script and modifies the sysinit and install_recovery files if present which are on the system. It won't break safetynet if that's what you're wondering :)
I thought *any* System modification trips the Safety net?

I use the Universal Safetynet Bypass module for Magisk so it doesn't bother me, but curious.

Sent from my Redmi Note 4 using Tapatalk
 

Zackptg5

Recognized Developer
Sep 18, 2014
4,086
6,679
zackptg5.com
I thought *any* System modification trips the Safety net?

I use the Universal Safetynet Bypass module for Magisk so it doesn't bother me, but curious.

Sent from my Redmi Note 4 using Tapatalk

That's what I thought initially too but I've found lots of system modifications doesn't break safetynet such as editing the hosts file. Modifications to the zygote such as xposed framework for sure break safetynet but I'm not sure exactly which system modifications would. Other than testing them myself, I'm not really sure what would break it. I've found that you can completely alter parts of the system like with arise sound systems which adds a whole slew of libs and other modifications and safetynet still won't break (I found through my work there that having the system mounted as rw via a boot script will trigger safetynet but you can even go so far as to mount it as rw, make your changes, and then remount it as ro before boot completes and safetynet will still pass). It's weird man
 

CosmicDan

Senior Member
Jun 19, 2009
5,862
7,697
34
Sydney
Xiaomi Poco F1
That's what I thought initially too but I've found lots of system modifications doesn't break safetynet such as editing the hosts file. Modifications to the zygote such as xposed framework for sure break safetynet but I'm not sure exactly which system modifications would. Other than testing them myself, I'm not really sure what would break it. I've found that you can completely alter parts of the system like with arise sound systems which adds a whole slew of libs and other modifications and safetynet still won't break (I found through my work there that having the system mounted as rw via a boot script will trigger safetynet but you can even go so far as to mount it as rw, make your changes, and then remount it as ro before boot completes and safetynet will still pass). It's weird man
Kind of makes sense actually.

Hosts is in etc right, nothing in there is executable. So I imagine any changes to etc won't trip it because nothing in there would mess with device security. Sound mods... Well yeah they ADD libs but they don't replace any do they? They just add sound filters through the mixer configs in etc.

So I guess it makes sense. Sysinit is just added to xbin or whatever and I guess that doesn't trip it. But if you replaced, say, dex2oat with a proxy script to intercept oat generation, then it would definitely trip it.

Sent from my Redmi Note 4 using Tapatalk
 

amit.tiger12

Senior Member
Jul 15, 2015
625
454
Mumbai
Is it really needed??
I want to flash Dolby Atmos for Redmi Note 4, but init.d support is needed as mentioned by developer.
I tried Dolby Atmos without it sound is loud and great
I can't understand, why init.d is still needed?
Can anyone explain here?
 

Zackptg5

Recognized Developer
Sep 18, 2014
4,086
6,679
zackptg5.com
Is it really needed??
I want to flash Dolby Atmos for Redmi Note 4, but init.d support is needed as mentioned by developer.
I tried Dolby Atmos without it sound is loud and great
I can't understand, why init.d is still needed?
Can anyone explain here?
If it's working, then you don't need it or already have it. Init.d support is needed for Dolby if you are not using magisk or supersu and you have selinux set to enforcing
 

d3vyarth

Senior Member
Jul 10, 2014
367
70
If it's working, then you don't need it or already have it. Init.d support is needed for Dolby if you are not using magisk or supersu and you have selinux set to enforcing
That's with respect to Dolby, what does it provide as a general point of view? What is it's significance?
Explain if you've enough time or just throw a link, it will help out.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 68
    This is a flashable zip that enables init.d scripts to run depending on the root method you have installed.
    To uninstall, just flash the zip again and it'll restore everything to how it was before

    If magisk:
    Boot scripts will be installed that will run all exectuable scripts in init.d as post-fs-data except any that end in '-ls' which will be run as late start. Also note that if you're trying to create the init.d folder, the original directory when using magisk is actually /sbin/.core/mirror/system/etc. It goes without saying that this could break safetynet (honestly though, just copy your script to /sbin/.core/img/.core/service.d or post-fs-data.d instead and set permissions to 0755 rather than creating an init.d directory - using the in-house magisk solution is always the better option. Magisk users have almost no reason to create an init.d directory)

    The rest of this is for non-magisk/supersu installs
    Otherwise: the boot img and part of the system will be modified to enable init.d support.
    What it does:
    • Search for sysinit in any rc file. If found and seclabel is intact and equal to target seclabel for my init rc script, then that seclabel will be set to permissive in sepolicy if needbe instead of using my solution
    • If sysinit with seclabel isn't found, a custom rc file and system/bin/script file will be installed and sepolicy will be patched accordingly to add init.d support. Init.d scripts will be run the same way as with magisk installs above
    • Adds magiskpolicy to sbin. It's more up to date and complete than setools so why not?
    If there is an error on unpacking your boot image, check the binary inclusion section here to see if your device needs one: https://github.com/osm0sis/AnyKernel3#-binary-inclusion
    If it does, place it in addon/AnyKernel3/tools/arm (or x86 - whichever your architecture is - probably arm)

    I am not responsible for any oddities that happen to your device because of this, use common sense. For example, if you know your device has a weird boot img, check first.

    BACKUP BOOT AND SYSTEM PARTITIONS BEFORE FLASHING

    Compatibility: Any device magisk is compatible with

    Confirmed working (boot img method):
    Nexus 5x
    Verizon LG G2
    Oneplus 3/3T
    Oneplus 5T
    Nexus 9
    Redmi Note
    Zuk Edge
    Axon 7 (A2017U)
    Nexus 5
    SM-N900T
    SM-T350
    LeEco Pro 3

    Confirm your device works and I'll add it to the list! :)

    Special thanks to: @osm0sis, @CosmicDan, @Ricky Divjakovski, @JustArchi

    Source: https://github.com/Zackptg5/Init.d-Injector

    Download
    4
    Hey everyone. Rereleasing v1.8 due to a major bug in unity that I just fixed :/
    4
    Dropped a new update. Removed all addon.d backup/restore stuff since restoring an old kernel would be bad if the user dirty flashes an updated rom or something like that and updated AK2. Use old v1.4 zip to uninstall old version before flashing v1.5 in order to remove all addon.d stuff (or just delete the script manually)
    4
    Updated init.d injector to v1.8.8. Changelog: Updated magisktools to 18.1, minapi is now 17
    4
    Due to most of my free time being eaten up by work/school for the past few months and forseeable future, I'm calling it quits on this mod (and many others I work on). I moved them accordingly on my website so you can see which are still being actively updated. Note that this mod still works fine with latest magisk and non-magisk installs so it'll still be fine for now at least
Our Apps
Get our official app!
The best way to access XDA on your phone
Nav Gestures
Add swipe gestures to any Android
One Handed Mode
Eases uses one hand with your phone