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

UserNS=auto wrong sub{g,u}id #24937

Open
mountainfloating opened this issue Jan 4, 2025 · 1 comment
Open

UserNS=auto wrong sub{g,u}id #24937

mountainfloating opened this issue Jan 4, 2025 · 1 comment
Labels
kind/bug Categorizes issue or PR as related to a bug.

Comments

@mountainfloating
Copy link

mountainfloating commented Jan 4, 2025

Issue Description

Hey, the documentation says about rootful UserNS=auto that I should define the subuids like containers:100000:65536

auto[:OPTIONS,…]: automatically create a unique user namespace.
rootful mode: The --userns=auto flag requires that the user name containers be specified in the /etc/subuid and /etc/subgid files, with an unused range of subordinate user IDs that Podman containers are allowed to allocate.
Example: containers:2147483647:2147483648.

This configuration errors and tells me to map root:100000:65536 (which then works fine).
Is this a mistake in the documentation or some quirk on almalinux 9.5?
Also the resulting uid:gid is 1001:1001 which is not inside my specified range?

Also tested with a fresh fedora 41 install. Same behaviour.

Steps to reproduce the issue

As root:

echo "containers:100000:65536" | tee /etc/sub{g,u}id
podman run --rm --userns=auto quay.io/podman/hello

Describe the results you received

ERRO[0000] Cannot find mappings for user "root": no subuid ranges found for user "root" in /etc/subuid 
Error: creating container storage: not enough unused IDs in user namespace

Describe the results you expected

Run

podman info output

arch: amd64
  buildahVersion: 1.37.5
  cgroupControllers:
  - memory
  - pids
  cgroupManager: systemd
  cgroupVersion: v2
  conmon:
    package: conmon-2.1.12-1.el9.x86_64
    path: /usr/bin/conmon
    version: 'conmon version 2.1.12, commit: eb379dceb7efebd9a9d6b3349a57424d83483065'
  cpuUtilization:
    idlePercent: 73.59
    systemPercent: 8.84
    userPercent: 17.58
  cpus: 4
  databaseBackend: sqlite
  distribution:
    distribution: almalinux
    version: "9.5"
  eventLogger: journald
  freeLocks: 2046
  hostname: podman
  idMappings:
    gidmap: null
    uidmap: null
  kernel: 6.8.12-5-pve
  linkmode: dynamic
  logDriver: journald
  memFree: 3134861312
  memTotal: 4294967296
  networkBackend: netavark
  networkBackendInfo:
    backend: netavark
    dns:
      package: aardvark-dns-1.12.2-1.el9_5.x86_64
      path: /usr/libexec/podman/aardvark-dns
      version: aardvark-dns 1.12.2
    package: netavark-1.12.2-1.el9.x86_64
    path: /usr/libexec/podman/netavark
    version: netavark 1.12.2
  ociRuntime:
    name: crun
    package: crun-1.16.1-1.el9.x86_64
    path: /usr/bin/crun
    version: |-
      crun version 1.16.1
      commit: afa829ca0122bd5e1d67f1f38e6cc348027e3c32
      rundir: /run/crun
      spec: 1.0.0
      +SYSTEMD +SELINUX +APPARMOR +CAP +SECCOMP +EBPF +CRIU +YAJL
  os: linux
  pasta:
    executable: /usr/bin/pasta
    package: passt-0^20240806.gee36266-2.el9.x86_64
    version: |
      pasta 0^20240806.gee36266-2.el9.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: false
    path: /run/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: false
    seccompEnabled: true
    seccompProfilePath: /usr/share/containers/seccomp.json
    selinuxEnabled: false
  serviceIsRemote: false
  slirp4netns:
    executable: /usr/bin/slirp4netns
    package: slirp4netns-1.3.1-1.el9.x86_64
    version: |-
      slirp4netns version 1.3.1
      commit: e5e368c4f5db6ae75c2fce786e31eef9da6bf236
      libslirp: 4.4.0
      SLIRP_CONFIG_VERSION_MAX: 3
      libseccomp: 2.5.2
  swapFree: 0
  swapTotal: 0
  uptime: 10h 48m 56.00s (Approximately 0.42 days)
  variant: ""
plugins:
  authorization: null
  log:
  - k8s-file
  - none
  - passthrough
  - journald
  network:
  - bridge
  - macvlan
  - ipvlan
  volume:
  - local
registries:
  search:
  - registry.access.redhat.com
  - registry.redhat.io
  - docker.io
store:
  configFile: /etc/containers/storage.conf
  containerStore:
    number: 2
    paused: 0
    running: 2
    stopped: 0
  graphDriverName: overlay
  graphOptions:
    overlay.mountopt: nodev,metacopy=on
  graphRoot: /var/lib/containers/storage
  graphRootAllocated: 8350298112
  graphRootUsed: 5125754880
  graphStatus:
    Backing Filesystem: extfs
    Native Overlay Diff: "false"
    Supports d_type: "true"
    Supports shifting: "false"
    Supports volatile: "true"
    Using metacopy: "false"
  imageCopyTmpDir: /var/tmp
  imageStore:
    number: 2
  runRoot: /run/containers/storage
  transientStore: false
  volumePath: /var/lib/containers/storage/volumes
version:
  APIVersion: 5.2.2
  Built: 1734439251
  BuiltTime: Tue Dec 17 12:40:51 2024
  GitCommit: ""
  GoVersion: go1.22.7 (Red Hat 1.22.7-2.el9_5)
  Os: linux
  OsArch: linux/amd64
  Version: 5.2.2

Podman in a container

Yes

Privileged Or Rootless

Privileged

Upstream Latest Release

Yes

@mountainfloating mountainfloating added the kind/bug Categorizes issue or PR as related to a bug. label Jan 4, 2025
@Luap99
Copy link
Member

Luap99 commented Jan 6, 2025

containers is the default and is being used in our CI AFAICS. so yeas the docs are correct.
I guess you are running within a nested container (user namesapce)? The code for checking if root checks if it is not running in a user namespace and thus it then defaults to the current username in that case.

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