In package managers like pacman and apt, the root check is hard coded into source using guid checks. Why is this?
A non privileged user can compile a program - let's say chromium browser - from source into a pseudo root (within the user directory) and run it. The user can even download a pre-compiled binary and run it. Why not just let the user use package managers to directly install the software into the pseudo root (within the users home directory) without privilege escalation?
IMO package managers should require sudo only when writing files to a dir owned by root. like /bin or /etc.
Please let me know if there is some security issue that I'm overlooking.
Note: A bit of research shows that there indeed are alternate package managers for user space. Package management without the need of root permission https://askubuntu.com/questions/339 Non-Root Package Managers
My question still is - why native package managers do not support such a use case - would have been a more elegant implementation.