Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: quoted some more paths to handle spaces #1028

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmd/agent/container/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ func dockerlessBuild(
}

// build args
args := []string{"build", "--ignore-path", binaryPath}
args := []string{"build", "--ignore-path", fmt.Sprintf("'%s'", binaryPath)}
args = append(args, parseIgnorePaths(dockerlessOptions.IgnorePaths)...)
args = append(args, "--build-arg", "TARGETOS="+runtime.GOOS)
args = append(args, "--build-arg", "TARGETARCH="+runtime.GOARCH)
Expand Down Expand Up @@ -520,7 +520,7 @@ func configureSystemGitCredentials(ctx context.Context, cancel context.CancelFun
return nil, err
}

gitCredentials := fmt.Sprintf("%s agent git-credentials --port %d", binaryPath, serverPort)
gitCredentials := fmt.Sprintf("'%s' agent git-credentials --port %d", binaryPath, serverPort)
_ = os.Setenv("DEVPOD_GIT_HELPER_PORT", strconv.Itoa(serverPort))

err = git.CommandContext(ctx, "config", "--system", "--add", "credential.helper", gitCredentials).Run()
Expand Down
2 changes: 1 addition & 1 deletion cmd/agent/workspace/up.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ func configureCredentials(ctx context.Context, cancel context.CancelFunc, worksp

gitCredentials := ""
if workspaceInfo.Agent.InjectGitCredentials == "true" {
gitCredentials = fmt.Sprintf("%s agent git-credentials --port %d", binaryPath, serverPort)
gitCredentials = fmt.Sprintf("'%s' agent git-credentials --port %d", binaryPath, serverPort)
_ = os.Setenv("DEVPOD_GIT_HELPER_PORT", strconv.Itoa(serverPort))
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ func rerunAsRoot(workspaceInfo *provider2.AgentWorkspaceInfo, log log.Logger) (b
}

// call ourself
args := []string{binary}
args := []string{fmt.Sprintf("'%s'", binary)}
args = append(args, os.Args[1:]...)
log.Debugf("Rerun as root: %s", strings.Join(args, " "))
cmd := exec.Command("sudo", args...)
Expand Down
2 changes: 1 addition & 1 deletion pkg/agent/inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func InjectAgentAndExecute(
downloadURL = DefaultAgentDownloadURL()
}

versionCheck := fmt.Sprintf(`[ "$(%s version 2>/dev/null || echo 'false')" != "%s" ]`, remoteAgentPath, version.GetVersion())
versionCheck := fmt.Sprintf(`[ "$('%s' version 2>/dev/null || echo 'false')" != "%s" ]`, remoteAgentPath, version.GetVersion())
if version.GetVersion() == version.DevVersion {
preferDownload = false

Expand Down
4 changes: 2 additions & 2 deletions pkg/gitcredentials/gitcredentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ func ConfigureHelper(binaryPath, userName string, port int) error {
}

config := string(out)
if !strings.Contains(config, fmt.Sprintf(`helper = "%s agent git-credentials --port %d"`, binaryPath, port)) {
if !strings.Contains(config, fmt.Sprintf(`helper = "'%s' agent git-credentials --port %d"`, binaryPath, port)) {
content := removeCredentialHelper(config) + fmt.Sprintf(`
[credential]
helper = "%s agent git-credentials --port %d"
helper = "'%s' agent git-credentials --port %d"
`, binaryPath, port)

err = os.WriteFile(gitConfigPath, []byte(content), 0600)
Expand Down
4 changes: 2 additions & 2 deletions pkg/ide/fleet/fleet.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (o *FleetServer) Start(binaryPath, location, projectDir string) error {

err := single.Single("fleet.pid", func() (*exec.Cmd, error) {
o.log.Infof("Starting fleet in background...")
runCommand := fmt.Sprintf("%s launch workspace -- --projectDir '%s' --cache-path '%s' --auth=accept-everyone --publish --enableSmartMode", binaryPath, projectDir, location)
runCommand := fmt.Sprintf("'%s' launch workspace -- --projectDir '%s' --cache-path '%s' --auth=accept-everyone --publish --enableSmartMode", binaryPath, projectDir, location)
args := []string{}
if o.userName != "" {
args = append(args, "su", o.userName, "-c", runCommand)
Expand Down Expand Up @@ -177,7 +177,7 @@ func (o *FleetServer) startMonitor() error {

return single.Single("fleet-monitor.pid", func() (*exec.Cmd, error) {
o.log.Infof("Starting fleet monitor in background...")
runCommand := fmt.Sprintf("%s helper fleet-server --workspaceid %s", self, "test")
runCommand := fmt.Sprintf("'%s' helper fleet-server --workspaceid %s", self, "test")
args := []string{}
if o.userName != "" {
args = append(args, "su", o.userName, "-c", runCommand)
Expand Down
4 changes: 2 additions & 2 deletions pkg/ide/openvscode/openvscode.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func (o *OpenVSCodeServer) installExtensions() error {
binaryPath := filepath.Join(location, "bin", "openvscode-server")
for _, extension := range o.extensions {
o.log.Info("Install extension " + extension + "...")
runCommand := fmt.Sprintf("%s --install-extension '%s'", binaryPath, extension)
runCommand := fmt.Sprintf("'%s' --install-extension '%s'", binaryPath, extension)
args := []string{}
if o.userName != "" {
args = append(args, "su", o.userName, "-c", runCommand)
Expand Down Expand Up @@ -261,7 +261,7 @@ func (o *OpenVSCodeServer) Start() error {

return single.Single("openvscode.pid", func() (*exec.Cmd, error) {
o.log.Infof("Starting openvscode in background...")
runCommand := fmt.Sprintf("%s server-local --without-connection-token --host '%s' --port '%s'", binaryPath, o.host, o.port)
runCommand := fmt.Sprintf("'%s' server-local --without-connection-token --host '%s' --port '%s'", binaryPath, o.host, o.port)
args := []string{}
if o.userName != "" {
args = append(args, "su", o.userName, "-c", runCommand)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ide/vscode/vscode.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func (o *VsCodeServer) InstallExtensions() error {
// download extensions
for _, extension := range o.extensions {
o.log.Info("Install extension " + extension + "...")
runCommand := fmt.Sprintf("%s serve-local --accept-server-license-terms --install-extension '%s'", binPath, extension)
runCommand := fmt.Sprintf("'%s' serve-local --accept-server-license-terms --install-extension '%s'", binPath, extension)
args := []string{}
if o.userName != "" {
args = append(args, "su", o.userName, "-c", runCommand)
Expand Down
2 changes: 1 addition & 1 deletion pkg/ssh/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func addHost(path, host, user, context, workspace, workdir, command string, gpga
} else {
proxyCommand := fmt.Sprintf(" ProxyCommand \"%s\" ssh --stdio --context %s --user %s %s", execPath, context, user, workspace)
if workdir != "" {
proxyCommand = fmt.Sprintf("%s --workdir %s", proxyCommand, workdir)
proxyCommand = fmt.Sprintf("'%s' --workdir '%s'", proxyCommand, workdir)
}
newLines = append(newLines, proxyCommand)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/ssh/server/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ func getShell() ([]string, error) {
return nil, err
}

return []string{executable, "helper", "sh"}, nil
return []string{fmt.Sprintf("'%s'", executable), "helper", "sh"}, nil
}

func (s *Server) handler(sess ssh.Session) {
Expand Down
Loading