:::BRIEF DESCRIPTION:::
mksh is the official, currently-developed shell used for android. It is not an app nor a virus (lol) like some people seem to think, looking at a quick xda search. And as the core shell for android, it is used to shell superuser, so if you're rooted and get a message saying "mksh requests root", that basically just means that superuser is being run correctly and is using the default Android shell that is in every android device. (GOOD)
If you get a message saying bash(or any other shell) requested root, and you're NOT in the terminal interactively. That most likely is NOT GOOD! Almost all bash scripts I've seen will run shelled with mksh, so be safe and schebang with mksh. You'll have better performance and features, and when you see bash requesting root, you'll know your security is compromised, instead of sitting there wandering whether to allow/block it.
::: mksh Resources/links :::
mirbsd mksh main page: https://www.mirbsd.org/mksh.htm
mksh man page: https://www.mirbsd.org/htman/i386/man1/mksh.htm
Now that that's out of the way, I've attached a recovery flash zip to this post containing a full mksh(R48 August 2013 from CFX ROM), full mkshrc modded for android, bunch of fpath functions like a much needed basic sudo, parallel sudo(sexe), required libc.so and libc_malloc*.so libs, and alternate busybox.ndk and standalone grep bins. The mksh binary was compiled with O3 or O4 aliasing, Clanged CodeSourcery toolchain by CFX I believe. It's very stable.
(Installer uses a modded version of Chainfire's great no-edify script.)
Features scripted into mkshrc:
--sudo: auto detects supersu for mount master (highly recommended) or CWM su
e.g.:
sudo cat <<< $'\n' >> /system/build.prop
sudo 'for i=(0 2000); do echo $i{[]}; done'
--suid: (set user id) Uses chpst to run a prog setsuid, this is broken in most busyboxes, and it's needed as much or even more than a sudo.
e.g.: suid 1000 sh
--Better tab completion: unjams clustered words, so ec[cursor]12345 + tab ---> echo 12345
--TMPDIR: mounts a tmpdir at /tmp for all users and random generates subdirs for individual secured tmpdirs. This fixes here-docs, here-strings, and here-executions. To get a /tmp directory mounted, you need to run su once upon booting android. Just type "ss".
e.g.:
su << 'eeooff'
sysrw; chgrp 2000 /system/bin; sysro
! (( $? )) && print -- -changed them bin group-
eeooff
--Basic "help" command: Android lacks this and the doc is still under development I believe. I added all the basic info(cmd forms) for mksh bultins to a command help(aliased to h):
e.g.:
$ help mkn
> mknod [-m mode] name b|c major minor
> mknod [-m mode] name p
h ''
(all help is printed, grep from here if you want)
--Very complicated and colorful PS1 prompt, it looks good and I thought it through. It auto-turns off xtrace within itself so that 50 lines don't get printed each return with set -x.
--ton of ultra lazy aliases, got my android scripting speed up to ~70% my normal pc speed.
--full mkshrc functions like pulld,popd,dirs,more,hd,64encode,64decode,hashopti mizations
The latest full R49 source with original mkshrc and complete mksh manual is completed. It'll be installed to /system/etc/mksh...zip and /system/etc/mksh...pdf. I use Document Viewer from fdroid to view it.
The scripting in this is very sophisticated and complex, especially the inherent full mkshrc functions. It would make a good scripting learning tool to say the least. I know I've learned twice what I knew from bash scripting back 3 months ago.
I've been working on modding the full mkshrc a while, so I appreciate any error reports. Shouldn't be any problems though.
Modifying the mkshrc file / mksh shell has system-wide effects, so PLEASE nandroid backup as usual!!! This should be COMPATIBLE with all androids, but has only been tested on my Galaxy Nexus thus far.
mksh is the official, currently-developed shell used for android. It is not an app nor a virus (lol) like some people seem to think, looking at a quick xda search. And as the core shell for android, it is used to shell superuser, so if you're rooted and get a message saying "mksh requests root", that basically just means that superuser is being run correctly and is using the default Android shell that is in every android device. (GOOD)
If you get a message saying bash(or any other shell) requested root, and you're NOT in the terminal interactively. That most likely is NOT GOOD! Almost all bash scripts I've seen will run shelled with mksh, so be safe and schebang with mksh. You'll have better performance and features, and when you see bash requesting root, you'll know your security is compromised, instead of sitting there wandering whether to allow/block it.
::: mksh Resources/links :::
mirbsd mksh main page: https://www.mirbsd.org/mksh.htm
mksh man page: https://www.mirbsd.org/htman/i386/man1/mksh.htm
Now that that's out of the way, I've attached a recovery flash zip to this post containing a full mksh(R48 August 2013 from CFX ROM), full mkshrc modded for android, bunch of fpath functions like a much needed basic sudo, parallel sudo(sexe), required libc.so and libc_malloc*.so libs, and alternate busybox.ndk and standalone grep bins. The mksh binary was compiled with O3 or O4 aliasing, Clanged CodeSourcery toolchain by CFX I believe. It's very stable.
(Installer uses a modded version of Chainfire's great no-edify script.)
Features scripted into mkshrc:
--sudo: auto detects supersu for mount master (highly recommended) or CWM su
e.g.:
sudo cat <<< $'\n' >> /system/build.prop
sudo 'for i=(0 2000); do echo $i{[]}; done'
--suid: (set user id) Uses chpst to run a prog setsuid, this is broken in most busyboxes, and it's needed as much or even more than a sudo.
e.g.: suid 1000 sh
--Better tab completion: unjams clustered words, so ec[cursor]12345 + tab ---> echo 12345
--TMPDIR: mounts a tmpdir at /tmp for all users and random generates subdirs for individual secured tmpdirs. This fixes here-docs, here-strings, and here-executions. To get a /tmp directory mounted, you need to run su once upon booting android. Just type "ss".
e.g.:
su << 'eeooff'
sysrw; chgrp 2000 /system/bin; sysro
! (( $? )) && print -- -changed them bin group-
eeooff
--Basic "help" command: Android lacks this and the doc is still under development I believe. I added all the basic info(cmd forms) for mksh bultins to a command help(aliased to h):
e.g.:
$ help mkn
> mknod [-m mode] name b|c major minor
> mknod [-m mode] name p
h ''
(all help is printed, grep from here if you want)
--Very complicated and colorful PS1 prompt, it looks good and I thought it through. It auto-turns off xtrace within itself so that 50 lines don't get printed each return with set -x.
--ton of ultra lazy aliases, got my android scripting speed up to ~70% my normal pc speed.
--full mkshrc functions like pulld,popd,dirs,more,hd,64encode,64decode,hashopti mizations
The latest full R49 source with original mkshrc and complete mksh manual is completed. It'll be installed to /system/etc/mksh...zip and /system/etc/mksh...pdf. I use Document Viewer from fdroid to view it.
The scripting in this is very sophisticated and complex, especially the inherent full mkshrc functions. It would make a good scripting learning tool to say the least. I know I've learned twice what I knew from bash scripting back 3 months ago.
I've been working on modding the full mkshrc a while, so I appreciate any error reports. Shouldn't be any problems though.
Modifying the mkshrc file / mksh shell has system-wide effects, so PLEASE nandroid backup as usual!!! This should be COMPATIBLE with all androids, but has only been tested on my Galaxy Nexus thus far.