I have a script for MobileTerminal in iOS that requires su, is there any way I can add a command to the bash script to login as root without having to type su then the password?
Cheers,
Dec
SUDO and system functions are disallowed in iOS, they violate sandboxing and security.
That's the solution worked for me:
SSH to your iPhone
$ssh root@<your iphone ip>
Password: alpine //no echo
and run
iPhone:~ root# visudo
add right after
root ALL=(ALL) ALL
this line (varies of what you want)
mobile ALL=(ALL) ALL
sudo
. For editing with visudo
you should use controls like in vi
After all add to your script hardcoded sudo
call like this
#!/bin/bash
sudo -S -p "" echo -n "" <<!
alpine
!
sudo echo "This line is printed as root"
Now explanation:
-S
allows reading password from <<!\n ... \n!
block, it should be printed on a single line-p ""
suppresses password promt, so the line Password:
is not printedecho -n
disallows a newline character in the endSo you can sudo
in your script without any password promt. The only thing - in this method password is hardcoded. But you can try command line arguments like $1 (not tested, just an idea)