Skip to content

Commit ddc54c2

Browse files
authored
Merge pull request #64 from jandubois/spaces
Quote local and remote filenames in case they include spaces
2 parents ed5d055 + 7ed7e03 commit ddc54c2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

pkg/reversesshfs/reversesshfs.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (rsf *ReverseSSHFS) Prepare() error {
5252
sshArgs = append(sshArgs, "-p", strconv.Itoa(rsf.Port))
5353
}
5454
sshArgs = append(sshArgs, rsf.Host, "--")
55-
sshArgs = append(sshArgs, "mkdir", "-p", rsf.RemotePath)
55+
sshArgs = append(sshArgs, "mkdir", "-p", strconv.Quote(rsf.RemotePath))
5656
sshCmd := exec.Command(sshBinary, sshArgs...)
5757
logrus.Debugf("executing ssh for preparing sshfs: %s %v", sshCmd.Path, sshCmd.Args)
5858
out, err := sshCmd.CombinedOutput()
@@ -138,7 +138,7 @@ func (rsf *ReverseSSHFS) Start() error {
138138
sshArgs = append(sshArgs, "-p", strconv.Itoa(rsf.Port))
139139
}
140140
sshArgs = append(sshArgs, rsf.Host, "--")
141-
sshArgs = append(sshArgs, "sshfs", ":"+rsf.LocalPath, rsf.RemotePath, "-o", "slave")
141+
sshArgs = append(sshArgs, "sshfs", strconv.Quote(":"+rsf.LocalPath), strconv.Quote(rsf.RemotePath), "-o", "slave")
142142
if rsf.Readonly {
143143
sshArgs = append(sshArgs, "-o", "ro")
144144
}
@@ -261,7 +261,8 @@ export LANG LC_ALL
261261
i=0
262262
while : ; do
263263
# FIXME: not really robust
264-
if mount | grep "on ${dir}" | egrep -qw "fuse.sshfs|osxfuse"; then
264+
# spaces in file names are encoded as '\040' in the mount table
265+
if mount | sed 's/\\040/ /g' | grep "on ${dir}" | egrep -qw "fuse.sshfs|osxfuse"; then
265266
echo '{"return":{}}'
266267
exit 0
267268
fi

0 commit comments

Comments
 (0)