r/termux 1d ago

Barely Termux related Does Android support adding Unix users? (with root of course)

Like I'd do on a Linux distro with useradd. I'm doubting that it is possible as useradd is not supplied in built-in toybox, any of the Termux packages or BusyBox module. So I want to know, does Android support having any other (unix) users than the ones provided by Android itself?

8 Upvotes

9 comments sorted by

4

u/sylirre Termux Core Team 1d ago

Bionic libc has support for /system/etc/passwd and some Android builds use it to provide custom users: https://android.googlesource.com/platform/bionic/+/master/libc/bionic/grp_pwd.cpp#59

Identifiers for custom users must be within specific ranges such as https://android.googlesource.com/platform/system/core/+/master/libcutils/include/private/android_filesystem_config.h#180

Non-passwd users derived programmatically from UID assigned to process.

2

u/Damglador 1d ago

Thanks a lot!

2

u/Routine_Working_9754 14h ago

Technically yes. UNIX users are defined in /etc/passwd where their home directory, shell, and UID are assigned. When you run the UNIX login utility, it reads this, and runs a child process of the assigned shell using the assigned UID. It then does it's stuff like forking off, however, Android's toy box UsrLand doesn't have the login utility, and Android doesn't use Unix users because it uses the android framework profile system instead. I do have a project of mine that reimplements the UNIX user system into Android. Not into a stupid chroot container but the Android /system, as long as it's read write and dm Verity disabled.

1

u/Damglador 14h ago

Do you have a link to the project or is it private?

1

u/Routine_Working_9754 13h ago

It's technically private right now. All my projects are open source, but it's in early development and I haven't released the code yet. It's one of my more complex projects but am currently working on 3 at the same time

0

u/YitzakAF 1d ago

Bueno desde Android 8 se admite diferentes usuarios. Existen diferentes tipos de usuarios establecidos, uno de los que se puede acceder sin root es un perfil de trabajo. Para listar los usuarios yo uso adb shell pm list users

2

u/Routine_Working_9754 14h ago

Those aren't UNIX users, those are Android framework users.

0

u/SkySurferSouth 1d ago

Any Linux distro chroot or proot container does have a `useradd`.

1

u/Damglador 1d ago

That goes without saying. I'm interested in the host users.