Fix Commands that Require Quoted Paths (#198)

* fix commands that require quoted paths

Several commands did not wrap the path in quotes which caused problems
when attempting to store the waveterm installation in a place that had a
space in the path. This corrects this in the particular case where the
username does not have spaces but the path to the executable does.

Note: the case of a user name having spaces has not been tested but
likely does not work.

* fix logging problem for wavesrv

A previous fix replaced the getWaveSrvCmd with getWaveSrvPath. This
needs to be getWaveSrvCmd to enable logging.

* fix variable name
This commit is contained in:
Sylvie Crowe 2023-12-30 22:52:30 -08:00 committed by GitHub
parent 2c9272e3a7
commit d1319c0a2c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -140,7 +140,7 @@ function getWaveSrvCmd() {
let waveSrvPath = getWaveSrvPath();
let waveHome = getWaveHomeDir();
let logFile = path.join(waveHome, "wavesrv.log");
return `${waveSrvPath} >> "${logFile}" 2>&1`;
return `"${waveSrvPath}" >> "${logFile}" 2>&1`;
}
function getWaveSrvCwd() {
@ -540,8 +540,8 @@ function sendWSSC() {
}
function runWaveSrv() {
let pResolve = null;
let pReject = null;
let pResolve: (value: unknown) => void;
let pReject: (reason?: any) => void;
let rtnPromise = new Promise((argResolve, argReject) => {
pResolve = argResolve;
pReject = argReject;
@ -551,8 +551,9 @@ function runWaveSrv() {
if (isDev) {
envCopy[WaveDevVarName] = "1";
}
console.log("trying to run local server", getWaveSrvPath());
let proc = child_process.spawn("bash", ["-c", getWaveSrvCmd()], {
let waveSrvCmd = getWaveSrvCmd();
console.log("trying to run local server", waveSrvCmd);
let proc = child_process.spawn("bash", ["-c", waveSrvCmd], {
cwd: getWaveSrvCwd(),
env: envCopy,
});
@ -560,7 +561,7 @@ function runWaveSrv() {
console.log("wavesrv exit", e);
waveSrvProc = null;
sendWSSC();
pReject(new Error(sprintf("failed to start local server (%s)", getWaveSrvPath())));
pReject(new Error(sprintf("failed to start local server (%s)", waveSrvCmd)));
if (waveSrvShouldRestart) {
waveSrvShouldRestart = false;
this.runWaveSrv();

View File

@ -21,6 +21,7 @@ import (
"syscall"
"time"
"github.com/alessio/shellescape"
"github.com/armon/circbuf"
"github.com/creack/pty"
"github.com/google/uuid"
@ -66,9 +67,9 @@ func MakeLocalMShellCommandStr(isSudo bool) (string, error) {
return "", err
}
if isSudo {
return fmt.Sprintf(`%s; sudo %s --server`, PrintPingPacket, mshellPath), nil
return fmt.Sprintf(`%s; sudo %s --server`, PrintPingPacket, shellescape.Quote(mshellPath)), nil
} else {
return fmt.Sprintf(`%s; %s --server`, PrintPingPacket, mshellPath), nil
return fmt.Sprintf(`%s; %s --server`, PrintPingPacket, shellescape.Quote(mshellPath)), nil
}
}