Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Equivalent of --map-root-user #1

Open
douglas-raillard-arm opened this issue Nov 1, 2021 · 6 comments
Open

Equivalent of --map-root-user #1

douglas-raillard-arm opened this issue Nov 1, 2021 · 6 comments
Labels
enhancement New feature or request

Comments

@douglas-raillard-arm
Copy link

Hi,

For some reason on my system unshare -m is not permitted as a regular user unless --map-root-user is also used. Given the general usefulness of --map-root-user, would you consider adding a similar option to unshare.unshare() Python function ?

Regards,
Douglas

@shubham1172
Copy link
Owner

@douglas-raillard-arm that sounds good, would you like to send in a PR?

@shubham1172 shubham1172 added the enhancement New feature or request label Mar 22, 2022
@douglas-raillard-arm
Copy link
Author

I unfortunately don't have the bandwidth at the moment, I guess I did not really require the feature in the end or found a workaround, I cannot remember. Let's leave it opened so that people understand what happens if they hit the issue, as the kernel is not particularly verbose when something goes wrong

@hexDoor
Copy link

hexDoor commented Sep 13, 2022

I unfortunately don't have the bandwidth at the moment, I guess I did not really require the feature in the end or found a workaround, I cannot remember. Let's leave it opened so that people understand what happens if they hit the issue, as the kernel is not particularly verbose when something goes wrong

Just for anyone who comes by (since I also ran into this issue), I ended up writing the mapping to /proc/self/uid_map, /proc/self/gid_map and /proc/self/setgroups directly.

user_namespaces(7) should have all the information you need to work from there.

@douglas-raillard-arm
Copy link
Author

The current state of my code is there and has worked for a while now. It also takes care of spinning up a sub process and transferring logging back to the main process to be as transparent as possible.
https://github.com/ARM-software/lisa/blob/master/lisa/_unshare.py

@hpe-ykoehler
Copy link

if I run from the shell "unshare -rm" (which does unshare (NEWNS|NEWUSER)" it works, but whenever I call unshare from python be it with ffi or ctypes or this unshare component, I get invalid error or permission denied.

Somehow it seems that the NEWNS must gets executed after the NEWUSER... when that when I use -rm directly in shell it seems to work, yet the C code of unshare seems to be calling it the same way as in the Python code.

@douglas-raillard-arm
Copy link
Author

Maybe you are running in a more restricted environment like a container ? The Python source I shared above has been used by my team for quite a while now and it works well AFAIK on a typical Ubuntu setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants