Enforces disable networks

This commit is contained in:
riccardom
2026-06-05 12:29:39 +02:00
parent 6355a24deb
commit 01a4c245a7
3 changed files with 21 additions and 4 deletions

View File

@@ -23,6 +23,7 @@ const (
KeyDisableAdvancedSettings = "disableAdvancedSettings"
KeyDisableUpdateSettings = "disableUpdateSettings"
KeyDisableProfiles = "disableProfiles"
KeyDisableNetworks = "disableNetworks"
KeyDisableClientRoutes = "disableClientRoutes"
KeyDisableServerRoutes = "disableServerRoutes"
KeyBlockInbound = "blockInbound"
@@ -56,6 +57,7 @@ var AllKeys = []string{
KeyDisableAdvancedSettings,
KeyDisableUpdateSettings,
KeyDisableProfiles,
KeyDisableNetworks,
KeyDisableClientRoutes,
KeyDisableServerRoutes,
KeyBlockInbound,

View File

@@ -30,7 +30,7 @@ func (s *Server) ListNetworks(context.Context, *proto.ListNetworksRequest) (*pro
s.mutex.Lock()
defer s.mutex.Unlock()
if s.networksDisabled {
if s.checkNetworksDisabled() {
return nil, gstatus.Errorf(codes.Unavailable, errNetworksDisabled)
}
@@ -143,7 +143,7 @@ func (s *Server) SelectNetworks(_ context.Context, req *proto.SelectNetworksRequ
s.mutex.Lock()
defer s.mutex.Unlock()
if s.networksDisabled {
if s.checkNetworksDisabled() {
return nil, gstatus.Errorf(codes.Unavailable, errNetworksDisabled)
}
@@ -195,7 +195,7 @@ func (s *Server) DeselectNetworks(_ context.Context, req *proto.SelectNetworksRe
s.mutex.Lock()
defer s.mutex.Unlock()
if s.networksDisabled {
if s.checkNetworksDisabled() {
return nil, gstatus.Errorf(codes.Unavailable, errNetworksDisabled)
}

View File

@@ -1699,7 +1699,7 @@ func (s *Server) GetFeatures(ctx context.Context, msg *proto.GetFeaturesRequest)
features := &proto.GetFeaturesResponse{
DisableProfiles: s.checkProfilesDisabled(),
DisableUpdateSettings: s.checkUpdateSettingsDisabled(),
DisableNetworks: s.networksDisabled,
DisableNetworks: s.checkNetworksDisabled(),
}
// MDM kill switch: read the value from the active policy on the
@@ -1746,6 +1746,21 @@ func (s *Server) checkProfilesDisabled() bool {
return false
}
func (s *Server) checkNetworksDisabled() bool {
// CLI flag set at service install time wins.
if s.networksDisabled {
return true
}
// MDM kill switch: either source can disable the feature; neither
// can re-enable a switch the other has set.
if s.config != nil {
if v, ok := s.config.Policy().GetBool(mdm.KeyDisableNetworks); ok && v {
return true
}
}
return false
}
func (s *Server) checkUpdateSettingsDisabled() bool {
// CLI flag set at service install time wins.
if s.updateSettingsDisabled {