Address CodeRabbit review on embedded VNC PR

This commit is contained in:
Viktor Liu
2026-05-24 18:52:57 +02:00
parent 4e3e3ce6d3
commit bf2fb2fd44
7 changed files with 58 additions and 14 deletions

View File

@@ -155,8 +155,10 @@ func (e *Engine) startVNCServer() error {
}
// updateVNCServerAuth updates VNC fine-grained access control from management.
// A nil vncAuth clears all authorized users and session pubkeys so management
// can revoke access by omitting the field on the next sync.
func (e *Engine) updateVNCServerAuth(vncAuth *mgmProto.VNCAuth) {
if vncAuth == nil || e.vncSrv == nil {
if e.vncSrv == nil {
return
}
@@ -165,6 +167,11 @@ func (e *Engine) updateVNCServerAuth(vncAuth *mgmProto.VNCAuth) {
return
}
if vncAuth == nil {
vncSrv.UpdateVNCAuth(&sshauth.Config{})
return
}
protoUsers := vncAuth.GetAuthorizedUsers()
authorizedUsers := make([]sshuserhash.UserIDHash, len(protoUsers))
for i, hash := range protoUsers {
@@ -207,12 +214,17 @@ func (e *Engine) updateVNCServerAuth(vncAuth *mgmProto.VNCAuth) {
}
// GetVNCServerStatus returns whether the VNC server is running and the list
// of active VNC sessions.
// of active VNC sessions. The pointer is captured under syncMsgMux so a
// concurrent updateVNC/stopVNCServer cannot swap it out between the nil
// check and the ActiveSessions call.
func (e *Engine) GetVNCServerStatus() (enabled bool, sessions []vncserver.ActiveSessionInfo) {
if e.vncSrv == nil {
e.syncMsgMux.Lock()
vncSrv := e.vncSrv
e.syncMsgMux.Unlock()
if vncSrv == nil {
return false, nil
}
return true, e.vncSrv.ActiveSessions()
return true, vncSrv.ActiveSessions()
}
func (e *Engine) stopVNCServer() error {