mirror of
https://github.com/decolua/9router.git
synced 2026-05-08 12:01:28 +00:00
fix: pass HOME explicitly in sudo inlineCmd so MITM server resolves correct data dir (closes #478) (#482)
This commit is contained in:
@@ -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"] }
|
||||
|
||||
Reference in New Issue
Block a user