SuperUser apk

2,612 views
Skip to first unread message

Shagan

unread,
Jun 28, 2012, 4:16:26 PM6/28/12
to panda...@googlegroups.com

Hi Guys, 

I could login via adb shell to my pandaboard running android, and i get the root shell. 
But i am not able to run commands as "su" from my application. 

String[] cmds = {"rm /mnt/sdcard/touch.txt"};

Process p = Runtime.getRuntime().exec("su"); < hangs here > 

            DataOutputStream os = new DataOutputStream(p.getOutputStream());            

            for (String tmpCmd : cmds) {

                    os.writeBytes(tmpCmd+"\n");

            }           

            os.writeBytes("exit\n");  

            os.flush();


I tried installing SuperUser apk, but it also threw error :

D/Su.UpdaterFragment( 4169): /system/bin/busybox touch /data/sutest && /system/bin/busybox echo YEAH 

E/Su.UpdaterFragment( 4169): Failed to execute root commands

E/Su.UpdaterFragment( 4169): java.io.IOException: write failed: EPIPE (Broken pipe)

E/Su.UpdaterFragment( 4169): at libcore.io.IoBridge.write(IoBridge.java:452)

E/Su.UpdaterFragment( 4169): at java.io.FileOutputStream.write(FileOutputStream.java:187)

E/Su.UpdaterFragment( 4169): at java.io.OutputStream.write(OutputStream.java:82)

E/Su.UpdaterFragment( 4169): at java.io.DataOutputStream.writeBytes(DataOutputStream.java:156)

E/Su.UpdaterFragment( 4169): at com.noshufou.android.su.UpdaterFragment.executeCommand(UpdaterFragment.java:795)

Running as su is really important for my application. Any help how to get thru this ? 

thanks
Shankar

Tom Mitchell

unread,
Jun 28, 2012, 5:38:54 PM6/28/12
to panda...@googlegroups.com
Start with some informative commands without using "su".
Try "id".  You stated you had root already but I cannot verify.
"su" commonly expects a password if you are not root.  The hang could be
a TTY expecting I/O. 

 Next inspect the permissions of the file and the dir it is in.

I know that android does not allow "su" to any user under normal conditions
from byte code.  Also use full pathnames for all commands.  I would also 
expect "su" followed by a command string or stream.  Look at a man page and 
the info pages for su.  I very much doubt that you need "su", you may wish access 
to more shell commands which does not need a privledge escalation.
--
  T o m   M i t c h e l l

Shagan

unread,
Jun 28, 2012, 9:38:23 PM6/28/12
to panda...@googlegroups.com
Thanks Tom. 

Via adb shell i could login as root 

root@android:/ # id

uid=0(root) gid=0(root)


Also, from my application, result of running id command is

06-29 01:19:24.901: D/USBStorageActivity(1246): uid=10043(app_43) gid=10043(app_43) groups=1015(sdcard_rw)

But when i try to run su command, 

Process process = Runtime.getRuntime().exec("/system/xbin/su");

BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

Log.d(TAG,bufferedReader.readLine());

readline throws null pointer exception. 

Also from the command line, i could see that my app can never become su either.

root@android:/ # su app_43

root@android:/ $ su

su: uid 10043 not allowed to su


But my question is, what difference is the difference between rooting the device and root shell available via adb ? 

My SuperUser app does not even list any attempts from my app to get su access. 

-- Shankar

Tom Mitchell

unread,
Jun 28, 2012, 10:00:28 PM6/28/12
to panda...@googlegroups.com
When "id" tells you you are not "root" you are seeing one
of the security models in action. Linux/Unix/Android have the
notion of real and effective user ID. The dalvik/java world runs
with reduced permissions and is not permitted to run with
more permissions as you are seeing.

I am not sure what "rooting" a device does beyond giving
you access to change things that are commonly restricted.

I see a hint in that "su" is checking to see that you are allowed or not.
I would have you look deeper to see where that list of permissions
is established and how you might change it.

Also look for "sudo" sudo gives much more flexibility for enabling
objects to run in a context that matches you need. You may
be able to install "sudo" on a rooted device and establish a framework
that gets the job done.
Reply all
Reply to author
Forward
0 new messages