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

podman run --userns fails with gidmapping=100:@${GID} but works with gidmapping=100:@${UID} #25117

Closed
Fak3 opened this issue Jan 25, 2025 · 3 comments
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@Fak3
Copy link
Contributor

Fak3 commented Jan 25, 2025

Issue Description

When i run podman run --userns="auto:uidmapping=405:@${UID},gidmapping=100:@${GID}" --user guest alpine whoami, i get syntax error:
Error: parsing id map value "@": strconv.ParseUint: parsing "": invalid syntax

Steps to reproduce the issue

Run podman run --userns="auto:uidmapping=405:@${UID},gidmapping=100:@${GID}" --user guest alpine whoam

Describe the results you received

Error: parsing id map value "@": strconv.ParseUint: parsing "": invalid syntax

Describe the results you expected

This should replace ${GID} in the argument with the GID of the current user. The same way that it currently replaces ${UID} with current user's UID. For example, this command currently works fine:

> podman run --userns="auto:uidmapping=405:@${UID},gidmapping=100:@${UID}" --user guest  alpine whoami
guest

podman info output

host:
  arch: amd64
  buildahVersion: 1.38.0
  cgroupControllers:
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.12-1.2.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.12, commit: unknown'
  cpuUtilization:
    idlePercent: 91.28
    systemPercent: 2.58
    userPercent: 6.15
  cpus: 12
  databaseBackend: sqlite
  distribution:
    distribution: opensuse-tumbleweed
    version: "20250121"
  eventLogger: journald
  freeLocks: 2033
  hostname: localhost.localdomain
  idMappings:
    gidmap:
    - container_id: 0
      host_id: 1001
      size: 1
    - container_id: 1
      host_id: 165536
      size: 65536
    uidmap:
    - container_id: 0
      host_id: 1001
      size: 1
    - container_id: 1
      host_id: 165536
      size: 65536
  kernel: 6.12.10-1-default
  linkmode: dynamic
  logDriver: journald
  memFree: 4434448384
  memTotal: 32985276416
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.13.1-1.2.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.13.1
    package: netavark-1.13.1-1.1.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.13.1
  ociRuntime:
    name: crun
    package: crun-1.19.1-1.1.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.19.1
      commit: 3e32a70c93f5aa5fea69b50256cca7fd4aa23c80
      rundir: /run/user/1001/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-20241211.09478d5-1.2.x86_64
    version: |
      pasta 20241211.09478d5-1.2
      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/1001/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: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.3.1-1.2.x86_64
    version: |-
      slirp4netns version 1.3.1
      commit: unknown
      libslirp: 4.8.0
      SLIRP_CONFIG_VERSION_MAX: 5
      libseccomp: 2.5.5
  swapFree: 0
  swapTotal: 0
  uptime: 28h 30m 2.00s (Approximately 1.17 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.opensuse.org
  - registry.suse.com
  - docker.io
store:
  configFile: /home/u1/.config/containers/storage.conf
  containerStore:
    number: 14
    paused: 0
    running: 0
    stopped: 14
  graphDriverName: overlay
  graphOptions: {}
  graphRoot: /home/u1/.local/share/containers/storage
  graphRootAllocated: 234619252736
  graphRootUsed: 202116640768
  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: 1
  runRoot: /run/user/1001/containers
  transientStore: false
  volumePath: /home/u1/.local/share/containers/storage/volumes
version:
  APIVersion: 5.3.1
  Built: 1733485830
  BuiltTime: Fri Dec  6 16:50:30 2024
  GitCommit: ""
  GoVersion: go1.23.4
  Os: linux
  OsArch: linux/amd64
  Version: 5.3.1

Podman in a container

No

Privileged Or Rootless

Rootless

Upstream Latest Release

Yes

Additional environment details

No response

Additional information

No response

@Fak3 Fak3 added the kind/bug Categorizes issue or PR as related to a bug. label Jan 25, 2025
@eriksjolund
Copy link
Contributor

I did a test on Fedora CoreOS 42.20241025.91.0

$ echo $UID
1046
$ echo $GID

$

According to
https://stackoverflow.com/a/39446268/757777
Bash sets the Bash variable UID .
In my example UID is not set as an environment variable:

$ printenv UID
$ printenv GID
$

Does it work if you set GID beforehand?

GID=$(id -g)

@eriksjolund
Copy link
Contributor

I forgot to say:

Your shell does variable substitution of ${UID} and ${GID} in the command

podman run --userns="auto:uidmapping=405:@${UID},gidmapping=100:@${GID}" --user guest  alpine whoam

The actual command that will be run after shell variable substitution can be seen by running the same command but appending echo to the command-line:

echo podman run --userns="auto:uidmapping=405:@${UID},gidmapping=100:@${GID}" --user guest  alpine whoam

@Fak3
Copy link
Contributor Author

Fak3 commented Jan 26, 2025

Does it work if you set GID beforehand?

Thank you, It worked!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

No branches or pull requests

2 participants