Skip to content

Commit

Permalink
Merge pull request #64 from jandubois/spaces
Browse files Browse the repository at this point in the history
Quote local and remote filenames in case they include spaces
  • Loading branch information
AkihiroSuda authored Feb 11, 2023
2 parents ed5d055 + 7ed7e03 commit ddc54c2
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions pkg/reversesshfs/reversesshfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func (rsf *ReverseSSHFS) Prepare() error {
sshArgs = append(sshArgs, "-p", strconv.Itoa(rsf.Port))
}
sshArgs = append(sshArgs, rsf.Host, "--")
sshArgs = append(sshArgs, "mkdir", "-p", rsf.RemotePath)
sshArgs = append(sshArgs, "mkdir", "-p", strconv.Quote(rsf.RemotePath))
sshCmd := exec.Command(sshBinary, sshArgs...)
logrus.Debugf("executing ssh for preparing sshfs: %s %v", sshCmd.Path, sshCmd.Args)
out, err := sshCmd.CombinedOutput()
Expand Down Expand Up @@ -138,7 +138,7 @@ func (rsf *ReverseSSHFS) Start() error {
sshArgs = append(sshArgs, "-p", strconv.Itoa(rsf.Port))
}
sshArgs = append(sshArgs, rsf.Host, "--")
sshArgs = append(sshArgs, "sshfs", ":"+rsf.LocalPath, rsf.RemotePath, "-o", "slave")
sshArgs = append(sshArgs, "sshfs", strconv.Quote(":"+rsf.LocalPath), strconv.Quote(rsf.RemotePath), "-o", "slave")
if rsf.Readonly {
sshArgs = append(sshArgs, "-o", "ro")
}
Expand Down Expand Up @@ -261,7 +261,8 @@ export LANG LC_ALL
i=0
while : ; do
# FIXME: not really robust
if mount | grep "on ${dir}" | egrep -qw "fuse.sshfs|osxfuse"; then
# spaces in file names are encoded as '\040' in the mount table
if mount | sed 's/\\040/ /g' | grep "on ${dir}" | egrep -qw "fuse.sshfs|osxfuse"; then
echo '{"return":{}}'
exit 0
fi
Expand Down

0 comments on commit ddc54c2

Please sign in to comment.