koush / Superuser

Other
1.48k stars 999 forks source link

New superuser/CM screws sdcard path detection up #189

Open ldt116 opened 11 years ago

ldt116 commented 11 years ago

Hi there,

Recently I have got users reported to me that my app failed to write to sdcard from root process. Turn out that there are changes in su/CM that rendered the hack I did for Android 4.3 and your Superuser obsolete (specifically I tested 20130923 build). The code for this hack is like this:

    public static final String getSdPath() {
        String path = Environment.getExternalStorageDirectory().getPath();
        if (Build.VERSION.SDK_INT > 17 && path.startsWith("/storage/emulated")) {
            path = "/storage/emulated/legacy";
        }
        return path;
    }

The reason that this hack does not work is because /storage/emulated/legacy now empty and sdcard path moves back to Environment.getExternalStorageDirectory().getPath() like it should. I can remove this hack and it works like normal for both Superuser on the new CM and SuperSU. The problem is it does not work for the current Superuser on Play Store. What should I do now? Working around this from my side is rather ugly unless I miss something.

P.S. This problem happens with other app, too. According to one of the users who reported it: "I discovered similar problems with other apps. francos kernel updater was also unable to save the kernel and googles play music refuses the download. Also funny is Titaniums behaviour ... after each reboot i have to switch the backup location between emulated/0 and emulated/legacy - otherwise it reports "no space left on device" when trying to save anything."

ldt116 commented 11 years ago

I don't know where the incompatibility between superuser on Play Store and on latest CM nightlies began but if possible, koush, please update your superuser on Play Store so root app has the same mount view on both.

In the case of that breaking any app they can simply update, remove the hack (like the one I had), and tell users to update their superuser too.

The current situation required me to write a new hack method that works for all 3 possibility of root implementations, SuperSU, Superuser on Play Store and Superuser on latest CM nightlies. This method requires me to descend to root shell to detect the path correctly which if done right should be done in a background thread. The whole thing is ugly that I rather not have to deal with.

koush commented 11 years ago

I'll push an update soon.

koush commented 11 years ago

This change: http://review.cyanogenmod.org/#/c/50535/1/Superuser/jni/su/daemon.c,unified

d4rken commented 10 years ago

Has this change been committed yet? I've got reports that this still happens on latest Nexus 5/7(2013) CM nightly.

d4rken commented 10 years ago

I see the issue on my Nexus7(grouper) with latest CM11 nightly (11-20131208-NIGHTLY-grouper). The primary external storage location returned by http://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory() which is "/storage/emulated/0" is not available from a root shell launched from an app. With root: cm11_n7_with_root Without root: cm11_n7_without_root

Let me know if you need anything else.

koush commented 10 years ago

I'll give this a shot on my n7. Which n7, the new one or old one?

d4rken commented 10 years ago

The old one, but i don't think it is device specific. Thanks for looking into it.

mcl21014 commented 10 years ago

Koush, it isn't device specific. Happened on my 2013 Nexus 7, and d4rken's 2012 model.

d4rken commented 10 years ago

@koush could you reproduce the issue?

d4rken commented 10 years ago

I've created a sepperate ticket for this as the current issue is slightly different from the OPs ticket. https://github.com/koush/Superuser/issues/218