Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Couldn't switch context on official L #25

Closed
thuantran opened this issue Nov 14, 2014 · 11 comments
Closed

Couldn't switch context on official L #25

thuantran opened this issue Nov 14, 2014 · 11 comments

Comments

@thuantran
Copy link

Hi there,

I'm using the current latest stable version of roottools and I can't switch context using this code:

RootTools.getShell(true, ShellContext.UNTRUSTED_APP).add(cc);

Regardless what ShellContext constant I use, I still only get the normal init context as the output of id is like this: uid=0(root) gid=0(root) context=u:r:init:s0

I tested this on Nexus 5 with CFAR and latest SuperSU with LPX21O.

@Stericson
Copy link
Owner

Can you provide The code you are using and logs from adb with RootTools.debug = true?

@thuantran
Copy link
Author

Here's the code I use roottools to run command

    public static String shellExec(String workingDir, Integer timeout,
            String... commands) {
        if (Looper.myLooper() == Looper.getMainLooper()) {
            Logcat.e("Warning execute commands on main thread\n"
                    + Arrays.toString(commands));
        }
        try {
            if (workingDir != null) {
                String[] tmp = new String[commands.length + 1];
                tmp[0] = "cd \"" + workingDir + "\"";
                System.arraycopy(commands, 0, tmp, 1, commands.length);
                commands = tmp;
            }

            final StringBuilder sb = new StringBuilder(4096);

            CommandCapture cc = new CommandCapture(0, timeout == null ? 5000
                    : timeout, commands) {
                @Override
                public void commandOutput(int id, String line) {
                    sb.append("\n").append(line);
                }
            };

            RootTools.getShell(true, ShellContext.UNTRUSTED_APP).add(cc);
            synchronized (cc) {
                try {
                    cc.wait();
                } catch (InterruptedException e) {
                }
            }
            return sb.length() > 0 ? sb.substring(1) : "";
        } catch (Exception e) {
            Logcat.e("Error execute command\n" + Arrays.toString(commands), e);
            return "";
        }
    }

And here's the relavant adb log:

11-14 11:20:11.230: D/TricksterMOD(15823): Result 0
11-14 11:20:11.323: D/OpenGLRenderer(15823): Render dirty regions requested: true
11-14 11:20:11.328: D/Atlas(15823): Validating map...
11-14 11:20:11.335: D/TricksterMOD(15823): Start checking status
11-14 11:20:11.349: D/TricksterMOD(15823): Result 0
11-14 11:20:11.364: D/RootTools v3.5(15823): Checking for Root access
11-14 11:20:11.365: D/RootTools v3.5(15823): CommandHandler not created
11-14 11:20:11.365: D/RootTools v3.5(15823): Starting Root Shell!
11-14 11:20:11.366: D/RootTools v3.5(15823): Starting shell: su
11-14 11:20:11.366: D/RootTools v3.5(15823): Context: normal
11-14 11:20:11.366: D/RootTools v3.5(15823): Timeout: 0
11-14 11:20:11.394: I/Adreno-EGL(15823): <qeglDrvAPI_eglInitialize:410>: QUALCOMM Build: 10/24/14, 167c270, I68fa98814b
11-14 11:20:11.395: I/OpenGLRenderer(15823): Initialized EGL, version 1.4
11-14 11:20:11.408: D/OpenGLRenderer(15823): Enabling debug mode 0
11-14 11:20:17.013: D/RootTools v3.5(15823): Using Existing Root Shell!
11-14 11:20:17.013: D/RootTools v3.5(15823): Command is in position 0 currently executing command at position 0 and the number of commands is 1
11-14 11:20:17.202: D/RootTools v3.5(15823): Executing: id
11-14 11:20:17.233: D/RootTools v3.5(15823): context=u:r:init:s0
11-14 11:20:17.233: D/RootTools v3.5(15823): uid=0(root)
11-14 11:20:17.233: D/RootTools v3.5(15823): Access Given
11-14 11:20:17.245: D/RootTools v3.5(15823): Command 2 finished.
11-14 11:20:17.246: D/TricksterMOD(15823): ============checkShell============
11-14 11:20:17.248: D/RootTools v3.5(15823): CommandHandler not created
11-14 11:20:17.248: D/RootTools v3.5(15823): Using Existing Root Shell!
11-14 11:20:17.280: D/RootTools v3.5(15823): Executing: echo ${KSH_VERSION}${BASH_VERSION}
11-14 11:20:17.280: D/RootTools v3.5(15823): id
11-14 11:20:17.303: D/RootTools v3.5(15823): Command 0 finished.
11-14 11:20:17.306: D/TricksterMOD(15823): SHELL VERSION @(#)MIRBSD KSH R48 2013/08/14
11-14 11:20:17.306: D/TricksterMOD(15823): uid=0(root) gid=0(root) context=u:r:init:s0

@ulligan
Copy link

ulligan commented Nov 19, 2014

uid=0(root) gid=0(root) context=u:r:init:s0

@thuantran
Copy link
Author

Is there any news on this Stericson?

@Stericson
Copy link
Owner

Hi Thuantran,

I'm planning to look at this today. I'm sorry, I've been swamped with work...

@Stericson
Copy link
Owner

Hey guys,

I think I fixed the issue, looks like it was a problem with ProcessBuilder.

Can you guys try this version out?

https://drive.google.com/file/d/0B5Amguus3csDQW1zV04waEhXNkE/view?usp=sharing

Also, I noticed a bug that may have been slowing the shell down, so I addressed that as well which may or may not speed up the shell (depending on use)

@thuantran
Copy link
Author

Sorry but I can't use the jar, it throws out this error

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dx.cf.iface.ParseException: bad class file magic (cafebabe) or version (0034.0000)
    at com.android.dx.cf.direct.DirectClassFile.parse0(DirectClassFile.java:472)
    at com.android.dx.cf.direct.DirectClassFile.parse(DirectClassFile.java:406)
    at com.android.dx.cf.direct.DirectClassFile.parseToInterfacesIfNecessary(DirectClassFile.java:388)
    at com.android.dx.cf.direct.DirectClassFile.getMagic(DirectClassFile.java:251)
    at com.android.dx.command.dexer.Main.processClass(Main.java:665)
    at com.android.dx.command.dexer.Main.processFileBytes(Main.java:634)
    at com.android.dx.command.dexer.Main.access$600(Main.java:78)
    at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:572)
    at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:284)
    at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:166)
    at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:144)
    at com.android.dx.command.dexer.Main.processOne(Main.java:596)
    at com.android.dx.command.dexer.Main.processAllFiles(Main.java:498)
    at com.android.dx.command.dexer.Main.runMonoDex(Main.java:264)
    at com.android.dx.command.dexer.Main.run(Main.java:230)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    at com.android.ide.eclipse.adt.internal.build.DexWrapper.run(DexWrapper.java:188)
    at com.android.ide.eclipse.adt.internal.build.BuildHelper.executeDx(BuildHelper.java:786)
    at com.android.ide.eclipse.adt.internal.build.builders.PostCompilerBuilder.build(PostCompilerBuilder.java:597)
    at org.eclipse.core.internal.events.BuildManager$2.run(BuildManager.java:734)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:206)
    at org.eclipse.core.internal.events.BuildManager.basicBuild(BuildManager.java:328)
    at org.eclipse.core.internal.events.BuildManager.build(BuildManager.java:403)
    at org.eclipse.core.internal.resources.Project$1.run(Project.java:618)
    at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:2313)
    at org.eclipse.core.internal.resources.Project.internalBuild(Project.java:597)
    at org.eclipse.core.internal.resources.Project.build(Project.java:124)
    at com.android.ide.eclipse.adt.internal.project.ProjectHelper.doFullIncrementalDebugBuild(ProjectHelper.java:1143)
    at com.android.ide.eclipse.adt.internal.launch.LaunchConfigDelegate.launch(LaunchConfigDelegate.java:155)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:885)
    at org.eclipse.debug.internal.core.LaunchConfiguration.launch(LaunchConfiguration.java:739)
    at org.eclipse.debug.internal.ui.DebugUIPlugin.buildAndLaunch(DebugUIPlugin.java:1039)
    at org.eclipse.debug.internal.ui.DebugUIPlugin$8.run(DebugUIPlugin.java:1256)
    at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
...while parsing com/stericson/RootTools/BuildConfig.class

[2014-11-27 09:49:06 - Trickster MOD] Dx 1 error; aborting

@Stericson
Copy link
Owner

I've updated the jar, can you use it now?

https://drive.google.com/file/d/0B5Amguus3csDQW1zV04waEhXNkE/view?usp=sharing

@thuantran
Copy link
Author

Still the same problem even in Android Studio as I moved my projects over. I also tried your new RootShell same issue with the jar. I will report this issue there and will double check this SELinux with plain library source until you have this fixed.

@thuantran
Copy link
Author

The context switching issue seems to be fixed in RootShell for me, thanks.

I don't know why but you've "blow out" your code in RootShell project so in the mean time I will report stuffs regarding the jar issue here until further notice.

@Stericson
Copy link
Owner

Thanks!

yea, sorry about that. I was working on it...I'm horrible at commit messages.

I've pushed everything back in. So you should see all of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants