phhusson / Superuser

Keeping koush's Superuser fresh
GNU General Public License v3.0
426 stars 50 forks source link

Why I get IOException: Permission denied When My apk quest su? #39

Open flyuuo9 opened 8 years ago

flyuuo9 commented 8 years ago

My phone is HUAWEI HONOR 4A 5.1.1

0. push SuperUser apk(com.koushikdutta.superuser) to /system/app, and reboot phone(HUAWEI HONOR 4A 5.1.1)

1. run su --daemon under root (after this, adb shell, exe su I can get "#")

2. but when exe su in my test apk(com.example.suTest), SuperUser apk's question dialog did not show, my test apk code as this:


if (exec("su", "id").contains("uid=0")) {
//root
}
    public static String exec(String su, String cmd) {
        DataOutputStream dos = null;
        BufferedReader bf = null;
        try {
            java.lang.Process process = Runtime.getRuntime().exec(su);
            dos = new DataOutputStream(process.getOutputStream());
            bf = new BufferedReader(new InputStreamReader(process.getInputStream()));
            dos.writeBytes(cmd + "\n");
            dos.writeBytes("exit\n");
            StringBuilder builder = new StringBuilder();
            String tmp;
            while ((tmp = bf.readLine()) != null) {
                Log.i(TAG, "exec tmp: " + tmp);
                builder.append(tmp);
            }
            dos.flush();
            String ret =  builder.toString();
            return ret;
        } catch (IOException e) {
            Log.e(TAG, "", e);
        } finally {
            close(dos);
            close(bf);
        }
        return "";
    }

I tried several times, so the log time maybe not match

SuperUser apk log:

03-10 21:47:36.114 V/ActivityThread(28244): ActivityThread,callActivityOnCreate
03-10 21:47:36.124 D/CubicBezierInterpolator(28244): CubicBezierInterpolator  mControlPoint1x = 0.2, mControlPoint1y = 0.65, mControlPoint2x = 0.28, mControlPoint2y = 0.97
03-10 21:47:36.124 D/CubicBezierInterpolator(28244): CubicBezierInterpolator  mControlPoint1x = 0.2, mControlPoint1y = 0.65, mControlPoint2x = 0.28, mControlPoint2y = 0.97
03-10 21:47:36.134 D/CubicBezierInterpolator(28244): CubicBezierInterpolator  mControlPoint1x = 0.2, mControlPoint1y = 0.65, mControlPoint2x = 0.28, mControlPoint2y = 0.97
03-10 21:47:36.134 D/CubicBezierInterpolator(28244): CubicBezierInterpolator  mControlPoint1x = 0.2, mControlPoint1y = 0.65, mControlPoint2x = 0.28, mControlPoint2y = 0.97
03-10 21:47:36.134 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.134 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.134 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.134 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.134 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.134 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.134 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.134 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.134 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.134 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.144 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.144 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.144 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.144 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.174 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.174 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.174 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.184 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.184 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.184 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.184 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.184 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.184 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.184 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.194 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.194 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.194 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.194 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.194 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.194 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.194 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.194 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.204 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.204 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.204 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.204 E/ZipFileCache(28244): init failed when open zip file.
03-10 21:47:36.214 I/Superuser(28244): Permission denied
03-10 21:47:36.214 I/Superuser(28244): java.io.IOException: Permission denied
03-10 21:47:36.214 I/Superuser(28244):  at android.net.LocalSocketImpl.connectLocal(Native Method)
03-10 21:47:36.214 I/Superuser(28244):  at android.net.LocalSocketImpl.connect(LocalSocketImpl.java:293)
03-10 21:47:36.214 I/Superuser(28244):  at android.net.LocalSocket.connect(LocalSocket.java:130)
03-10 21:47:36.214 I/Superuser(28244):  at com.koushikdutta.superuser.MultitaskSuRequestActivity$7.run(MultitaskSuRequestActivity.java:278)
03-10 21:47:36.224 I/ViewRootImpl(28244): CPU Rendering VSync enable = false
03-10 21:47:36.224 I/View    (28244): ssignParent(ViewParent parent) parent is: android.view.ViewRootImpl@3255354a
03-10 21:47:36.254 E/HAL     (28244): hw_get_module_by_class: lib loaded: /system/lib/hw/gralloc.msm8909.so

test apk log:

03-10 22:09:28.514 I/tag( 6291): exec tmp: log: [d] su invoked.
03-10 22:09:28.524 I/tag( 6291): exec tmp: log: [w] hacks: Testing (com.keramidas.TitaniumBackup:0:10068)
03-10 22:09:28.544 I/tag( 6291): exec tmp: log: [d] mkdir /dev/com.koushikdutta.superuser 0777
03-10 22:09:28.554 I/tag( 6291): exec tmp: log: [d] chown (/dev/com.koushikdutta.superuser, 10067, 10067)
03-10 22:09:28.574 I/tag( 6291): exec tmp: log: [d] database_check ret: 0
03-10 22:09:28.584 I/tag( 6291): exec tmp: log: [d] /dev/com.koushikdutta.superuser/.socket23342
03-10 22:09:28.594 I/tag( 6291): exec tmp: log: [d] socket_create_temp socket_serv_fd: 4
03-10 22:09:28.614 I/tag( 6291): exec tmp: log: [d] send_request needs_owner_login_prompt: 0
03-10 22:09:28.624 I/tag( 6291): exec tmp: log: [d]  /system/bin/app_process
03-10 22:09:28.634 I/tag( 6291): exec tmp: log: [d]
03-10 22:09:28.634 I/tag( 6291): exec tmp:
03-10 22:09:48.674 I/tag( 6291): exec tmp: log: [e] select failed with 2: No such file or directory
03-10 22:09:48.674 I/tag( 6291): exec tmp: log: [d]  /system/bin/app_process
03-10 22:09:48.694 I/tag( 6291): exec tmp: log: [d]
03-10 22:09:48.694 I/tag( 6291): exec tmp:
03-10 22:09:48.714 I/tag( 6291): exec tmp: log: [w] request rejected (10186->0 /system/bin/sh)
03-10 22:09:48.754 I/tag( 6291): exec tmp: log: [d] starting daemon client 10186 10186
03-10 22:09:48.754 I/tag( 6291): exec tmp: log: [d] connecting client 23321
03-10 22:09:48.754 I/tag( 6291): exec tmp: log: [d] client exited 1

daemon log:

log: [d] remote pid: 30221
log: [d] remote pts_slave:
log: [d] remote uid: 10068
log: [d] remote req pid: 30176
log: [d] remote args: 1
log: [d] waiting for child exit
log: [d] sending code
log: [d] child exited
phhusson commented 8 years ago

Which android version?

flyuuo9 commented 8 years ago

@phhusson HUAWEI HONOR 4A 5.1.1, Is something wrong about my SuperUser.apk Install Method?

phhusson commented 8 years ago

Well there is a SELinux policy which prevents an app to contact the su daemon. You might try to call setenforce 0 from your root adb