From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <m.carrara@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 41C3299164
 for <pbs-devel@lists.proxmox.com>; Thu, 20 Apr 2023 14:53:45 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 0A1732BB05
 for <pbs-devel@lists.proxmox.com>; Thu, 20 Apr 2023 14:53:15 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pbs-devel@lists.proxmox.com>; Thu, 20 Apr 2023 14:53:13 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 553B945D7A
 for <pbs-devel@lists.proxmox.com>; Thu, 20 Apr 2023 14:53:13 +0200 (CEST)
From: Max Carrara <m.carrara@proxmox.com>
To: pbs-devel@lists.proxmox.com
Date: Thu, 20 Apr 2023 14:53:07 +0200
Message-Id: <20230420125307.1790967-1-m.carrara@proxmox.com>
X-Mailer: git-send-email 2.30.2
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.013 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
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [main.rs]
Subject: [pbs-devel] [PATCH proxmox-backup-restore-image] fix #4477: init:
 symlink busybox binaries on init
X-BeenThere: pbs-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox Backup Server development discussion
 <pbs-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pbs-devel/>
List-Post: <mailto:pbs-devel@lists.proxmox.com>
List-Help: <mailto:pbs-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel>, 
 <mailto:pbs-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Thu, 20 Apr 2023 12:53:45 -0000

This change makes Busybox symbolically link its inbuilt utils to their
respective locations, allowing them to be invoked through their
absolute path. This means that Busybox inbuilts like e.g. `mount`
and `env` become available at `/bin/mount` and `/usr/bin/env` etc.

In particular, when entering any of the snapshot directories in
`.zfs/snapshot` (e.g. via `cd` or `ls`), ZFS normally mounts the
respective snapshot(s) on demand, using `/usr/bin/env mount [...]`
internally. Before this change, this would fail, rendering ZFS
snapshots unavailable when restoring individual files.

Signed-off-by: Max Carrara <m.carrara@proxmox.com>
---
 src/init-shim-rs/src/main.rs | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/src/init-shim-rs/src/main.rs b/src/init-shim-rs/src/main.rs
index a6e093c..083c08f 100644
--- a/src/init-shim-rs/src/main.rs
+++ b/src/init-shim-rs/src/main.rs
@@ -31,6 +31,14 @@ fn main() {
         do_mknod("/dev/null", NULL_MAJ, NULL_MIN)
     });
 
+    // tell busybox to symlink its binaries
+    wrap_err("busybox --install -s", || {
+        Command::new("/bin/busybox")
+            .args(["--install", "-s"])
+            .spawn()?;
+        Ok(())
+    });
+
     if let Err(err) = run_agetty() {
         // not fatal
         println!("[init-shim] debug: agetty start failed: {}", err);
-- 
2.30.2