0 votes

As the title says, is it possible? or is there a built-in function for it?

Godot version latest
in Engine by (21 points)

1 Answer

0 votes

Check for the su binary usually in "/sbin/su" or "/system/bin/su" however with all of the exploits today it's possible for it to be in other locations. And The /system partition is unaccessible by default. So use.

var process_id = OS.execute("su", [], false)
if process_id:
by (6,934 points)

Thanks Wakatta, I'll let you know later the results.

Hi Wakatta, It's not working on my side. Not sure if I done it correctly, but my plan is checking if the phone is rooted, then the game will not run else continue.


The only other idea that comes to mind is to use the which command which is used to locate the executable su file. Since that command isn't part of Android by default if it completes successfully then the device is rooted.

As mentioned before there are just too many rooting exploits and you most likely will have to consistently upgrade your app to match them. One way to do that is to keep a list of applications related to rooting and test to see in any are installed using the pm (package manager) command

Thanks Wakatta!

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.