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

docker/podman-docker.sh breaks login shells #23628

Closed
Gchbg opened this issue Aug 15, 2024 · 1 comment · Fixed by #23630
Closed

docker/podman-docker.sh breaks login shells #23628

Gchbg opened this issue Aug 15, 2024 · 1 comment · Fixed by #23630
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@Gchbg
Copy link
Contributor

Gchbg commented Aug 15, 2024

Issue Description

The latest Podman available in Debian trixie includes a script docker/podman-docker.sh which breaks login shells. This is because the script runs for all login shells and checks whether a variable is empty, but the variable may not even be set. This fails if a login shell runs with -eu (error checking and checking for undefined variables).

The fix is to replace the check on line 3 of the script. Instead of if [ -z "$DOCKER_HOST" ]; then, the line should be changed to if [ -z "${DOCKER_HOST-''}" ]; then. This will explicitly set the variable to the empty value if it is unset within the scope of the check.

$ podman version
Client:       Podman Engine
Version:      5.0.3
API Version:  5.0.3
Go Version:   go1.22.5
Built:        Thu Jan  1 02:00:00 1970
OS/Arch:      linux/amd64

Steps to reproduce the issue

Steps to reproduce the issue on a host system

  1. Make sure DOCKER_HOST is not set
  2. sudo su -l root -s /bin/sh -- -eu -c 'true' ; echo $?

Describe the results you received

$ sudo su -l root -s /bin/sh -- -eu -c 'true'; echo $?
-sh: 3: /etc/profile.d/podman-docker.sh: DOCKER_HOST: parameter not set
2

Describe the results you expected

$ sudo su -l root -s /bin/sh -- -eu -c 'true' ; echo $?
0

podman info output

host:
  arch: amd64
  buildahVersion: 1.35.3
  cgroupControllers:
  - cpu
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon_2.1.10+ds1-1+b1_amd64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.10, commit: unknown'
  cpuUtilization:
    idlePercent: 99.3
    systemPercent: 0.11
    userPercent: 0.59
  cpus: 2
  databaseBackend: sqlite
  distribution:
    codename: trixie
    distribution: debian
    version: unknown
  eventLogger: journald
  freeLocks: 2048
  hostname: Farnsworth
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 100000
      size: 65536
  kernel: 6.10.3-amd64
  linkmode: dynamic
  logDriver: journald
  memFree: 1634111488
  memTotal: 3387248640
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns_1.9.0-2_amd64
      path: /usr/lib/podman/aardvark-dns
      version: aardvark-dns 1.9.0
    package: netavark_1.9.0-4_amd64
    path: /usr/lib/podman/netavark
    version: netavark 1.9.0
  ociRuntime:
    name: crun
    package: crun_1.15-1+b1_amd64
    path: /usr/bin/crun
    version: |-
      crun version 1.15
      commit: e6eacaf4034e84185fd8780ac9262bbf57082278
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt_0.0~git20240806.ee36266-1_amd64
    version: |
      pasta 0.0~git20240806.ee36266-1
      Copyright Red Hat
      GNU General Public License, version 2 or later
        <https://www.gnu.org/licenses/old-licenses/gpl-2.0.html>
      This is free software: you are free to change and redistribute it.
      There is NO WARRANTY, to the extent permitted by law.
  remoteSocket:
    exists: true
    path: /run/user/1000/podman/podman.sock
  security:
    apparmorEnabled: false
    capabilities: CAP_CHOWN,CAP_DAC_OVERRIDE,CAP_FOWNER,CAP_FSETID,CAP_KILL,CAP_NET_BIND_SERVICE,CAP_SETFCAP,CAP_SETGID,CAP_SETPCAP,CAP_SETUID,CAP_SYS_CHROOT
    rootless: true
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns_1.2.1-1+b1_amd64
    version: |-
      slirp4netns version 1.2.1
      commit: 09e31e92fa3d2a1d3ca261adaeb012c8d75a8194
      libslirp: 4.8.0
      SLIRP_CONFIG_VERSION_MAX: 4
      libseccomp: 2.5.5
  swapFree: 0
  swapTotal: 0
  uptime: 25h 13m 26.00s (Approximately 1.04 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries: {}
store:
  configFile: /home/gc/.config/containers/storage.conf
  containerStore:
    number: 0
    paused: 0
    running: 0
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/gc/.local/share/containers/storage
  graphRootAllocated: 249425629184
  graphRootUsed: 6362935296
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "true"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 0
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/gc/.local/share/containers/storage/volumes
version:
  APIVersion: 5.0.3
  Built: 0
  BuiltTime: Thu Jan  1 02:00:00 1970
  GitCommit: ""
  GoVersion: go1.22.5
  Os: linux
  OsArch: linux/amd64
  Version: 5.0.3

Podman in a container

No

Privileged Or Rootless

None

Upstream Latest Release

Yes

Additional environment details

No response

Additional information

No response

@Gchbg Gchbg added the kind/bug Categorizes issue or PR as related to a bug. label Aug 15, 2024
@rhatdan
Copy link
Member

rhatdan commented Aug 15, 2024

Please open a PR to fix?

@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Nov 14, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Nov 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants