Skip to content

Commit

Permalink
protect tracked files with mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
capnspacehook committed Oct 30, 2024
1 parent 2667d93 commit 4f0b98d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions tool/teleport/common/sftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"os/user"
"path"
"strings"
"sync"
"sync/atomic"
"time"

Expand Down Expand Up @@ -90,6 +91,7 @@ type allowedOps struct {
type sftpHandler struct {
logger *log.Entry
allowed *allowedOps
mtx sync.Mutex
files []*trackedFile
events chan<- apievents.AuditEvent
}
Expand Down Expand Up @@ -245,7 +247,9 @@ func (s *sftpHandler) openFile(req *sftp.Request) (sftp.WriterAtReaderAt, error)
return nil, err
}
trackFile := &trackedFile{file: f}
s.mtx.Lock()
s.files = append(s.files, trackFile)
s.mtx.Unlock()

return trackFile, nil
}
Expand Down

0 comments on commit 4f0b98d

Please sign in to comment.