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: skip the nobody user #1473

Merged
merged 1 commit into from
Jan 17, 2023

Conversation

giuseppe
Copy link
Member

improve the heuristic to detect the user namespace size needed to run an image. Hardcode the nobody user value to 65534, which is the value used by the kernel, and ignore this value when parsing /etc/passwd and /etc/group.

Closes: #1472

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com

improve the heuristic to detect the user namespace size needed to run
an image.  Hardcode the nobody user value to 65534, which is the value
used by the kernel, and ignore this value when parsing /etc/passwd and
/etc/group.

Closes: containers#1472

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Copy link
Member

@vrothberg vrothberg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment on lines 102 to 104
if u.Name == "nobody" {
continue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we skip this check here now

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left it just in case some image defines it to have a value different than the default 65534

Comment on lines 117 to 119
if g.Name == "nobody" {
continue
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@robbmanes
Copy link

Verified working for me in the below test..

Before:

$ podman run --name test1 --userns=auto docker.io/rapidfort/mariadb:10.10

$ podman run --name test2 --userns=auto docker.io/rapidfort/mariadb:10.10
Error: error creating container storage: could not find enough available IDs

$ podman inspect test1 | jq '.[].HostConfig.IDMappings'
{
  "UidMap": [
    "0:1:65534"
  ],
  "GidMap": [
    "0:1:65534"
  ]
}

After:

$ ./bin/podman run --name test1 --userns=auto docker.io/rapidfort/mariadb:10.10

$ ./bin/podman run --name test2 --userns=auto docker.io/rapidfort/mariadb:10.10

$ ./bin/podman inspect test1 | jq '.[].HostConfig.IDMappings'
{
  "UidMap": [
    "0:1:1024"
  ],
  "GidMap": [
    "0:1:1024"
  ]
}

$ ./bin/podman inspect test2 | jq '.[].HostConfig.IDMappings'
{
  "UidMap": [
    "0:1025:1024"
  ],
  "GidMap": [
    "0:1025:1024"
  ]

@rhatdan
Copy link
Member

rhatdan commented Jan 17, 2023

LGTM

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 this pull request may close these issues.

[Bug]: "podman run" with "--userns=auto" fills all available user namespaces for a specific container image
5 participants