pkg / sftp

SFTP support for the go.crypto/ssh package
BSD 2-Clause "Simplified" License
1.5k stars 380 forks source link

RealPathFileLister #448

Closed d4z3x closed 2 years ago

d4z3x commented 3 years ago

How do I use this interface to customize the start directory?

type RealPathFileLister interface {
    FileLister
    RealPath(string) string
}

I do see this in request-example.go:

// implements RealpathFileLister interface
func (fs *root) Realpath(p string) string {
    fs.startDirectory = "/test"

    if fs.startDirectory == "" || fs.startDirectory == "/" {
        return cleanPath(p)
    }
    return cleanPathWithBase(fs.startDirectory, p)
}

Do I implement the RealPath method and change the dir there? My apologies in advance for asking a basic question.

drakkan commented 2 years ago

Hi,

yes do you need to implement the RealpathFileLister interface and returns the response for the SSH_FXP_REALPATH request from there. This way you can implement the start directory logic.

drakkan commented 2 years ago

RealpathFileLister works only with smart clients, I proposed a better approach in #498