phhusson / Superuser

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

Fix prepare_su_bind check #66

Closed PerfectSlayer closed 7 years ago

PerfectSlayer commented 7 years ago

/system/xbin/su presence is checked before trying to mount it. The check was inverted. If bound su is missing, prepare method exits instead of mounting su file.

phhusson commented 7 years ago

Mmmm, to me this check is the right way. Let me explain what this does.

Standard superuser.zip changes init.rc so that PATH includes /sbin. Now, some apps first checks /system/xbin/su before checking $PATH, because of historical reasons. If /system/xbin/su isn't there, they behave properly and go check what's in $PATH But if /system/xbin/su exists, then it calls it instead of /sbin/su. This is a problem for the ROMs which provide their own SU, because they'll most likely be broken by my SU.

So this functions replaces /system/xbin/su with my su if it already exists.

Does this look right to you, and does this make sense? If so, I'll add this comment in the source code of that function to make the use-case explicit.

PerfectSlayer commented 7 years ago

Thanks for the explanation! It would be definitively better if the documentation comes the code 👍

By the way, I'm still looking why I need to change this code to have su --bind working. Maybe there is a side effect which is needed in my case. I'm still looking at it.

So I close the PR.