all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Filip Schauer <f.schauer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH container] fix #8254: oci create: do not require /etc/ files for numeric ids
Date: Mon,  9 Nov 2026 15:50:00 +0100	[thread overview]
Message-ID: <20261109145146.105652-1-f.schauer@proxmox.com> (raw)

resolve_oci_user() used to always die if /etc/passwd or /etc/group could
not be resolved in the container rootfs, even when the image config set
a numeric User that needs no lookup.

Only treat the files as unresolvable when they are actually needed.

This also changes behavior when a name cannot be resolved. It now fails
with an error instead of silently continuing without a UID or GID, which
let the container's init run as root even though the image asked for a
different user. This is also required by the OCI image spec, in the
"Conversion to OCI Runtime Configuration" section: "If Config.User does
not correspond to a user in the container's context, the converter MUST
return an error."

Signed-off-by: Filip Schauer <f.schauer@proxmox.com>
---
 src/PVE/LXC/Create.pm | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/src/PVE/LXC/Create.pm b/src/PVE/LXC/Create.pm
index 64a6f66..3c07911 100644
--- a/src/PVE/LXC/Create.pm
+++ b/src/PVE/LXC/Create.pm
@@ -801,12 +801,13 @@ sub resolve_oci_user {
             # Prevent symlinks from escaping out of container rootdir
             chroot($rootdir) or die "failed to change root to: $rootdir: $!\n";
             chdir('/') or die "failed to change to root directory\n";
-            my $etc_passwd = abs_path('/etc/passwd')
-                or die "cannot resolve /etc/passwd path in container rootfs\n";
-            my $etc_group = abs_path('/etc/group')
-                or die "cannot resolve /etc/group path in container rootfs\n";
+            my $etc_passwd = abs_path('/etc/passwd');
+            my $etc_group = abs_path('/etc/group');
 
-            return [$rootdir . $etc_passwd, $rootdir . $etc_group];
+            return [
+                defined($etc_passwd) ? $rootdir . $etc_passwd : undef,
+                defined($etc_group) ? $rootdir . $etc_group : undef,
+            ];
         })
     };
 
@@ -858,6 +859,7 @@ sub resolve_oci_user {
     } else {
         $username = $user;
         $uid = $lookup_field->($etc_passwd, 0, $username, 2);
+        die "cannot resolve username '$username' to uid\n" if !defined($uid);
     }
 
     if (defined($group)) {
@@ -865,6 +867,7 @@ sub resolve_oci_user {
             $gid = $group;
         } else {
             $gid = $lookup_field->($etc_group, 0, $group, 2);
+            die "cannot resolve group '$group' to gid\n" if !defined($gid);
         }
     } else {
         $gid = $lookup_field->($etc_passwd, 2, $uid, 3) if defined($uid);
-- 
2.47.3





                 reply	other threads:[~2026-11-09 14:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261109145146.105652-1-f.schauer@proxmox.com \
    --to=f.schauer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal