fix: pass HOME explicitly in sudo inlineCmd so MITM server resolves correct data dir (closes #478) (#482)

This commit is contained in:
Anurag Saxena
2026-04-03 21:52:31 -04:00
committed by GitHub
parent 5fe2c81cf9
commit 7f4f75a807

View File

@@ -450,7 +450,9 @@ async function startServer(apiKey, sudoPassword) {
if (_updateSettings) await _updateSettings({ mitmCertInstalled: true }).catch(() => { });
} else if (isSudoAvailable()) {
const inlineCmd = `ROUTER_API_KEY='${apiKey}' NODE_ENV='production' '${process.execPath}' '${SERVER_PATH}'`;
// Pass HOME explicitly so os.homedir() resolves to the unprivileged user's home
// instead of /root when sudo resets the environment.
const inlineCmd = `HOME='${os.homedir()}' ROUTER_API_KEY='${apiKey}' NODE_ENV='production' '${process.execPath}' '${SERVER_PATH}'`;
serverProcess = spawn(
"sudo", ["-S", "-E", "sh", "-c", inlineCmd],
{ detached: false, stdio: ["pipe", "pipe", "pipe"] }