Documentation
¶
Overview ¶
Package server: confinedFs is an afero.Fs backed by one or more *os.Root values, confining every path -- however it is spelled, however many symlinks it crosses -- to a fixed set of directory trees: basePath (the tree the FTP client sees as its root) and, optionally, one or more resolveRoots. A symlink found anywhere under basePath is followed only when its literal, unresolved target text names basePath or one of resolveRoots (or a path under one of them); any other target -- including one that would otherwise resolve back inside an allowed root by way of ".." segments the kernel would happily walk -- is refused rather than followed. With no resolveRoots, only basePath itself qualifies: confinement then reduces to "nothing outside basePath is ever reachable", which is what os.Root already guarantees on its own.
This mirrors the *os.Root-based confinement in cmd/traffic/cmd/agent/sftpserver/server.go's resolve/resolveLink/underMounts, generalized from a fixed two-root (exports, mounts) layout to an arbitrary basePath plus N resolveRoots, and from a single fixed symlink position (container/top) to a symlink at any depth.
Package server contains an FTP server based on github.com/fclairamb/ftpserverlib
Index ¶
- func Start(ctx context.Context, publicHost string, basePath string, ...) error
- func StartOnPort(ctx context.Context, publicHost string, basePath string, port uint16, ...) error
- func StartOnPortWithValidator(ctx context.Context, publicHost, basePath string, port uint16, ...) error
- func StartWithValidator(ctx context.Context, publicHost, basePath string, portAnnounceCh chan<- uint16, ...) error
- type PasswordValidator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
func Start(ctx context.Context, publicHost string, basePath string, portAnnounceCh chan<- uint16, resolveRoots ...string) error
Start starts an FTP server serving basePath and authenticating any username with any password (the "anonymous" pattern). The port it bound is sent once on portAnnounceCh, which is then closed.
A symlink under basePath is served (rather than refused) when its target is basePath itself, a path under it, or a path under one of resolveRoots; with no resolveRoots, only basePath qualifies. See confinedFs for the full confinement semantics.
func StartOnPort ¶
func StartOnPort(ctx context.Context, publicHost string, basePath string, port uint16, resolveRoots ...string) error
StartOnPort is like Start, but listens on the given port instead of an ephemeral one.
A symlink under basePath is served (rather than refused) when its target is basePath itself, a path under it, or a path under one of resolveRoots; with no resolveRoots, only basePath qualifies. See confinedFs for the full confinement semantics.
func StartOnPortWithValidator ¶ added in v1.3.0
func StartOnPortWithValidator(ctx context.Context, publicHost, basePath string, port uint16, validate PasswordValidator, resolveRoots ...string) error
StartOnPortWithValidator is like StartOnPort, but authenticates logins using validate instead of the built-in anonymous user.
func StartWithValidator ¶ added in v1.3.0
func StartWithValidator(ctx context.Context, publicHost, basePath string, portAnnounceCh chan<- uint16, validate PasswordValidator, resolveRoots ...string) error
StartWithValidator is like Start, but authenticates logins using validate instead of the built-in anonymous user.