mirror of
https://github.com/netbirdio/netbird.git
synced 2026-09-16 11:49:06 +02:00
Recycle the macOS VNC agent per connection so permission prompts work
This commit is contained in:
@@ -74,6 +74,8 @@ var vncAgentCmd = &cobra.Command{
|
||||
log.Debugf("chmod %s: %v", vncAgentSocket, err)
|
||||
}
|
||||
|
||||
ctx := cmd.Context()
|
||||
|
||||
capturer, injector, err := newAgentResources()
|
||||
if err != nil {
|
||||
_ = ln.Close()
|
||||
@@ -87,12 +89,12 @@ var vncAgentCmd = &cobra.Command{
|
||||
Listener: ln,
|
||||
})
|
||||
|
||||
if err := srv.Start(cmd.Context(), netip.AddrPort{}, netip.Prefix{}); err != nil {
|
||||
if err := srv.Start(ctx, netip.AddrPort{}, netip.Prefix{}); err != nil {
|
||||
return fmt.Errorf("start vnc server: %w", err)
|
||||
}
|
||||
log.Infof("vnc-agent listening on %s, ready", vncAgentSocket)
|
||||
|
||||
<-cmd.Context().Done()
|
||||
<-ctx.Done()
|
||||
log.Info("vnc-agent context cancelled, shutting down")
|
||||
return srv.Stop()
|
||||
},
|
||||
|
||||
@@ -9,12 +9,12 @@ import (
|
||||
)
|
||||
|
||||
func newAgentResources() (vncserver.ScreenCapturer, vncserver.InputInjector, error) {
|
||||
// Ask for Screen Recording here and nowhere else: this process runs as the
|
||||
// console user, which is what TCC requires for a user-scope service, and it
|
||||
// is the point where somebody is demonstrably trying to view the screen.
|
||||
// Granting it also requires the capturing process to restart, which comes
|
||||
// for free since the agent is respawned per session.
|
||||
vncserver.PrimeScreenCapturePermission()
|
||||
// Ask for Screen Recording here and nowhere else. This process runs as the
|
||||
// console user, which TCC requires for a user-scope service, and it is fresh
|
||||
// per connection, which is what makes the dialog appear at all: TCC shows it
|
||||
// once per process. The request blocks until the user answers, so it also
|
||||
// keeps the Accessibility ask that follows the first input out of its way.
|
||||
vncserver.RequestScreenRecording()
|
||||
|
||||
capturer := vncserver.NewMacPoller()
|
||||
injector, err := vncserver.NewMacInputInjector()
|
||||
|
||||
Reference in New Issue
Block a user