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

Fails to detect shell in docker containers run with rosetta on Apple Silicon #74

Closed
Moomboh opened this issue Apr 28, 2023 · 1 comment · Fixed by #75
Closed

Fails to detect shell in docker containers run with rosetta on Apple Silicon #74

Moomboh opened this issue Apr 28, 2023 · 1 comment · Fixed by #75

Comments

@Moomboh
Copy link
Contributor

Moomboh commented Apr 28, 2023

Description

shellingham currently fails to detect shells inside docker containers running with the [Docker Desktop option to run x86 binaries with rosetta]([Docker Desktop for Mac] - Support for running x86-64 binaries with Rosetta 2).
This is due to the fact that in this case the proc_args have /rosetta/rosetta as their first element and the second element is the actual shell, which currently isn't checked by shellingham.

Minimal Reproducible Example

Requires an Apple Silicon machine with Docker Desktop installed and the option "Use Rosetta for x86/amd64 emulation on Apple Silicon" enabled as in the following screenshot:
image

Using the following Dockerfile:

FROM --platform=linux/amd64 debian:bullseye

RUN set -ex && \
    apt-get update && \
    apt-get -y install \
    python3 \
    python3-pip \
    && rm -rf /var/lib/apt/lists/* && \
    pip3 install shellingham

Then open a shell in that docker container with

docker build . -t shellingham-rosetta-bug-mre && docker run --platform=linux/amd64 -it shellingham-rosetta-bug-mre /bin/bash

and finally in the container try to detect the shell with shellingham

python3 -c 'import shellingham; print(shellingham.detect_shell())'
@Moomboh
Copy link
Contributor Author

Moomboh commented Apr 28, 2023

Just noticed this is related to or a duplicate of #55 although there it seems to be the case that it doesn't consider qemu-x86_64 being the first process_arg.

Moomboh added a commit to Moomboh/shellingham that referenced this issue Apr 28, 2023
Moomboh added a commit to Moomboh/shellingham that referenced this issue Apr 28, 2023
@Moomboh Moomboh mentioned this issue Apr 28, 2023
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 a pull request may close this issue.

1 participant