scp: don’t error out on directories in the tarball

This commit is contained in:
Michael Stapelberg 2018-12-15 14:47:34 +01:00
parent c11ed6a015
commit 05fda29dea

3
scp.go
View File

@ -79,6 +79,9 @@ func scpSink(channel ssh.Channel, req *ssh.Request, cmdline []string) error {
if err := os.MkdirAll(filepath.Dir(h.Name), 0700); err != nil {
return err
}
if strings.HasSuffix(h.Name, "/") {
continue // directory, dont try to OpenFile() it
}
mode := h.FileInfo().Mode() & os.ModePerm
out, err := os.OpenFile(h.Name, os.O_CREATE|os.O_TRUNC|os.O_WRONLY, mode)
if err != nil {