mirror of
https://github.com/tailscale/tailscale.git
synced 2025-04-18 20:51:45 +00:00
ipn/ipnlocal: in direct file mode, don't readdir
And don't even allow attempts at Open/Delete. Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:
parent
9972c02b60
commit
8e75c8504c
@ -63,7 +63,7 @@ func (s *peerAPIServer) diskPath(baseName string) (fullPath string, ok bool) {
|
|||||||
// hasFilesWaiting reports whether any files are buffered in the
|
// hasFilesWaiting reports whether any files are buffered in the
|
||||||
// tailscaled daemon storage.
|
// tailscaled daemon storage.
|
||||||
func (s *peerAPIServer) hasFilesWaiting() bool {
|
func (s *peerAPIServer) hasFilesWaiting() bool {
|
||||||
if s.rootDir == "" {
|
if s.rootDir == "" || s.directFileMode {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if s.knownEmpty.Get() {
|
if s.knownEmpty.Get() {
|
||||||
@ -110,6 +110,9 @@ func (s *peerAPIServer) WaitingFiles() (ret []WaitingFile, err error) {
|
|||||||
if s.rootDir == "" {
|
if s.rootDir == "" {
|
||||||
return nil, errors.New("peerapi disabled; no storage configured")
|
return nil, errors.New("peerapi disabled; no storage configured")
|
||||||
}
|
}
|
||||||
|
if s.directFileMode {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
f, err := os.Open(s.rootDir)
|
f, err := os.Open(s.rootDir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -147,6 +150,9 @@ func (s *peerAPIServer) DeleteFile(baseName string) error {
|
|||||||
if s.rootDir == "" {
|
if s.rootDir == "" {
|
||||||
return errors.New("peerapi disabled; no storage configured")
|
return errors.New("peerapi disabled; no storage configured")
|
||||||
}
|
}
|
||||||
|
if s.directFileMode {
|
||||||
|
return errors.New("deletes not allowed in direct mode")
|
||||||
|
}
|
||||||
path, ok := s.diskPath(baseName)
|
path, ok := s.diskPath(baseName)
|
||||||
if !ok {
|
if !ok {
|
||||||
return errors.New("bad filename")
|
return errors.New("bad filename")
|
||||||
@ -162,6 +168,9 @@ func (s *peerAPIServer) OpenFile(baseName string) (rc io.ReadCloser, size int64,
|
|||||||
if s.rootDir == "" {
|
if s.rootDir == "" {
|
||||||
return nil, 0, errors.New("peerapi disabled; no storage configured")
|
return nil, 0, errors.New("peerapi disabled; no storage configured")
|
||||||
}
|
}
|
||||||
|
if s.directFileMode {
|
||||||
|
return nil, 0, errors.New("opens not allowed in direct mode")
|
||||||
|
}
|
||||||
path, ok := s.diskPath(baseName)
|
path, ok := s.diskPath(baseName)
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, 0, errors.New("bad filename")
|
return nil, 0, errors.New("bad filename")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user