Because of the Thanksgiving holiday in the U.S., TI E2E design support forum responses may be delayed the week of Nov. 21. Thank you for your patience.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Beagleboard application root privileges with Runtime.getRuntime().exec()

I'm running JB 4.1.2 on  a BeagleBoard-xM but i can't run any root command using Runtime.getRuntime().exec().
I've tried anything but i got:

java.io.IOException: Error running exec(). Command: [echo] Working Directory: null Environment: null

With original /system/xbin/su command, or at least

Permission Denied or no output replacing original "su" command with a custom one (taken from SuperSu or SuperUser application, ARM build).

I've also tried to change "su" command group and permission and running application as a system app.
I've tried any command like "sh -c" "su -c" or libsuperuser (from chainfire) or also using a custom JNI lib that invoke system("su...");
Nothing change, no luck.

su command only works by terminal or through adb shell.

I need to run some echo command to use board leds from my application, how can solve it?

Thanks

  • I'm having the same issue since I'm trying to exec shell comands that requireroot access. Let me know if you found a workaroumd.

  • The following discussion in the rowboat forum may be of help:

    https://groups.google.com/d/topic/rowboat/GYhu3mUSYsI/discussion

  • Thanks, problem solved. The cause of the issue is that the /system/xbin/su bin does not allow the app root permission, only console user is allowed to execute as root. The solution is to modify su bin.

    1. Download Superuser package from git. I used https://github.com/koush/Superuser.

    2. You need to install Google NDK package

    3. Modify jni/su/su.c using the following code

    4. Build using ndk-build (you don't need to build the apk, unless you want the dialog from the Superuser app to ask for root permissions).

    5. Install the su bin libs/armeaabi in /system/bin (or replace the su in /system/xbin).

    6. Invoke su in your app using /system/bin/su.

    =============Code for su.c ======================
    #include "utils.h"

    static int permissionDenied()
    {
            printf("su: permission denied\n");
            return 1;
    }

    static int executionFailure(char *context)
    {
            fprintf(stderr, "su: %s. Error:%s\n", context, strerror(errno));
            return -errno;

    }

    int main(int argc, char *argv[])
    {
            if(setgid(0) || setuid(0))
                    return permissionDenied();
             
            char *exec_args[argc + 1];
            exec_args[argc] = NULL;
            exec_args[0] = "sh";
            int i;
            for (i = 1; i < argc; i++)
            {
                    exec_args[i] = argv[i];
            }
            execv("/system/bin/sh", exec_args);
            return executionFailure("sh");
    }

  • Hi
    Can you please send me the recompiled SU binaries please. I dont have a much knowledge in using NDK can you please send me the modified file please.