-
Notifications
You must be signed in to change notification settings - Fork 36
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
Set SHELL env var in launcher if unset to avoid issues in Code's shell detection #284
Conversation
Before launching Code, if the SHELL environment variable is unset, set it to something before launching: * If SHELL is unset and /bin/bash is installed, use that * Otherwise, fall back to /bin/sh as a 'safe' option This is necessary to avoid internal shell-detection logic in Code, which reads /etc/passwd when SHELL is not set. This is an issue when running in e.g. OpenShift, where cri-o will add a user entry to /etc/passwd containing /sbin/nologin as the login shell. Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Signed-off-by: Angel Misevski <amisevsk@redhat.com>
Pull Request images published ✨ |
1 similar comment
Pull Request images published ✨ |
launcher/src/vscode-launcher.ts
Outdated
@@ -66,6 +66,17 @@ export class VSCodeLauncher { | |||
env.NODE_EXTRA_CA_CERTS = NODE_EXTRA_CERTIFICATE; | |||
} | |||
|
|||
if (!env.SHELL) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about checking if the user shell (in /etc/passwd
) is /sbin/nologin or not? If cri-o hasn't patched /etc/passwd
(i.e. containerd is the container runtime) there may be a valid shell for current user anyway.
Beyond that I have tested the PR using image quay.io/che-incubator-pull-requests/che-code:pr-284-amd64
and the quarkus devfile from registry.devfile.io and the problem got solved 🎉 . I had an unrelated problem though and I have filed a separate issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is probably a good idea -- I didn't initially do it since I was trying to keep it simple (since IIRC the default UDI image sets SHELL) but better safe than sorry :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the PR now. If /etc/passwd contains anything other than /sbin/nologin
, we no longer override it by setting SHELL if it's not already set.
Pull Request images published ✨ |
2 similar comments
Pull Request images published ✨ |
Pull Request images published ✨ |
Pull Request images published ✨ |
@vitaliy-guliy @l0rd Updated this PR after Mario's suggestion, please take a look before I merge. |
When launching Code, add an additional check to read /etc/passwd and check if the user has a (non-/sbin/nologin) shell defined there. If /etc/passwd contains any other shell (e.g. /bin/zsh, /bin/bash, etc.), then let Code read that shell from /etc/passwd instead of overriding it by setting the SHELL environment variable. Signed-off-by: Angel Misevski <amisevsk@redhat.com>
778c229
to
7544fdb
Compare
Pull Request images published ✨ |
Build 3.10 :: code_3.x/959: Console, Changes, Git Data |
Build 3.10 :: sync-to-downstream_3.x/4970: Console, Changes, Git Data |
Build 3.10 :: get-sources-rhpkg-container-build_3.x/4794: code : 3.x :: |
Pull Request images published ✨ |
What does this PR do?
If the SHELL environment variable is unset when running the Code launcher, set it:
/bin/bash
/bin/sh
This is necessary due to shell-detection logic within Code itself, which will fallback to parsing /etc/passwd when SHELL is not set (see [1]). When running on e.g. OpenShift with a normal container, cri-o will add an /etc/passwd entry for the current user with
/sbin/nologin
, which results the terminal failing to launch.What issues does this PR fix?
Closes eclipse-che/che#22524
How to test this PR?
Changes from this PR are built into
quay.io/amisevsk/che-code:dev
via the following Dockerfile:To test the changes on an existing workspace, edit the DevWorkspace yaml on the cluster, updating the
.spec.contributions
field:(This will use quay.io/amisevsk/che-code:dev in place of the default injector image)
We should verify three cases before merging:
SHELL
environment variable have It is not possible to start a terminal when workspace started from a devfile from theregistry.devfile.io
eclipse-che/che#22524 resolved.