Skip to content

'exec --tty --workdir /missing/path ...' no longer uses exit code 127 #1823

@debarshiray

Description

@debarshiray

Issue Description

In the past podman exec --workdir /missing/path ... used exit code 127, which is caught by Toolbx to fall back to podman exec --workdir <home-directory>. At some point the error path changed when --tty is present, and it now uses exit code 255, while it behaves as before if --tty is not used.

Would it be possible to restore the previous exit code?

Note that this doesn't impact podman run --workdir /missing/path ..., where the exit code remains the same with and without --tty.

We have tests for this in Toolbx, but, unfortunately the tests run non-interactively and don't use --tty. That's how it didn't get caught earlier.

There's the associated issue that exit codes for --workdir /missing/path are not the same across exec and run, 127 versus 126, and it seems that --workdir /missing/path is abusing the exit codes reserved for problems with the executable. However, these aren't pressing problems for Toolbx.

Steps to reproduce the issue

Steps to reproduce the issue:

Create and start a container:

$ podman create --name foo registry.fedoraproject.org/fedora:42 sleep +Inf
c6479c24fa91117e7feb8832d64d15afb465b19e80d293db8ec88315b700686d
$ podman start foo
foo

Compare the behaviour of exec with and without the --tty option:

$ podman exec --tty --workdir /var/tmp/toolbx-test-OX06oxCvi6 foo pwd
Error: OCI runtime error: crun: read pipe failed
$ echo "$?"
255
$ podman exec --workdir /var/tmp/toolbx-test-OX06oxCvi6 foo pwd
Error: crun: chdir to `/var/tmp/toolbx-test-OX06oxCvi6`: No such file or directory: OCI runtime attempted to invoke a command that was not found
$ echo "$?"
127

Describe the results you received

exec --tty --workdir /missing/path uses exit code 255, and uses 127 if --tty is absent.

Describe the results you expected

exec --tty --workdir /missing/path should use exit code 127, just as when --tty is absent.

podman info output

host:
  arch: amd64
  buildahVersion: 1.40.1
  cgroupControllers:
  - cpu
  - io
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.13-1.fc42.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.13, commit: '
  cpuUtilization:
    idlePercent: 99.41
    systemPercent: 0.2
    userPercent: 0.39
  cpus: 16
  databaseBackend: sqlite
  distribution:
    distribution: fedora
    variant: workstation
    version: "42"
  eventLogger: journald
  freeLocks: 2046
  hostname: topinka
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1000
      size: 1
    - container_id: 1
      host_id: 524288
      size: 65536
  kernel: 6.15.4-200.fc42.x86_64
  linkmode: dynamic
  logDriver: journald
  memFree: 21743378432
  memTotal: 33543249920
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.15.0-1.fc42.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.15.0
    package: netavark-1.15.2-1.fc42.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.15.2
  ociRuntime:
    name: crun
    package: crun-1.22-1.fc42.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.22
      commit: 4de19b63a85efd9ea8503452179c371181750130
      rundir: /run/user/1000/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +LIBKRUN +WASM:wasmedge +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20250611.g0293c6f-1.fc42.x86_64
    version: |
      pasta 0^20250611.g0293c6f-1.fc42.x86_64
      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
  rootlessNetworkCmd: pasta
  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: true
  serviceIsRemote: false
  slirp4netns:
    executable: ""
    package: ""
    version: ""
  swapFree: 8589930496
  swapTotal: 8589930496
  uptime: 11h 23m 6.00s (Approximately 0.46 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.fedoraproject.org
  - registry.access.redhat.com
  - docker.io
store:
  configFile: /home/rishi/.config/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 2
    stopped: 0
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/rishi/.local/share/containers/storage
  graphRootAllocated: 1695606808576
  graphRootUsed: 604253806592
  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: 2
  runRoot: /run/user/1000/containers
  transientStore: false
  volumePath: /home/rishi/.local/share/containers/storage/volumes
version:
  APIVersion: 5.5.2
  BuildOrigin: Fedora Project
  Built: 1750723200
  BuiltTime: Tue Jun 24 02:00:00 2025
  GitCommit: e7d8226745ba07a64b7176a7f128e4ef53225a0e
  GoVersion: go1.24.4
  Os: linux
  OsArch: linux/amd64
  Version: 5.5.2

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

n/a

Additional information

I think this is a regression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions