-
Couldn't load subscription status.
- Fork 107
default value for $HOME when adding the application user #21
base: develop
Are you sure you want to change the base?
default value for $HOME when adding the application user #21
Conversation
|
What is the service you are trying to add? The stripping of most environment variables by JupyterHub is a pain for other reasons. Usually one deals with it by setting Even so, with your change you would still be needing to execute Anyway, am not really inclined to add setting of So in pursuit of fixing this in an entirely different way, can you explain a bit more about how you are using the JupyterHub service feature so I understand what you are using it for, and I can think about whether the different changes I have in mind would work with it. |
|
Actually I am not adding a custom service at all, I am only using an unmodified version of the When a container is started, I clone/pull a git repository via ssh in the spawner and copy it to a volume shared between the hub and the notebook. However, at this point the git command fails because the Passing the environment variable to the service from the hub is a workaround I did not think about, thanks for pointing this out! |
|
I am a bit confused how FWIW, if the alternate fix for |
|
The git commands are not executed in the The timeline of events is as follows:
|
|
Okay. I understand now. So there are a few options as to how to fix it. The first is to add The second is to not even invoke A third is to ditch use of nsswrapper and use writable This third one is sort of the best, but as already mentioned means can't build as S2I anymore, which as said I don't think is a big issue. In doing the third option I would be refactoring a lot of the startup sequence to introduce hooking points where you could run scripts on startup of the container. It sounds like these hook points would be a better place to do your setup than having to override |
|
I will go for the first option for now: c.JupyterHub.services = [
{
# ...
'environment': {
"HOME": os.environ["HOME"]
}
}
]I did not yet look into init containers, but I will definitely check this out. Thanks a lot for your support! Of course feel free to just close this pull request, there are for sure better ways to work around this. |
The base image (
centos/python-36-centos7) uses/opt/app-root/etc/passwdinstead of the system's/etc/passwdfile. When this file is updated to contain the default application user (by sourcing/opt/app-root/etc/generate_container_user), the$HOMEenvironment variable is used the specify the home directory:https://github.com/sclorg/s2i-python-container/blob/1ff8621371c9c6c39cadea5e18cf0b6a2275a949/3.6/root/opt/app-root/etc/generate_container_user#L12
Some scripts (for example
cull-idle-servers) indirectly source this file:jupyterhub-quickstart/.s2i/bin/assemble
Line 56 in e5c38dd
jupyterhub-quickstart/scripts/cull-idle-servers
Line 3 in e5c38dd
However, JupyterHub services are started in a rather minimal environment:
https://github.com/jupyterhub/jupyterhub/blob/e4d4e059bd6ecc749a6276a80eada8f0de8ad206/jupyterhub/services/service.py#L317
This results in
$HOMEnot being set and the user having no home directory after the service is executed. For applications relying on thepasswdfile to get the user's home directory afterwards, this can lead to problems.As an example,
sshdefaults to the root directory to create the.sshdirectory in case the home directory is not set:https://github.com/openssh/openssh-portable/blob/4d28fa78abce2890e136281950633fae2066cc29/ssh.c#L1427
Non-root users have no write permissions there and the execution fails.
With this merge request I make sure that
$HOMEis set in the/opt/app-root/etc/scl_enablescript before sourcing/opt/app-root/etc/generate_container_user. Please let me know in case there is a better place to add this.