FORUMS
Remove All Ads from XDA
Win Honor 9 Lite

[MOD] Universal Init.d Injector

2,390 posts
Thanks Meter: 2,914
 
By Zackptg5, Senior Member on 21st October 2017, 02:54 AM
Post Reply Email Thread
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 or supersu: a boot scripts (post-fs-data) will be installed that will run all exectuable scripts in init.d. A test init.d script will also be installed.

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 by using @osm0sis's anykernel2. It's based off of @CosmicDan's original idea with using sysinit. See list below.
What it does:
  • Search for sysinit in any rc file. If found and seclabel is missing (typical case), add seclabel. If seclabel is already present, then that seclabel will be set to permissive in sepolicy
  • If sysinit isn't found, a custom rc file and sysinit file (modified version of @JustArchi's) will be installed and init.rc and sepolicy will be patched accordingly to add init.d support
  • Test init.d script is installed. It'll create an empty file called InitdInjectorTest in /data - if that files is present after rebooting, init.d is working
  • Backup/remove any setools present in bin and xbin and then 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

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.

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)
Devices that require boot img avb-signing

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 (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

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

Changelog:
  • v1.1 - Use late start for magisk (liveboot is still post-fs-data) due to auto mount occurring after post-fs-data
  • v1.0 - Completely redone with unity/ak2 hybrid template for maximal device compatibility
Attached Files
File Type: zip Init.d-Injector_v1.2.zip - [Click for QR Code] (8.19 MB, 374 views)
The Following 38 Users Say Thank You to Zackptg5 For This Useful Post: [ View ] Gift Zackptg5 Ad-Free
 
 
21st October 2017, 04:38 AM |#2  
CosmicDan's Avatar
Senior Member
Flag Sydney
Thanks Meter: 4,334
 
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, 04:42 AM |#3  
OP Senior Member
Thanks Meter: 2,914
 
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, 11:46 AM |#4  
Account currently disabled
Flag San Pedro, Laguna
Thanks Meter: 1,618
 
More
Will try this soon on Honor 8 Pro and report back.
22nd October 2017, 03:55 PM |#5  
OP Senior Member
Thanks Meter: 2,914
 
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, 05:22 PM |#6  
OP Senior Member
Thanks Meter: 2,914
 
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, 05:35 AM |#7  
OP Senior Member
Thanks Meter: 2,914
 
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, 07:01 AM |#8  
CosmicDan's Avatar
Senior Member
Flag Sydney
Thanks Meter: 4,334
 
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, 01:13 PM |#9  
OP Senior Member
Thanks Meter: 2,914
 
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, 11:46 AM |#10  
Junior Member
Thanks Meter: 0
 
More
Is that supposed to work systemlessly?
28th October 2017, 06:09 PM |#11  
Senior Member
Flag Erie, CO
Thanks Meter: 220
 
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

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes