Question: How to add route with busybox (for specified destination and gateway)? - Magisk

THIS IS THE SOLUTION:
Code:
/dev/busybox/route add -net 1.0.1.0 netmask 255.255.255.0 gw $(getprop net.dns1)
-----THE ORIGINAL POST BELOW-----
Is it just me or the busybox doesn't work well?
Here is my code:
alias netstat='/system/xbin/busybox netstat'
alias grep='/system/xbin/busybox grep'
alias awk='/system/xbin/busybox awk'
alias route='/system/xbin/busybox route'
gateway=`netstat -rn | grep ^0\.0\.0\.0 | awk '{print $2}'`
route add -net 1.0.1.0 netmask 255.255.255.0 gw $gateway
Click to expand...
Click to collapse
Apparently busybox doesn't recognize `route add -net 1.0.1.0 netmask 255.255.255.0 gw $gateway`...
Update: I tried to update to magisk 12.0, and now it just shows applet not found instead...
BTW, what's SafetyNet?
Deic said:
You are using a built-in Busybox binary with your ROM not the Magisk's Busybox probably.
Try
Code:
/data/magisk/busybox route
or
Code:
/dev/busybox/route
and:
https://www.howtogeek.com/241012/sa...y-and-other-apps-dont-work-on-rooted-devices/
Click to expand...
Click to collapse
So I did try
Code:
/data/magisk/busybox route
This gives me applet not found again. Then I tried
Code:
/dev/busybox/route
It prints '/dev/busybox/route not found'. I checked and the file '/dev/busybox/route' exists (as a shortcut), so I am not sure what is going on anymore. BTW, I did run su before I tried to run these commands.
Also this is very funny, if I run these commands line by line, I will get different error message than "not found" when I put them in a .sh file and run
Code:
sh script.sh
under root folder.
Solution provided on top.

You are using a built-in Busybox binary with your ROM not the Magisk's Busybox probably.
Try
Code:
/data/magisk/busybox route
or
Code:
/dev/busybox/route
and:
https://www.howtogeek.com/241012/sa...y-and-other-apps-dont-work-on-rooted-devices/

Deic said:
You are using a built-in Busybox binary with your ROM not the Magisk's Busybox probably.
Try
Code:
/data/magisk/busybox route
or
Code:
/dev/busybox/route
and:
https://www.howtogeek.com/241012/sa...y-and-other-apps-dont-work-on-rooted-devices/
Click to expand...
Click to collapse
So I did try
Code:
/data/magisk/busybox route
This gives me applet not found again. Then I tried
Code:
/dev/busybox/route
It prints '/dev/busybox/route not found'. I checked and the file '/dev/busybox/route' exists (as a shortcut), so I am not sure what is going on anymore. BTW, I did run su before I tried to run these commands.

aeroxy said:
So I did try
Code:
/data/magisk/busybox route
This gives me applet not found again. Then I tried
Code:
/dev/busybox/route
It prints '/dev/busybox/route not found'. I checked and the file '/dev/busybox/route' exists (as a shortcut), so I am not sure what is going on anymore. BTW, I did run su before I tried to run these commands.
Click to expand...
Click to collapse
Have you got installed Magisk v12? Would be usefull know what is your device, Android version, etc.. And other relevant info, log, etc...

Deic said:
Have you got installed Magisk v12? Would be usefull know what is your device, Android version, etc.. And other relevant info, log, etc...
Click to expand...
Click to collapse
Yes, I think I mentioned it in the update.
I have two devices, Samsung S6 and Samsung S7, both reported identical error message. Can anyone try to run the same command and see if they get the same result? :fingers-crossed:
Nevermind, I figured it out, check the OP for updated solution.

Deic said:
Have you got installed Magisk v12? Would be usefull know what is your device, Android version, etc.. And other relevant info, log, etc...
Click to expand...
Click to collapse
I figured it. The code had problem. Check out the OP for the solution.

Related

[Q] Compiling kernel modules

Hi
I'm a new owner to a Galaxy tab 8.9 and trying to make it able to mount NFS exports.
So I've rooted the device, installed SuperUser and terminal emulator. Then I downloaded the kernel source tree from Samsung, I compiled the NFS module on my desktop computer moved it to /system/lib/modules on the tab. But it doesn't work, when I do 'insmod nfs.ko' it gives back 'insmod: init_module nfs.ko failed (No such file or directory)'
Is it possible at all to add modules to the standard kernel that comes with the device?
Is my device completely rooted because when I try 'adb root' I get 'adbd cannot run as root in production builds'
me too...
I just encountered the exact same problem on my LG Revolution, except I'm trying to load nfsd.ko for server support.
I know I built it correctly because I've already succeeded in getting tun.ko working properly...
Code:
root # /system/bin/insmod /system/lib/modules/nfsd.ko
insmod: init_module '/system/lib/modules/nfsd.ko' failed (No such file or directory)
root # ls /system/lib/modules
... nfsd.ko
Very odd...
When you do the insmod are you actually in the /system/lib/modules directory? If not, you have to use the full path to the module.
The message with "adb root" is normal even on a rooted device. If you can do "adb shell" followed by "su" you should be ok.
edit...
Now that I think of it...that message usually means the module file was found but a dependency wasn't.
gtj0 said:
Now that I think of it...that message usually means the module file was found but a dependency wasn't.
Click to expand...
Click to collapse
Yep that was my problem. My nfsd.ko needed dependencies that didn't exist...
To the OP: try to insmod the nfs.ko module again and then look at the output of dmesg. You should see messages complaining about the dependencies required by the nfs module.
Then you ought to be able to either remove the requirement for them from your module (my nfsd.ko wanted posix_acl support so I just got rid of that option and rebuilt the module) or if it's something you need/want you might be able to add support for whatever it is as another module...
Good luck and I hope I didn't intrude upon your thread too much
Thanks, I had indeed a dependency problem. Now I managed to load nfs.ko and sunrpc.ko and lockd.ko that were needed because of dependency.
Although I'm still having problems at mounting an nfs export. Previously, before kernel module problem was solved, I got the error message 'No such device' when I tried to mount, now I get 'Invalid argument' instead.
I've tried commands like
busybox mount -t nfs 192.168.1.100:/mnt/raid/media /sdcard/nfs
and
busybox mount -o nolock,ro,hard,intr,vers=3 -t nfs 192.168.1.100:/mnt/raid/media /sdcard/nfs
Any thoughts?
NFS Share - Invalid Argument
Marlin79 said:
........... now I get 'Invalid argument' instead.
I've tried commands like
busybox mount -t nfs 192.168.1.100:/mnt/raid/media /sdcard/nfs
and
busybox mount -o nolock,ro,hard,intr,vers=3 -t nfs 192.168.1.100:/mnt/raid/media /sdcard/nfs
Any thoughts?
Click to expand...
Click to collapse
Seems like an Old thread, and I would assume you've gotten this fixed already, but in case it ISN'T fixed...
>Double check your NFS config (/etc/exports file) and confirm that you are sharing:
* /exports/mnt/raid/media *
If you specified something else in your /etc/exports file, check to make sure your Hard drive (I assume /mnt/raid/media) is soft-linked to the share name you wanted to give it, or that at least the subfolders/files you want shared are softlinked to the /exports/share directory.
**e.g.**
# ln -s /exports/media/ /mnt/raid/media
-OR-
# ln -s /exports/media/shared_media_1.mp4 /mnt/raid/media/actual_file.mp4

[Q] help w jb root

all is good until the last step whats going on?
[email protected]:/tmp/share$ tar xvf motoshare.tgz
adb
busybox
pwn
su
Superuser.apk
[email protected]:/tmp/share$ sudo chown root:root pwn
[email protected]:/tmp/share$ sudo chmod 6755 pwn
[email protected]:/tmp/share$ /tmp/share/adb shell /storage/rfs0/pwn
bash: /tmp/share/adb: No such file or directory
[email protected]:/tmp/share$
Please give me the response for the terminal command:
ls -l /tmp/share/adb
re jb root
[email protected]:/tmp/share$ ls -l /tmp/share/adb
-rwsr-sr-x 1 jody jody 204436 Feb 11 11:49 /tmp/share/adb
jodybgoode said:
[email protected]:/tmp/share$ ls -l /tmp/share/adb
-rwsr-sr-x 1 jody jody 204436 Feb 11 11:49 /tmp/share/adb
Click to expand...
Click to collapse
I will get back to you after I talk with Dan. Unless another set of eyes knows the solution.
Sent from my MB886 using xda app-developers app
Try running the last command as simply "adb shell /storage/rfs0/pwn"
(i.e. without the prefix /tmp/share/)
Help confused
djrbliss said:
As promised, this post describes how to root the Atrix HD Jelly Bean build. This should also work on other Motorola 4.1.2 builds (Razr/Razr Maxx, Razr HD, Razr M, etc.).
The exploit requires setting up a special Samba share and mounting this share on your phone using the File Manager app. I apologize that this process may seem involved for some of you, and request that members of this community help each other out if some of you are having problems completing the procedure. I'm not able to provide individual tech support to every user who wants to root this phone.
The following instructions require a working Linux installation. The following instructions are for Ubuntu. If you don't want to install Ubuntu permanently on your machine, I suggest using a LiveCD installation. Instructions on setting this up are described here:
https://help.ubuntu.com/community/LiveCD#How-To_LiveCD_Ubuntu
Once you're booted into Ubuntu, open a terminal. Create a new directory for your Samba share:
Code:
mkdir /tmp/share
Next, install the samba package:
Code:
sudo apt-get install samba
Edit the configuration file for samba:
Code:
sudo gedit /etc/samba/smb.conf
Add the following lines to the end of the configuration file and save your changes:
Code:
[share]
path = /tmp/share
available = yes
valid users = guest
read only = yes
browsable = yes
public = yes
Close the text editor once you've saved your changes.
Next, create a user for the Samba share by typing in the terminal:
Code:
sudo useradd guest -m -G users
Set a password for the new user. Remember this password:
Code:
sudo passwd guest
Provide a password here and press enter. You won't see the characters you're typing, so be careful.
Next, set a password on the share. Use the same password you just provided:
Code:
sudo smbpasswd -a guest
Type the password you created before and press enter.
Next, restart the Samba server:
Code:
sudo restart smbd
Finally, download and prepare the required files to the Samba share:
Code:
cd /tmp/share
wget [url]http://vulnfactory.org/public/motoshare.tgz[/url]
tar xvf motoshare.tgz
sudo chown root:root pwn
sudo chmod 6755 pwn
At this point, you'll need to know the IP address of your Linux host, which you can get by running "ifconfig" from your terminal (it should be of the form "192.168.x.x").
Next, move over to your Android device. Ensure you have enabled USB Debugging Mode (under Settings -> Development Settings). Ensure your device is connected via Wifi.
Open the "File Manager" app, and select "Remote storage". Click "Add storage", and fill in fields as follows:
Code:
Host IP address: [your Linux machine's IP address]
Domain name: WORKGROUP
Shared folder name: share
User: guest
Password: [the password you created above]
At this point, the phone will mount your Linux share. To complete the process, plug in your phone via USB to your Linux machine, and type the following in your Linux terminal:
Code:
sudo /tmp/share/adb kill-server
sudo /tmp/share/adb shell /storage/rfs0/pwn
If it's successful, this should print "[+] Rooting complete!".
Finally, install Supersu by typing the following in the terminal:
Code:
sudo /tmp/share/adb install /tmp/share/eu.chainfire.supersu.apk
Congratulations, enjoy your rooted device.
I can't stress this enough: I can't provide individualized tech support for everyone on this forum. Please help each other.
TTLayland has been successfully rooted using this technique and has volunteered to help. If you get stuck and can't find support on these forums, feel free to email him at ttlayland (at) gmail (dot) com.
Paypal:
http://goo.gl/zBGb0
Click to expand...
Click to collapse
Got this error:
[email protected]:/tmp/share$ sudo /tmp/share/adb shell /storage/rfs0/pwn
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
mount: Operation not permitted
sh: can't create /system/xbin/busybox: Read-only file system
Unable to chmod /system/xbin/busybox: No such file or directory
sh: busybox: not found
cp: /system/bin/su: Read-only file system
Unable to chown /system/bin/su: No such file or directory
Unable to chmod /system/bin/su: No such file or directory
link failed Read-only file system
[+] Rooting complete!
[email protected]:/tmp/share$
Then it says: "There is no SU binary installed, and SuperSU cannot install it. This is a problem!" when opening SuperSU
PLEASE HELP HERE OR MY EMAIL! : [email protected]
Thanks in advanced
progrockguy said:
Try running the last command as simply "adb shell /storage/rfs0/pwn"
(i.e. without the prefix /tmp/share/)
Click to expand...
Click to collapse
progrockguy said:
Try running the last command as simply "adb shell /storage/rfs0/pwn"
(i.e. without the prefix /tmp/share/)
Click to expand...
Click to collapse
that worked kinda. well it says rooting complete but when i update superuser or root checker says root fail
Please Help: error: device offline
I am getting the following error
[email protected]:/tmp/share$ sudo /tmp/share/adb kill-server
[email protected]:/tmp/share$ sudo /tmp/share/adb shell /storage/rfs0/pwn
* daemon not running. starting it now on port 5037 *
* daemon started successfully *
error: device offline
[email protected]:/tmp/share$
I am running the LiveCD in VMware Workstation
Sorry for the duplicate posts
worked perfectly after i used a 32 bit live disk
jodybgoode said:
worked perfectly after i used a 32 bit live disk[/QUOTE
Did you use Ubuntu and which version?
do you have a link to the CD?
Did you boot a machine or you used VMware or Virtualbox?
Click to expand...
Click to collapse
Why would anyone even attempt to use a VM for this simple root method? You could've been rooted already if you had just followed the instructions.
Same problem here. I couldn't get past the adb kill-server command. It would tell me there is no such directory. If any one can get past this can someone please tell me what they did to get past it.
Black_halo said:
Same problem here. I couldn't get past the adb kill-server command. It would tell me there is no such directory. If any one can get past this can someone please tell me what they did to get past it.
Click to expand...
Click to collapse
I am stuck, I have tried so many machine to no luck
Please someone help
Start over and just copy and paste each single line and hit enter do not copy multiple code lines .
ATRIX HD running BATAKANG 1.10
sickkside13 said:
Start over and just copy and paste each single line and hit enter do not copy multiple code lines .
ATRIX HD running BATAKANG 1.10
Click to expand...
Click to collapse
I did, no luck
Dammz man idk what else to tell you yesterday i spend all day trying to root too but just when i was about to give up i got everything g working
ATRIX HD running BATAKANG 1.10
sickkside13 said:
Dammz man idk what else to tell you yesterday i spend all day trying to root too but just when i was about to give up i got everything g working
ATRIX HD running BATAKANG 1.10
Click to expand...
Click to collapse
hehehehe
Does the root method have anything to do with having android sdk and ndk on your system? Im thinking thats what it is now. Would i have to have linux sdk to run with terminal root or windows sdk?
Black_halo said:
Does the root method have anything to do with having android sdk and ndk on your system? Im thinking thats what it is now. Would i have to have linux sdk to run with terminal root or windows sdk?
Click to expand...
Click to collapse
No, you don't need the Android SDK/NDK, since I included a copy of ADB in the tarball file that you extracted to /tmp/share.
What's the output of "ls -l /tmp/share/adb" on your Linux machine?
I had to re-flash official JB firmware in RSD Lite before the exploit would work. Before that, the Exploit would return "Root Complete", but there was no root access (though I could su to # in adb). I run Ubuntu 12.04 x64 at work already with Windows in VirtualBox.
RSD Lite doesn't seem to want to complete a flash in the Windows VMs I run in VirtualBox at work, so I waited until I got home and used my Windows 8 Pro machine to RSD the phone with the official JB firmware. I run Ubuntu 12.04 in a VirtualBox on that machine already, so after the RSD flash, I ran the exploit from that VM - BINGO - worked on the first try.
Failing other options, you might want to try re-flashing JB in RSD Lite and running the exploit on a fresh device.
I used the firmware in this thread (To fix the issue the thread is about):
http://forum.xda-developers.com/showthread.php?t=2057078
If you decide to try that, Be SURE to get the firmware zip AND THE XML and replace the XML before flashing!!

[APP] DropBear Server II // ssh/scp (root only)

I wanted to enable SCP and SSH using DropBear II ... for some reason DropBear Server II doesn't install scp & ssh binaries, you can get them from github and symlink it into system. Here's what I did...
DropBear archive (1M): https://www.dropbox.com/s/h2guipuvdltiden/dropbearii.zip
Feel free to mirror that if you want.
These directions allow you to ssh into the system as root, be very careful. I recommend not leaving the service running if you are not using it.
I take no responsibility if you brick your unit while mucking around as root.
Back Up
Download dropbearii.zip and unzip on your local file system.
From your local filesystem install the APK and push scp & ssh to tmp.
Code:
adb install DropBearServer2.1.apk
adb push scp /data/local/tmp/scp
adb push ssh /data/local/tmp/ssh
From the OUYA GUI install the DropBearServerII service... Select Make -> Software -> DropBearServer II -> Install
Shell into your OUYA and make /system writable.
Code:
adb shell
su
mount -o rw,remount -t ext4 /dev/block/platform/sdhci-tegra.3/by-name/APP
Move scp & ssh into DropBear II directory
Code:
mv /data/local/tmp/scp /data/data/me.shkschneider.dropbearserver2/app_data/
mv /data/local/tmp/ssh /data/data/me.shkschneider.dropbearserver2/app_data/
Change the permissions
Code:
chmod 6555 /data/data/me.shkschneider.dropbearserver2/app_data/scp
chmod 6555 /data/data/me.shkschneider.dropbearserver2/app_data/ssh
Create the symlinks
Code:
cd /system/bin/
ln -s /data/data/me.shkschneider.dropbearserver2/app_data/scp ./scp
ln -s /data/data/me.shkschneider.dropbearserver2/app_data/ssh ./ssh
Change /system back to read-only (optional) and exit.
Code:
mount -o ro,remount -t ext4 /dev/block/platform/sdhci-tegra.3/by-name/APP
exit
exit
Reboot the OUYA (optional)
Code:
adb reboot
Notes/testing
Windows users can use Putty to ssh & scp get them here.
To ssh into the system:
Code:
ssh [email protected]_ADDRESS
To scp a file to the sdcard:
Code:
scp ./some_file [email protected]_ADDRESS:/sdcard/
To get to settings push the U circle button one time.
If you turn on "Start on boot" in the settings menu and reboot, the service will be turned off. Though it will be left on in the standard standby mode.
I recommend using pubkey rather than password. Basically generate a public key and push it into /sdcard/ then install it from the DropBear II app.
Unix Hosts can do:
Code:
ssh-keygen -t rsa
Windows using PuttySSH follow these directions, I haven't tested them though.
If you don't want to be bothered with pubkey, please change the default password it is set to 42.
If you already know about pubkey, you can cat them into: /data/data/me.shkschneider.dropbearserver2/app_data/authorized_keys
Unchecking "Allow Password" doesn't work properly.
Why would I want to do this? I didn't really like the Wireless ADB disappearing after the OTA upgrade, this may be less annoying if the next OTA doesn't nuke it.
I'm getting an error that busybox is not installed when trying to start the service. Is there anything special you had to do with busybox to get this to run? I installed it via the apk.
Edit: Nevermind. I didn't realize the busybox apk was an installer and I didn't find the icon when I looked. Just checked again and found the busybox installer icon and did a smart install. Dropbear ssh is running now.
I ran it manually with
Code:
dropbear -E -s -P /data/dropbear/dropbear.pid -r /data/dropbear/dropbear_rsa_host_key -d /data/dropbear/dropbear_dss_host_key
and it looks ok when idling but when connection it gives me
Aiee, segfault! You should probably report this as a bug to the developer
Click to expand...
Click to collapse
This could be CM10.1 environment issues (libc). The built-in SSHd doesn't work properly as well. Some binaries give strange errors when executed with SSHd (like sqlite3).
I can't install the DropBearServer II from the Make option, comes up with "operation failed". Tried to make the system rw to see if that might have been the problem but still no luck. Anyone else had that problem?
andlid said:
I can't install the DropBearServer II from the Make option, comes up with "operation failed". Tried to make the system rw to see if that might have been the problem but still no luck. Anyone else had that problem?
Click to expand...
Click to collapse
I installed it via adb.
For others I was able to install using IncognitoMan's -=StockPlus=- ROM -- http://forum.xda-developers.com/showthread.php?t=2347214
You may need busybox installed, I'm not 100% sure, I haven't tried without busybox.
SSH command line on android
The link is broken
Could someone please reupload this? would be awesome
Thank you so much
BIade said:
Could someone please reupload this? would be awesome
Thank you so much
Click to expand...
Click to collapse
bump - upload again please
You can also get static binaries from dropbear or ssh server apks in playstore by simply unpacking the apk.

How to change SELinuxMode to permissive in OP3T?

My OP3T is rooted running currently on OOS 4.0.
I'm unable to find etc/selinux/config folder in OP3T. Hence couldn't set the SELinuxMode to permissive.
Any help is appreciated
gopinath_shiva said:
My OP3T is rooted running currently on OOS 4.0.
I'm unable to find etc/selinux/config folder in OP3T. Hence couldn't set the SELinuxMode to permissive.
Any help is appreciated
Click to expand...
Click to collapse
https://forum.xda-developers.com/showthread.php?t=2524485
or via Terminal:
su
mount -o remount,rw /system
mkdir /system/su.d
echo "#!/system/bin/sh" > /system/su.d/permissive.sh
echo "setenforce 0" > /system/su.d/permissive.sh
echo "0" > /sys/fs/selinux/enforce
chmod 755 /system/su.d/permissive.sh
Fir3start3r said:
https://forum.xda-developers.com/showthread.php?t=2524485
or via Terminal:
su
mount -o remount,rw /system
mkdir /system/su.d
echo "#!/system/bin/sh" > /system/su.d/permissive.sh
echo "setenforce 0" > /system/su.d/permissive.sh
echo "0" > /sys/fs/selinux/enforce
chmod 755 /system/su.d/permissive.sh
Click to expand...
Click to collapse
please note that that will trigger dm-verity (if it isn't disabled already) and safetynet.
Usually when I see this question here, it's someone trying to run ViPER4Android.
If so, all you need to do is create a file like "viper4android.sh" with this inside:
Code:
#! /system/bin/sh
supolicy --live "allow audioserver audioserver_tmpfs:file { read write execute };"
Put it in /su/su.d and set the permission on that file to 0700. This will allow it to run without having to set the kernel to permissive.
Spasticdroid said:
Usually when I see this question here, it's someone trying to run ViPER4Android.
If so, all you need to do is create a file like "viper4android.sh" with this inside:
Code:
#! /system/bin/sh
supolicy --live "allow mediaserver mediaserver_tmpfs:file { read write execute };"
Put it in /su/su.d and set the permission on that file to 0700. This will allow it to run without having to set the kernel to permissive.
Click to expand...
Click to collapse
Yes you're right. I'm doing this due to issue with V4A. The thing is I am unable to install Viper Audio driver. Whenever I tried to install, I am receiving an error like "driver install failed i/o error".
I found the one of the fix to above is setting SELinuxMode to permissive. Though I tried setting SELinuxMode to permissive through terminal via setenforce 0 , its not working either.
gopinath_shiva said:
Yes you're right. I'm doing this due to issue with V4A. The thing is I am unable to install Viper Audio driver. Whenever I tried to install, I am receiving an error like "driver install failed i/o error".
I found the one of the fix to above is setting SELinuxMode to permissive. Though I tried setting SELinuxMode to permissive through terminal via setenforce 0 , its not working either.
Click to expand...
Click to collapse
http://www.theandroidsoul.com/install-viper4android-nougat/ use this tut. (SELinuxMode = permissive -> not needed)
Fir3start3r said:
http://www.theandroidsoul.com/install-viper4android-nougat/ use this tut. (SELinuxMode = permissive -> not needed)
Click to expand...
Click to collapse
Thanks to the link. I followed the tutorial. Now i got error says busybox installation found on your device doesn't work. Any thoughts
gopinath_shiva said:
Thanks to the link. I followed the tutorial. Now i got error says busybox installation found on your device doesn't work. Any thoughts
Click to expand...
Click to collapse
Flash SuperSU (2.79...) again and download Busybox from Playstore -> open the app and press install
gopinath_shiva said:
Thanks to the link. I followed the tutorial. Now i got error says busybox installation found on your device doesn't work. Any thoughts
Click to expand...
Click to collapse
If the variant of Busybox from the Play Store doesn't work, try the one by @@osm0sis here named Busybox Installer. His version has never given me any problems whatsoever on the devices I used it with, which is the Moto X Pure on Marshmallow and the OnePlus 3T on Nougat.
I've updated my original post on the su.d script. It turns out that the entry is a bit different for this phone. The correct one to use is:
Code:
#! /system/bin/sh
supolicy --live "allow audioserver audioserver_tmpfs:file { read write execute };"
You'll also might have to use FX Compatible Mode to "Compatible" in V4A, otherwise it won't always work as it should.

[WORKAROUND] - Magisk Not Installed - [Module]

I have Magisk v18.1 installed on my OG Pixel running PixelDust ROM and noticed every so often it loses root access. When entering the Magisk Manager app it also shows Magisk Not Installed. I did some investigating and found that magiskd (magisk daemon) gets terminated at some point randomly. Further testing revealed I could restart it manually by issuing "magisk --daemon" via SSH/ADB root shell.
I wrote a simple module to keep the daemon running and haven't noticed the "Magisk Not Found" error since. The module is just a simple bash script executed as service on boot that checks every minute for the daemon and runs the "magisk --daemon" command as root if not running. I am just posting it here to see if it can help anyone else who's root access disappears randomly on v17-19.3.
Please be aware that this is my first module ever. It was also originally started via an init.d script instead of the service hook in magisk, though it should work exactly the same. I have also noticed it is not possible for my module to restart magiskd yet if it was killed manually by the user.
GIt Repo:
https://github.com/Geofferey/mgkdhelper
Magisk Repo Submission:
https://github.com/Magisk-Modules-Repo/submission/issues/404
Release:
UNINSTALL INITIAL v1.0.0 RELEASE BEFORE INSTALL!!!
If you fail to do so you will have the old version and current version running at same time.
Download:
Current Release v2.1.0
Major thanks to @jcmm11 & @char101 whose contributions are now officially included in this module.
I just wanna say God bless you for this module, my man. I was frustratingly having my Magisk daemon getting killed 2-3 times a day On my LG V20. Since installing your module for the past 4 days ive yet to encounter such an issue. I greatly appreciate you coming up w/a solution to a problem that was frustrating me to the max
Geofferey said:
I wrote a simple module to keep the daemon running and haven't noticed the "Magisk Not Found" error since.
Click to expand...
Click to collapse
Thanks for that module. Very good idea and it's working perfectly fine. :good:
Hi,
There is no /data/local/run directory by default on my phone (OP6 Pie). So I suggest that either you create it first or simply uses /data/local/tmp to store the pid. Also creating the directory first might be a good idea. If you add -q to the grep command there is no need to redirect the output.
Code:
#!/system/xbin/bash
PIDFILE=/data/local/tmp/magiskd-helper.pid
LOGFILE=/data/local/tmp/magiskd-helper.log
is_magisk_running() {
ps -a | grep -q [m]agiskd
}
if [ ! -d /data/local/tmp ]; then
mkdir -p /data/local/tmp
fi
if [ -f $PIDFILE ]; then
kill -9 `cat $PIDFILE`
fi
echo $$ > $PIDFILE
RETRIES=0
while true; do
sleep 60
if ! is_magisk_running; then
echo `date` >> $LOGFILE
echo 'Magisk daemon appears to have crashed' >> $LOGFILE
echo 'Restarting magiskd...' >> $LOGFILE
/sbin/magisk --daemon
if is_magisk_running; then
echo 'Success!' >> $LOGFILE
RETRIES=0
else
echo 'Failure!' >> $LOGFILE
((++RETRIES))
if (( $RETRIES > 10 )); then
echo 'Giving up' >> $LOGFILE
break
fi
fi
echo >> $LOGFILE
fi
done
When first run, /system/bin/ps is linked to magisk builtin busybox, which don't have the -u option
Code:
ps: invalid option -- u
BusyBox v1.30.1-topjohnwu (2019-04-30 01:01:15 EDT) multi-call binary.
Usage: ps [-o COL1,COL2=HEADER] [-T]
Show list of processes
-o COL1,COL2=HEADER Select columns for display
-T Show threads
char101 said:
When first run, /system/bin/ps is linked to magisk builtin busybox, which don't have the -u option
Code:
ps: invalid option -- u
BusyBox v1.30.1-topjohnwu (2019-04-30 01:01:15 EDT) multi-call binary.
Usage: ps [-o COL1,COL2=HEADER] [-T]
Show list of processes
-o COL1,COL2=HEADER Select columns for display
-T Show threads
Click to expand...
Click to collapse
Try again after having install the 'Busybox for NDK' Magisk module (from osm0sis), maybe that the -u arg for ps command will works i ddon't remember me having testing it recently so idk if it will works but i think yeah
I have the GNU coreutils module installed so it is not the problem.
Also the original module redirect stderr to /dev/null so unless you modify it you won't see the error like I posted before.
My modifications
service.sh
Code:
#!/system/bin/sh
# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}
# This script will be executed in late_start service mode
$MODDIR/common/magisk-monitor > /data/local/tmp/magisk-monitor.log 2>&1 &
magisk-monitor
Code:
#!/system/bin/sh
is_magisk_running() {
ps -A | grep -q [m]agiskd
}
sleep 300
echo `date`
echo 'magisk-monitor running'
echo
RETRIES=0
while true; do
sleep 60
if ! is_magisk_running; then
echo `date`
echo 'Magisk daemon appears to have crashed'
echo 'Restarting magiskd...'
/sbin/magisk --daemon
if is_magisk_running; then
echo 'Success!'
RETRIES=0
else
echo 'Failure!'
((++RETRIES))
if (( $RETRIES > 10 )); then
echo 'Giving up'
break
fi
fi
echo
fi
done
Rom said:
Try again after having install the 'Busybox for NDK' Magisk module (from osm0sis), maybe that the -u arg for ps command will works i ddon't remember me having testing it recently so idk if it will works but i think yeah
Click to expand...
Click to collapse
I doubt it... From busybox.net:
ps
Report process status
Options:
-o col1,col2=header Select columns for display
-T Show threads
Click to expand...
Click to collapse
It is better to just use 'ps -A' which will work on busybox ps and coreutils ps.
Didgeridoohan said:
I doubt it... From busybox.net:
Click to expand...
Click to collapse
I'm agree with u, but it was already happen for me that some other args works too, i had never know why.
I came across your module while looking for the same issue affecting many users on different devices (although it seems to be affecting Pie only). Magisk GitHub is also full of reports by people losing root and solving with a reboot. I don't know how impactful it is on the battery since it checks for Magisk every 60 seconds (I have just installed it) but so far your module is the only blessing we can get to avoid rebooting once/twice per day. I think you should definitely submit your module to the official repository!
P.s i had to create /data/local/run first for the pid
@Geoffrey another quick correction: in my case on MIUI 10 based on Pie, ps -a does not show the same output as ps -A. So I had to replace the -a in your script with an upper case A.
char101 said:
It is better to just use 'ps -A' which will work on busybox ps and coreutils ps.
Click to expand...
Click to collapse
Coreutils doesn't have a ps applet. If you want to use -u just use the full path /system/bin/ps to force the toybox applet.
@Geoffrey
First of all nice workaround. I did some cleanup and a few modifications if you want to post it to the Magisk repository (and I think you should).
Changed over to the current template.
Removed all the PID stuff, it's really not needed.
Replaced ps -a -u with pgrep. That eliminates any busybox vs toybox issues (at least the way it's being used here)
Removed bash. There's nothing here that requires a bash shell as opposed to the default shell.
Moved the script to it's own directory instead of xbin. Not all phones have xbin, and trying to use it on those that don't is problematic. Plus there's no reason the script needs to be in the PATH.
Added nohup to the script startup command in service.sh
Also always create the log file, with a "started on" line in it. That at least gives an indication that the script started.
So what we're left with.
mgkd-helper (in a script directory)
Code:
#!/system/bin/sh
LOGFILE=/data/local/tmp/magiskd-helper.log
rm -f $LOGFILE
echo "Started " $(date) >> $LOGFILE
echo "-----------------------------" >> $LOGFILE
echo >> $LOGFILE
while true; do
sleep 60
if ! pgrep magiskd >/dev/null; then
echo $(date) >> $LOGFILE
echo "Magisk daemon appears to have crashed" >> $LOGFILE
echo "Restarting magiskd..." >> $LOGFILE
if magisk --daemon; then
echo "success!" >> $LOGFILE
else
echo "failure!" >> $LOGFILE
fi
echo >> $LOGFILE
fi
done
service.sh
Code:
#!/system/bin/sh
# Do NOT assume where your module will be located.
# ALWAYS use $MODDIR if you need to know where this script
# and module is placed.
# This will make sure your module will still work
# if Magisk change its mount point in the future
MODDIR=${0%/*}
# This script will be executed in late_start service mode
#Magisk Daemon Helper
# Copyright (C) 2019 Geofferey @ XDA
# License: GPL V3+
nohup $MODDIR/script/mgkd-helper > /dev/null &
If you do decide to place it in the repository you need to do something with README.md
You should also replace META-INF/com/google/android/update-binary with the attached version. The included version is for standalone installs. Repository versions should use the alternate one. (Remove the ".txt")
Last note: tested this and it does work. I killed the running magiskd and a new one was started, with the appropriate log entry created
I wasn't able to start magiskd with "magisk -- daemon" via adb. It always says "No daemon found" instead of starting it. I seem to have lost root with the original script and I had to restart again. Any idea? I just enabled root via adb in Magisk. Not sure if that was the issue that I couldn't restart it.
And it seems like magiskd is killed in OxygenOS 9.0.5 on my OnePlus 6. Not sure if it is due to out of memory reasons but I can't get any logcat as I don't have root. Super annoying.
Will this be added to the magisk module repository? If it is there I couldn't find it. I do know there are links and a revision at the end of the thread by @jcmm11. I don't need the module, just curious if the revision will be put there eventually. I have had others with that problem that I have helped.
Thanks
martyfender said:
Will this be added to the magisk module repository? If it is there I couldn't find it. I do know there are links and a revision at the end of the thread by @jcmm11. I don't need the module, just curious if the revision will be put there eventually. I have had others with that problem that I have helped.
Thanks
Click to expand...
Click to collapse
I think it should be but it's up to @Geoffrey. It's his module. I cleaned it up a bit that's all. Most of the work is done. Biggest thing left to do is modify README.md
jcmm11 said:
@Geoffrey
First of all nice workaround. I did some cleanup and a few modifications if you want to post it to the Magisk repository (and I think you should).
Changed over to the current template.
Removed all the PID stuff, it's really not needed.
Replaced ps -a -u with pgrep. That eliminates any busybox vs toybox issues (at least the way it's being used here)
Removed bash. There's nothing here that requires a bash shell as opposed to the default shell.
Moved the script to it's own directory instead of xbin. Not all phones have xbin, and trying to use it on those that don't is problematic. Plus there's no reason the script needs to be in the PATH.
Added nohup to the script startup command in service.sh
Also always create the log file, with a "started on" line in it. That at least gives an indication that the script started.
So what we're left with.
mgkd-helper (in a script directory)
service.sh
If you do decide to place it in the repository you need to do something with README.md
You should also replace META-INF/com/google/android/update-binary with the attached version. The included version is for standalone installs. Repository versions should use the alternate one. (Remove the ".txt")
Last note: tested this and it does work. I killed the running magiskd and a new one was started, with the appropriate log entry created
Click to expand...
Click to collapse
Should we directly flash zip in twrp recovery
kryshnakishore said:
Should we directly flash zip in twrp recovery
Click to expand...
Click to collapse
You can flash it in recovery or via Magisk Manager, modules section, big + button at bottom of screen.
I've been looking for a solution to this since v17 ... started happening on 17, kept happening on 18, is even worse now on v19 ... :-/

Categories

Resources