Rooting Sonim Phones

Sonim xp3800

End goal: my root app shouldn’t ever kernel panic (have init start a root daemon and disable SeLinux. Without disabling it, untrusted_app can’t connectto the daemon.

Or even easier: make a setuid (/system isn’t mounted blocking it) and have init turn off SeLinux so that untrusted_app can execute it.

What would happen if you added your certs

Wdym? Patch rules? I’d do that but there are so many differences between variants (Verizon vs Sprint vs att) that I’m scared.

1 Like

Not what I meant hold on

No responsibility for bricks :slight_smile:

1 Like

Check for these files:

vendor_mac_permissions.xml
plat_mac_permissions.xml

1 Like
~/.../public/root-sonim-xp3800 $ ssh -p 8022 redacted '~/su "find / -type f -name vendor_mac_permissions.xml"'
find: ‘/proc/3161’: No such file or directory
~/.../public/root-sonim-xp3800 $ ssh -p redacted '~/su "find / -type f -name plat_mac_permissions.xml"'
/system/etc/selinux/plat_mac_permissions.xml
~/.../public/root-sonim-xp3800 $                                             ✔

/system/etc/selinux/plat_mac_permissions.xml

Now I don’t remember what happens if you have more than one in there, but look into it.

Also don’t know if you’ll need a fr after.

Also don’t know if I know what I’m talking about.

1 Like

I definitely don’t know what you’re talking about :thinking:

What’s a fr? I can look into it

Factory reset.

Normally I’d just resign the whole rom but it’s not so simple depending on the phone.

I didn’t yet understand what this file is exactly but grim what you’re saying, this is exactly the type of thing I’m avoiding because of the variant differences. For this price I can patch SeLinux to add some rules.

If it would be the only way then maybe. But there’s the magisk firehose method + my app doesn’t cause that many kernel panics anyway. Only when you run root the first time after rebooting and your phone is anyway busy in the background

1 Like

depends on the phone literally even the same variant

sonim mysteries

You probably have more apps on the one that’s panicking. Right?

Correct

Update the app, the first time you use root after boot, don’t be running 17 apps in the background with battery bubbling.

Wait a minute after it turns on better you run it. (Just tips for better chances)

But there are other weirder differences between variants like the boot, and now an issue on my repo about install.sh failing on his att variant. Waiting on his logs

But if you have system r/w, and can find the correct file to edit in /system/etc/selinux/ (on any devices I’ve done it’s plat_seapp_contexts), couldn’t you make a script to

  1. Detect newly installed package.
  2. Get package name.
  3. Add package-specific seapp_contexts rule.
  4. Make sure target domain exists in compiled SELinux policy.
  5. Make sure that domain can connect to the su daemon.
  6. Reboot or restart enough Android services for the new mapping to apply.

For a newly installed /data/app package, a generated rule could look like:
user=_app seinfo=default name=com.example.newapp domain=root_client_app type=app_data_file levelFrom=user

Or is this the type of thing you are trying to avoid??

1 Like

I don’t have experience with patching SeLinux rules but if it can be device specific then I’m scared. The app will have to do all this programmatically and if the files look different on different devices then they’re probably different between the xp3 variants just because sonim loves making stuff the weird way all the time

3 Likes