Skip to content
This repository has been archived by the owner on Oct 19, 2022. It is now read-only.

Commit

Permalink
Merge pull request #20 from vieux/fix-sshfs-cmd
Browse files Browse the repository at this point in the history
Make sshfs shelling-out more robust
  • Loading branch information
vieux authored Mar 30, 2017
2 parents 776485c + acc3f89 commit 37d1428
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"os/exec"
"path/filepath"
"strconv"
"strings"
"sync"

"github.com/Sirupsen/logrus"
Expand Down Expand Up @@ -231,15 +232,16 @@ func (d *sshfsDriver) Capabilities(r volume.Request) volume.Response {
}

func (d *sshfsDriver) mountVolume(v *sshfsVolume) error {
cmd := fmt.Sprintf("sshfs -oStrictHostKeyChecking=no %s %s", v.Sshcmd, v.Mountpoint)
cmd := exec.Command("sshfs", "-oStrictHostKeyChecking=no", v.Sshcmd, v.Mountpoint)
if v.Port != "" {
cmd = fmt.Sprintf("%s -p %s", cmd, v.Port)
cmd.Args = append(cmd.Args, "-p", v.Port)
}
if v.Password != "" {
cmd = fmt.Sprintf("echo %s | %s -o workaround=rename -o password_stdin", v.Password, cmd)
cmd.Args = append(cmd.Args, "-p", v.Port, "-o", "workaround=rename", "-o", "password_stdin")
cmd.Stdin = strings.NewReader(v.Password)
}
logrus.Debug(cmd)
return exec.Command("sh", "-c", cmd).Run()
logrus.Debug(cmd.Args)
return cmd.Run()
}

func (d *sshfsDriver) unmountVolume(target string) error {
Expand Down

0 comments on commit 37d1428

Please sign in to comment.