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

Quote local and remote filenames in case they include spaces #64

Merged
merged 1 commit into from
Feb 11, 2023
Merged
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
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