From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 98EEC1FF178 for ; Mon, 1 Dec 2025 18:13:31 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 029C8228F8; Mon, 1 Dec 2025 18:13:56 +0100 (CET) From: Filip Schauer To: pve-devel@lists.proxmox.com Date: Mon, 1 Dec 2025 18:13:10 +0100 Message-ID: <20251201171317.149449-2-f.schauer@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251201171317.149449-1-f.schauer@proxmox.com> References: <20251201171317.149449-1-f.schauer@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1764609159037 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.005 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_VALIDITY_CERTIFIED_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_RPBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. RCVD_IN_VALIDITY_SAFE_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to Validity was blocked. See https://knowledge.validity.com/hc/en-us/articles/20961730681243 for more information. SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH proxmox 1/2] oci: fix rootfs extraction when paths already exist X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Remove paths from previous layers that conflict with new layer entries before unpacking. This aligns with the OCI spec. [0] This fixes a rootfs extraction failure with docker.io/grafana/otel-lgtm, which was reported in the Proxmox Forum [1]. [0] https://github.com/opencontainers/image-spec/blob/26647a49f642c7d22a1cd3aa0a48e4650a542269/layer.md#changeset-over-existing-files [1] https://forum.proxmox.com/threads/otel-lgtm-oci-create-lxc-failed.176996/ Signed-off-by: Filip Schauer --- proxmox-oci/src/lib.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/proxmox-oci/src/lib.rs b/proxmox-oci/src/lib.rs index cf0e4271..cce68207 100644 --- a/proxmox-oci/src/lib.rs +++ b/proxmox-oci/src/lib.rs @@ -302,6 +302,16 @@ fn extract_archive>(reader: &mut R, target_path: P) -> s } } + // If a file or directory already exists at this path, remove it first. + let file_path_abs = target_path.as_ref().join(file.path()?); + if file_path_abs.exists() { + if file_path_abs.is_dir() { + remove_dir_all(file_path_abs)?; + } else { + remove_file(file_path_abs)?; + } + } + file.unpack_in(&target_path)?; } @@ -309,6 +319,16 @@ fn extract_archive>(reader: &mut R, target_path: P) -> s // to avoid failure on restrictive parent directory permissions. directories.sort_by(|a, b| b.path_bytes().cmp(&a.path_bytes())); for mut dir in directories { + let dir_path_abs = target_path.as_ref().join(dir.path()?); + + // Remove the trailing slash + let dir_path_abs = dir_path_abs.components().as_path(); + + // If a file already exists at this path, remove it first. + if dir_path_abs.exists() && !dir_path_abs.is_dir() { + remove_file(dir_path_abs)?; + } + dir.unpack_in(&target_path)?; } -- 2.47.3 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel