2

I have a rooted phone and on it an application that I've built. My application receives su powers from the superuser app and can call commands that require root, but the problem is that I have a piece of code that has to run from a process with root uid, and the file can't be compiled separately.

Now, is it possible to fork my process and run the child process as root:root? or somehow change the uid to root (I've tried with seteuid / setuid and it didn't work.. probably because the application's setuid flag is off).

I would like something like this:

fork process
if (child-process)
    run_special_code()
else
    wait_for_the_child_process_to_exit()

Thanks!

shlatchz
  • 1,612
  • 1
  • 18
  • 40
  • I'm uncertain how much Android differs, but on a POSIX system, being able to change a processes' [e]uid does not depend on the setuid bit being set in the binary file's mode. If you need to set the process's *real* uid and gid, then you should call `setuid()` / `setgid()` twice -- the first call will set the euid / egid, but the second, when the euid / egid are already root, will set the real (and saved) uid / gid as well. Naturally, you want to do this only after forking, and only in the child. Again, Android may differ. – John Bollinger Sep 29 '16 at 19:13
  • I've tried that and the uid remains the same... – shlatchz Sep 29 '16 at 19:39
  • Possible duplicate of [Run android program as root](https://stackoverflow.com/questions/9194725/run-android-program-as-root) – Ciro Santilli OurBigBook.com Nov 07 '17 at 10:53

0 Answers0