shell root permissions (run executable c++ from shell)

132 views
Skip to first unread message

Lukas Adamec

unread,
Sep 8, 2010, 11:11:44 AM9/8/10
to android-ndk
Hello,
I need to run executable c++ code (compiled with crystax NDK ndk-build
tool) from shell on device. Is there any possibility to do it? There
is no problem to run application on emulator, but on device I probably
don't have sufficient permissions. Is there any way to delegate
permissions or other possibility to run executable file from shell?

Thanks a lot.

Lukas

Chris Stratton

unread,
Sep 8, 2010, 12:09:01 PM9/8/10
to android-ndk
It can be done, as long as what the executable wants to do does not
require root permissions.

You need to find a location that is not mounted noexec, and to which
you can adb push it. If this is a temporary experiment many have used
the /sqlite_stmt_journals directory, which is a ramdisk of sorts.

A more "supported" approach would be to compile your executable as a
jni library - which could be as simple as tacking the hello-jni
example code onto the end of it and adding a call to your main() into
the example's jni function.

Lukas Adamec

unread,
Sep 9, 2010, 4:46:52 AM9/9/10
to android-ndk
Thanks for advise, it's work good.

Dianne Hackborn

unread,
Sep 9, 2010, 12:39:21 PM9/9/10
to andro...@googlegroups.com
Please don't do this in production code -- /sqlite_stmt_journals is not part of the so not guaranteed to exist, and I believe that you can have security issues using this approach.

--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.




--
Dianne Hackborn
Android framework engineer
hac...@android.com

Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails.  All such questions should be posted on public forums, where I and others can see and answer them.

Reply all
Reply to author
Forward
0 new messages