-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Lack of passwd/group file entries when run as arbitrarily assigned user ID. #552
Comments
This is also needed for running Apache Toree in all-spark-notebook. Without it the Apache Toree kernel will not start as it can't work out what $HOME is for the user ID that the container runs as when run as arbitrarily assigned user ID. |
BTW, Red Hat guidelines have been updated to use this approach in place of a previous way they were recommending using libnss_wrapper. See section 'Support Arbitrary User IDs' of: Hopefully this provides some confirmation that is seen as okay to use it. |
Thanks for digging into it! Closed by #559 |
Thanks a lot @GrahamDumpleton . I was trying to fix a similar issue where a binary needs passwd entry and I was scratching my head. Your solution worked like a charm. However, I would have liked a source discussion url about the security review from Redhat about this. Anyway. Thank you again. P.S: For others, please be aware that you can become root inside the container with this change as discussed in the #553 . |
Hey, thank you for this!
my docker run is:
Can someone help me figuring this out please? Thanks a lot!! P.S. I don't know if it could be useful but the Dockerfile to build my image is
|
The problem in your start command seems to be summarized by the message An alternative could be to run the container as docker run -it --rm \
--user root \
-e NB_UID=$(id -u) \
-e NB_GID=$(id -g) \
-e JUPYTER_ENABLE_LAB=yes \
-p 8888:8888 \
jupyter/base-notebook
# (base) jovyan@d349947e59b5:~$ id
# uid=501(jovyan) gid=20(dialout) groups=20(dialout),100(users) However your solution should work according to the documentation common options. So there is a problem somewhere 😕 . I will check. In fact just figured out that your solution works if I remove the group from the docker run -it --rm \
--user $(id -u) \
--group-add users \
-e JUPYTER_ENABLE_LAB=yes \
-p 8888:8888 \
jupyter/base-notebook |
It does!! Thank you so much @romainx !! 💯 |
Note for later the problem comes from here docker-stacks/base-notebook/start.sh Lines 104 to 120 in 42f4c82
|
What docker image you are using?
All are affected by this issue.
What complete docker command do you run to launch the container (omitting sensitive values)?
Two commands to consider.
and:
The examples are where images are run as arbitrarily assigned user ID. This scenario can arise in container deployment platforms which enforce a security model where images can't run as
root
or even the user the image specifies. This is the case with Kubernetes (and OpenShift), where Role Base Access Control (RBAC) and Security Context Constraints (SCC) are enabled to enforce a secure multitenant deployment environment.Note that the images will not actualy work out of the box this way because the group they run as will be GID 0. To compensate for this, you need to add GID 100 as supplemental group for the container. A platform might also itself add the assigned user ID as a supplemental group as well.
What steps do you take once the container is running to reproduce the issue?
Once shell is running the container, run the commands:
In the first case the result will be:
In the second it will be:
What do you expect to happen?
No errors.
What actually happens?
Errors.
The reason this is a problem is some Python packages out there aren't tolerant of the user they are running as not having passwd and group file entries. An example of typical exception that might occur is:
Solution
A solution to this problem is to make
/etc/passwd
and/etc/group
files writable and when the container is run, add appropriate entries to the files so valid results are returned. That is, so get something like:This can be done through a script such as:
so that the
/etc/passwd
file ends up being:and the
/etc/group
file being:The system C libraries in the container will consult the modified files and yield the desired results.
A PR is coming with a working fix for this.
Note that making
/etc/passwd
and/etc/group
files writable has been reviewed by some security minded folks in Red Hat and no risk was seen in having them writable in the context of a container run under docker or other OCI spec runtime. The ability to make changes does not introduce any way of code being able to escalate privileges.The text was updated successfully, but these errors were encountered: