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(() => { });
|
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"] }
|
||||||
|
|||||||
Reference in New Issue
Block a user