From 00002f635e5c2d251adcf84583fbefb14f2889fe Mon Sep 17 00:00:00 2001 From: SArthurX Date: Mon, 25 May 2026 16:16:07 +0800 Subject: [PATCH] Set HOME to /root for guest root When kbox runs as guest root, it previously inherited the host's HOME. Because this directory does not exist in the LKL filesystem, cd would fail with ENOENT and shell profiles wouldn't load. Fix this by overriding HOME to /root when guest root is active. Change-Id: I738dbea7b0bcca01c62c29f054d0d5b375a68d66 --- src/image.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/image.c b/src/image.c index 94160d9..103a2d9 100644 --- a/src/image.c +++ b/src/image.c @@ -950,6 +950,9 @@ int kbox_run_image(const struct kbox_image_args *args) if (kbox_apply_guest_identity(sysnrs, root_id, override_uid, override_gid) < 0) goto err_post_boot; + + if (root_id || override_uid == 0) + setenv("HOME", "/root", 1); } /* Probe host features. Rewrite mode skips seccomp-specific probes. */