fix: pass HOME explicitly in sudo inlineCmd so MITM server resolves correct data dir (closes #478) (#482)
This commit is contained in:
parent
5fe2c81cf9
commit
7f4f75a807
1 changed files with 3 additions and 1 deletions
|
|
@ -450,7 +450,9 @@ async function startServer(apiKey, sudoPassword) {
|
||||||
|
|
||||||
if (_updateSettings) await _updateSettings({ mitmCertInstalled: true }).catch(() => { });
|
if (_updateSettings) await _updateSettings({ mitmCertInstalled: true }).catch(() => { });
|
||||||
} else if (isSudoAvailable()) {
|
} 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(
|
serverProcess = spawn(
|
||||||
"sudo", ["-S", "-E", "sh", "-c", inlineCmd],
|
"sudo", ["-S", "-E", "sh", "-c", inlineCmd],
|
||||||
{ detached: false, stdio: ["pipe", "pipe", "pipe"] }
|
{ detached: false, stdio: ["pipe", "pipe", "pipe"] }
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue