FORUMS
Remove All Ads from XDA
Honor View 10

[MOD] Universal Init.d Injector

1,701 posts
Thanks Meter: 1,536
 
By Zackptg5, Senior Member on 21st October 2017, 03:54 AM
Post Reply Email Thread
This is a flashable zip that modifies the boot img and part of the system to enable init.d support for any device (almost) by using @osm0sis's anykernel2. It's based off of @CosmicDan's original idea with using sysinit and for the sepolicy patches.

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.

What it does:
  • Patch sepolicy for init.d
  • Search all of the init*.rc scripts and backup/remove old init.d stuff
  • Search system for install-recovery.sh and backup/remove old init.d stuff from it
  • Add init.d support to init.rc
  • Replace/create /system/bin/sysinit file which will run any scripts present in init.d (and backup/remove any sysinit files present in bin and xbin)
  • Backup/remove any setools present in bin and xbin
  • Add addon.d script if ROM has addon.d support so it'll survive dirty flashes
  • Add setools to sbin. These tools include: sepolicy-inject, sesearch, seinfo. All have been ported to android by Xmikos and can be found here: https://github.com/xmikos/setools-android

All files that could be modified are backed up before they're modified at all for easy removal. To uninstall, just flash the zip again and it'll restore everything to how it was before
With the setools, you can use init.d boot scripts that search and inject sepolicy changes. Check Xmikos's github linked above for more details on their usage

BACKUP BOOT AND SYSTEM PARTITIONS BEFORE FLASHING.

Current weird boot imgs supported natively are:
LG bump devices (like my G2)
Pixel/newer nexus devices that require boot img avb-signing - untested

FOR OTHER WEIRD BOOT IMAGES:
If you have a weird boot image not listed above like sony ELF, rockchip KRNL, etc, go here: https://github.com/osm0sis/AnyKernel...nary-inclusion to see which binaries are required
Then get the binaries from the AIK Mobile zip here: https://forum.xda-developers.com/sho....php?t=2073775
Then just copy those binaries to the tools folder of the init.d-injector zip, rezip it, and flash it

Confirmed working:
Nexus 5x
Verizon LG G2
Oneplus 3/3T
Nexus 9
Redmi Note (running MIUI 9 - Marshmallow)

I'm still pretty new to the whole boot img modification thing so any feedback would be appreciated (I have the source here for a reason)
Confirmations for working devices would be great too. Thanks!

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

Changelog:
  • v1.6 - Swapped order of service and event that calls it - should fix issue where it wasn't working, sign boot imgs for all boot imgs that were already signed but leave others alone
  • v1.5 - Removed addon.d stuff (probably a bad idea to back up kernel since dirty flashing an updated rom would then have the older kernel restored), updated AK2 with enhanced pixel/pixel2 support
  • v1.4 - Added pixel 2 support (in theory), minor bug fixes, updated anykernel to latest version
  • v1.3 - Added patching of install-recovery.sh from @CosmicDan's suggestion
  • v1.2 - Added support for avb-signing for pixel/newer nexus devices
  • v1.1 - Added support for nvidia tegra devices
  • v1.0 - Initial release
Attached Files
File Type: zip Init.d-Injector-v1.6.zip - [Click for QR Code] (3.94 MB, 1254 views)
The Following 22 Users Say Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
 
 
21st October 2017, 05:38 AM |#2  
CosmicDan's Avatar
Senior Member
Flag Sydney
Thanks Meter: 4,199
 
Donate to Me
More
Good stuff

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.
The Following 2 Users Say Thank You to CosmicDan For This Useful Post: [ View ] Gift CosmicDan Ad-Free
21st October 2017, 05:42 AM |#3  
OP Senior Member
Thanks Meter: 1,536
 
More
Quote:
Originally Posted by CosmicDan

Good stuff

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!
22nd October 2017, 12:46 PM |#4  
Account currently disabled
Flag San Pedro, Laguna
Thanks Meter: 1,611
 
More
Will try this soon on Honor 8 Pro and report back.
22nd October 2017, 04:55 PM |#5  
OP Senior Member
Thanks Meter: 1,536
 
More
Quick update to v1.1
Just bought a used nexus 9 and found that the boot partition layout for it and other nvidia tegra devices is different from typical android devices. So I added support for nvidia tegra devices
The Following 2 Users Say Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
24th October 2017, 06:22 PM |#6  
OP Senior Member
Thanks Meter: 1,536
 
More
So github screwed with my EOL again and converted a few of the files to windows eol which broke everything. I just fixed it and reuploaded v1.1 with the fixes so just redownload it and flash away. Thanks to @dmgZero for finding the issue
The Following 2 Users Say Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
25th October 2017, 06:35 AM |#7  
OP Senior Member
Thanks Meter: 1,536
 
More
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
The Following 2 Users Say Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
26th October 2017, 08:01 AM |#8  
CosmicDan's Avatar
Senior Member
Flag Sydney
Thanks Meter: 4,199
 
Donate to Me
More
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.
The Following User Says Thank You to CosmicDan For This Useful Post: [ View ] Gift CosmicDan Ad-Free
26th October 2017, 02:13 PM |#9  
OP Senior Member
Thanks Meter: 1,536
 
More
Quote:
Originally Posted by CosmicDan

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!
The Following 2 Users Say Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
28th October 2017, 12:46 PM |#10  
Junior Member
Thanks Meter: 0
 
More
Is that supposed to work systemlessly?
28th October 2017, 07:09 PM |#11  
Senior Member
Flag Erie, CO
Thanks Meter: 217
 
Donate to Me
More
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.
Post Reply Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes