|
|
@@ -103,6 +103,11 @@ func (s *Server) Rebind(ctx context.Context, path string, acc Access) error {
|
|
|
s.mu.Lock()
|
|
|
defer s.mu.Unlock()
|
|
|
|
|
|
+ // Set before the access is applied, not after, so no connection the new access
|
|
|
+ // admits is checked against the old setting. Early is safe either way: a member
|
|
|
+ // arriving before a group's mode is set is refused by the kernel, and with a group
|
|
|
+ // being taken away the peer check applies a moment before the mode tightens.
|
|
|
+ prev := s.trustSocket.Swap(acc.Group != nil)
|
|
|
err := s.rebindLocked(ctx, path, acc, func(ln net.Listener) io.Closer {
|
|
|
logListening(s.l, path, acc)
|
|
|
// Closing the listener, when it is given up, ends the accept loop on the
|
|
|
@@ -111,8 +116,9 @@ func (s *Server) Rebind(ctx context.Context, path string, acc Access) error {
|
|
|
go s.accept(ln, s.semaphore())
|
|
|
return ln
|
|
|
})
|
|
|
- if err == nil {
|
|
|
- s.trustSocket.Store(acc.Group != nil)
|
|
|
+ if err != nil {
|
|
|
+ // Whatever was serving still is, with the access it had.
|
|
|
+ s.trustSocket.Store(prev)
|
|
|
}
|
|
|
return err
|
|
|
}
|