Skip to content

Commit e84cc8c

Browse files
committed
Merge pull request pkg#85 from pkg/rootdir
server: remote rootDir parameter, as it does nothing
2 parents 8a7343c + 8e47c75 commit e84cc8c

File tree

5 files changed

+2
-19
lines changed

5 files changed

+2
-19
lines changed

client_integration_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ func testClientGoSvr(t testing.TB, readonly bool, delay time.Duration) (*Client,
102102
server, err := NewServer(
103103
txPipeRd,
104104
rxPipeWr,
105-
".",
106105
options...,
107106
)
108107
if err != nil {

examples/sftp-server/main.go

-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,10 @@ func main() {
2121
var (
2222
readOnly bool
2323
debugStderr bool
24-
rootDir string
2524
)
2625

2726
flag.BoolVar(&readOnly, "R", false, "read-only server")
2827
flag.BoolVar(&debugStderr, "e", false, "debug to stderr")
29-
flag.StringVar(&rootDir, "root", "", "root directory")
3028
flag.Parse()
3129

3230
debugStream := ioutil.Discard
@@ -123,7 +121,6 @@ func main() {
123121
server, err := sftp.NewServer(
124122
channel,
125123
channel,
126-
rootDir,
127124
sftp.WithDebug(debugStream),
128125
sftp.ReadOnly(),
129126
)

server.go

+2-13
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ type Server struct {
2929
outMutex *sync.Mutex
3030
debugStream io.Writer
3131
readOnly bool
32-
rootDir string
3332
lastID uint32
3433
pktChan chan rxPacket
3534
openFiles map[string]*os.File
@@ -74,26 +73,16 @@ type serverRespondablePacket interface {
7473
}
7574

7675
// NewServer creates a new Server instance around the provided streams, serving
77-
// content from the directory specified by rootDir. Optionally, ServerOption
76+
// content from the root of the filesystem. Optionally, ServerOption
7877
// functions may be specified to further configure the Server.
7978
//
8079
// A subsequent call to Serve() is required to begin serving files over SFTP.
81-
func NewServer(in io.Reader, out io.WriteCloser, rootDir string, options ...ServerOption) (*Server, error) {
82-
if rootDir == "" {
83-
wd, err := os.Getwd()
84-
if err != nil {
85-
return nil, err
86-
}
87-
88-
rootDir = wd
89-
}
90-
80+
func NewServer(in io.Reader, out io.WriteCloser, options ...ServerOption) (*Server, error) {
9181
s := &Server{
9282
in: in,
9383
out: out,
9484
outMutex: &sync.Mutex{},
9585
debugStream: ioutil.Discard,
96-
rootDir: rootDir,
9786
pktChan: make(chan rxPacket, sftpServerWorkerCount),
9887
openFiles: map[string]*os.File{},
9988
openFilesLock: &sync.RWMutex{},

server_integration_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ func (chsvr *sshSessionChannelServer) handleSubsystem(req *ssh.Request) error {
297297
sftpServer, err := NewServer(
298298
chsvr.ch,
299299
chsvr.ch,
300-
".",
301300
WithDebug(sftpServerDebugStream),
302301
)
303302
if err != nil {

server_standalone/main.go

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ func main() {
3030
svr, _ := sftp.NewServer(
3131
os.Stdin,
3232
os.Stdout,
33-
"",
3433
sftp.WithDebug(debugStream),
3534
sftp.ReadOnly(),
3635
)

0 commit comments

Comments
 (0)