mirror of
https://github.com/netbirdio/netbird.git
synced 2026-05-19 07:09:56 +00:00
Fix Windows lint errcheck/unused and Linux nilerr in console VNC fallback
This commit is contained in:
@@ -5,6 +5,8 @@ package internal
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
vncserver "github.com/netbirdio/netbird/client/vnc/server"
|
vncserver "github.com/netbirdio/netbird/client/vnc/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -21,6 +23,7 @@ func newConsoleVNC() (vncserver.ScreenCapturer, vncserver.InputInjector, error)
|
|||||||
}
|
}
|
||||||
inj, err := vncserver.NewUInputInjector(w, h)
|
inj, err := vncserver.NewUInputInjector(w, h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
log.Debugf("uinput unavailable, falling back to view-only VNC: %v", err)
|
||||||
return poller, &vncserver.StubInputInjector{}, nil
|
return poller, &vncserver.StubInputInjector{}, nil
|
||||||
}
|
}
|
||||||
return poller, inj, nil
|
return poller, inj, nil
|
||||||
|
|||||||
@@ -91,12 +91,6 @@ const (
|
|||||||
wtsDisconnected = 4
|
wtsDisconnected = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
type wtsSessionInfo struct {
|
|
||||||
SessionID uint32
|
|
||||||
WinStationName [66]byte // actually *uint16, but we just need the struct size
|
|
||||||
State uint32
|
|
||||||
}
|
|
||||||
|
|
||||||
// getActiveSessionID returns the session ID of the best session to attach to.
|
// getActiveSessionID returns the session ID of the best session to attach to.
|
||||||
// On a Windows Server with no console display attached, session 1 still
|
// On a Windows Server with no console display attached, session 1 still
|
||||||
// reports WTSActive (login screen "owns" the console), so a naive
|
// reports WTSActive (login screen "owns" the console), so a naive
|
||||||
@@ -176,7 +170,7 @@ func reapOrphanOnPort(portStr string) {
|
|||||||
log.Warnf("reap on port %d: open PID=%d: %v", port, pid, err)
|
log.Warnf("reap on port %d: open PID=%d: %v", port, pid, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
defer windows.CloseHandle(h)
|
defer func() { _ = windows.CloseHandle(h) }()
|
||||||
if !isOurAgentProcess(h) {
|
if !isOurAgentProcess(h) {
|
||||||
log.Warnf("reap on port %d: PID=%d is not a netbird vnc-agent, leaving it alone", port, pid)
|
log.Warnf("reap on port %d: PID=%d is not a netbird vnc-agent, leaving it alone", port, pid)
|
||||||
return
|
return
|
||||||
@@ -307,7 +301,7 @@ func getSystemTokenForSession(sessionID uint32) (windows.Token, error) {
|
|||||||
return dup, nil
|
return dup, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
const agentTokenEnvVar = "NB_VNC_AGENT_TOKEN"
|
const agentTokenEnvVar = "NB_VNC_AGENT_TOKEN" // #nosec G101 -- env var name, not a credential
|
||||||
|
|
||||||
// injectEnvVar appends a KEY=VALUE entry to a Unicode environment block.
|
// injectEnvVar appends a KEY=VALUE entry to a Unicode environment block.
|
||||||
// The block is a sequence of null-terminated UTF-16 strings, terminated by
|
// The block is a sequence of null-terminated UTF-16 strings, terminated by
|
||||||
@@ -698,7 +692,7 @@ func (m *sessionManager) killAgent() {
|
|||||||
// error output, panic stack traces) are forwarded verbatim so failures
|
// error output, panic stack traces) are forwarded verbatim so failures
|
||||||
// during early agent startup remain visible.
|
// during early agent startup remain visible.
|
||||||
func relogAgentOutput(pipe windows.Handle) {
|
func relogAgentOutput(pipe windows.Handle) {
|
||||||
defer windows.CloseHandle(pipe)
|
defer func() { _ = windows.CloseHandle(pipe) }()
|
||||||
f := os.NewFile(uintptr(pipe), "vnc-agent-stderr")
|
f := os.NewFile(uintptr(pipe), "vnc-agent-stderr")
|
||||||
defer f.Close()
|
defer f.Close()
|
||||||
|
|
||||||
|
|||||||
@@ -41,12 +41,6 @@ const (
|
|||||||
keyeventfScanCode = 0x0008
|
keyeventfScanCode = 0x0008
|
||||||
)
|
)
|
||||||
|
|
||||||
// winlogonDesktopName is the name of the Windows secure desktop that hosts the
|
|
||||||
// logon UI, Ctrl+Alt+Del screen, UAC prompts, and credential dialogs. Its
|
|
||||||
// clipboard is isolated from the interactive Default desktop, so pasting via
|
|
||||||
// the clipboard API does not work there. We fall back to synthesizing the
|
|
||||||
// text as Unicode keystrokes.
|
|
||||||
const winlogonDesktopName = "Winlogon"
|
|
||||||
|
|
||||||
// maxTypedClipboardChars caps the number of characters we will synthesize as
|
// maxTypedClipboardChars caps the number of characters we will synthesize as
|
||||||
// keystrokes when falling back on the Winlogon desktop. Passwords are short;
|
// keystrokes when falling back on the Winlogon desktop. Passwords are short;
|
||||||
@@ -258,7 +252,7 @@ func signalSAS() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
ev := windows.Handle(h)
|
ev := windows.Handle(h)
|
||||||
defer windows.CloseHandle(ev)
|
defer func() { _ = windows.CloseHandle(ev) }()
|
||||||
if err := windows.SetEvent(ev); err != nil {
|
if err := windows.SetEvent(ev); err != nil {
|
||||||
log.Warnf("SetEvent SAS: %v", err)
|
log.Warnf("SetEvent SAS: %v", err)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
//go:build !windows
|
||||||
|
|
||||||
package server
|
package server
|
||||||
|
|
||||||
// keysymForASCIIRune maps an ASCII rune to (X11 keysym for the unshifted
|
// keysymForASCIIRune maps an ASCII rune to (X11 keysym for the unshifted
|
||||||
|
|||||||
@@ -166,7 +166,7 @@ func createSASEvent() (windows.Handle, bool) {
|
|||||||
// signalled, until ctx is cancelled. Recovers from panics inside SendSAS so
|
// signalled, until ctx is cancelled. Recovers from panics inside SendSAS so
|
||||||
// a future ABI surprise doesn't tear down the service.
|
// a future ABI surprise doesn't tear down the service.
|
||||||
func runSASListenerLoop(ctx context.Context, ev windows.Handle) {
|
func runSASListenerLoop(ctx context.Context, ev windows.Handle) {
|
||||||
defer windows.CloseHandle(ev)
|
defer func() { _ = windows.CloseHandle(ev) }()
|
||||||
defer func() {
|
defer func() {
|
||||||
if r := recover(); r != nil {
|
if r := recover(); r != nil {
|
||||||
log.Warnf("SAS listener recovered from panic: %v", r)
|
log.Warnf("SAS listener recovered from panic: %v", r)
|
||||||
|
|||||||
Reference in New Issue
Block a user