From 5b33eb75209bed07a7dd1df72464428633ef5fb2 Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Thu, 25 Oct 2018 07:18:43 +0200 Subject: [PATCH] Export HOME in pmb.chroot.root() and -.user() Set HOME to /root for commands started with pmb.chroot.root() and to /home/pmos for commands started with pmb.chroot.user(). POSIX requires this variable to be set, see: And this prevents a crash in "adb", which takes and alternative code path if HOME is not set, that does not work with musl (fixes #1638). Thanks to @ryang2678 for figuring this out! --- pmb/chroot/root.py | 1 + pmb/chroot/user.py | 3 +++ 2 files changed, 4 insertions(+) diff --git a/pmb/chroot/root.py b/pmb/chroot/root.py index a46b5dd8..d4e0f20b 100644 --- a/pmb/chroot/root.py +++ b/pmb/chroot/root.py @@ -70,6 +70,7 @@ def root(args, cmd, suffix="native", working_dir="/", output="log", # Merge env with defaults into env_all env_all = {"CHARSET": "UTF-8", "HISTFILE": "~/.ash_history", + "HOME": "/root", "PATH": pmb.config.chroot_path, "SHELL": "/bin/ash", "TERM": "xterm"} diff --git a/pmb/chroot/user.py b/pmb/chroot/user.py index cb5cb236..fa614cd4 100644 --- a/pmb/chroot/user.py +++ b/pmb/chroot/user.py @@ -34,6 +34,9 @@ def user(args, cmd, suffix="native", working_dir="/", output="log", See pmb.helpers.run_core.core() for a detailed description of all other arguments and the return value. """ + if "HOME" not in env: + env["HOME"] = "/home/pmos" + flat_cmd = pmb.helpers.run.flat_cmd(cmd, env=env) cmd = ["busybox", "su", "pmos", "-c", flat_cmd] return pmb.chroot.root(args, cmd, suffix, working_dir, output,