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

ssh: invoke sshd -T with a clean environment #1890

Closed
wants to merge 1 commit into from

Conversation

ogayot
Copy link
Member

@ogayot ogayot commented Jan 22, 2024

When calling sshd -T, we used to inherit the LD_LIBRARY_PATH variable, resulting in the following errors on focal:

sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /snap/subiquity/5270/usr/lib/x86_64-linux-gnu/libsystemd.so.0)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /snap/subiquity/5270/usr/lib/x86_64-linux-gnu/libsystemd.so.0)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /snap/subiquity/5270/usr/lib/x86_64-linux-gnu/libsystemd.so.0)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/liblzma.so.5)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/liblzma.so.5)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/libcap.so.2)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/libgcrypt.so.20)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/libgpg-error.so.0)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/libgpg-error.so.0)

Fixed by sanitizing the environment first. We don't expect sshd to be present in the snap anyway.

I encountered this while trying to reproduce the bug described at LP:#2050030

When calling `sshd -T`, we used to inherit the LD_LIBRARY_PATH variable,
resulting in the following errors on focal:

sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /snap/subiquity/5270/usr/lib/x86_64-linux-gnu/libsystemd.so.0)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /snap/subiquity/5270/usr/lib/x86_64-linux-gnu/libsystemd.so.0)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /snap/subiquity/5270/usr/lib/x86_64-linux-gnu/libsystemd.so.0)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/liblzma.so.5)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/liblzma.so.5)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/libcap.so.2)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/libgcrypt.so.20)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/libgpg-error.so.0)
sshd: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /snap/core22/current/lib/x86_64-linux-gnu/libgpg-error.so.0)

Fixed by sanitizing the environment first. We don't expect sshd to be
present in the snap anyway.

Signed-off-by: Olivier Gayot <[email protected]>
Copy link
Collaborator

@mwhudson mwhudson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remind me, what sets LD_LIBRARY_PATH these days? is it code injected by snapcraft? because i'm not sure why we need it...

@ogayot
Copy link
Member Author

ogayot commented Jan 23, 2024

Remind me, what sets LD_LIBRARY_PATH these days? is it code injected by snapcraft? because i'm not sure why we need it...

it looks like it's set by snapcraft ; which is interesting because it wasn't in the 22.07.2 snap.

# env | grep LIBRARY_PATH
# snap run --shell subiquity.subiquity-server
# env | grep LIBRARY_PATH
SNAP_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void
LD_LIBRARY_PATH=/var/lib/snapd/lib/gl:/var/lib/snapd/lib/gl32:/var/lib/snapd/void:/snap/subiquity/5270/lib:/snap/subiquity/5270/usr/lib:/snap/subiquity/5270/lib/x86_64-linux-gnu:/snap/subiquity/5270/usr/lib/x86_64-linux-gnu
# grep -C 5 LD_LIBRARY_PATH /snap/subiquity/5270/meta/snap.yaml
      OS_PROBER_SHARE: $SNAP/usr/share
      OS_PROBER_LIB: $SNAP/usr/lib
confinement: classic
grade: stable
environment:
  LD_LIBRARY_PATH: ${SNAP_LIBRARY_PATH}${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}:$SNAP/lib:$SNAP/usr/lib:$SNAP/lib/x86_64-linux-gnu:$SNAP/usr/lib/x86_64-linux-gnu
  PATH: $SNAP/usr/sbin:$SNAP/usr/bin:$SNAP/sbin:$SNAP/bin:$PATH
links:
  contact:
  - https://bugs.launchpad.net/subiquity/+filebug
  issues:

not sure how it ended up there since it isn't in our snapcraft.yaml definition https://github.com/canonical/subiquity/blob/01fd8d22a95afff7ede308437856e43832210350/snapcraft.yaml

EDIT: canonical/snapcraft#4187 seems relevant. The fix was first included in https://github.com/snapcore/snapcraft/releases/tag/8.0.0 and is available in the stable channel.

@ogayot ogayot marked this pull request as draft January 23, 2024 10:29
@ogayot
Copy link
Member Author

ogayot commented Jan 23, 2024

Converting to draft since the change would not be needed when we rebuild with snapcraft 8

@ogayot ogayot closed this Feb 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants