From ba9c13a09069ac2e93fa3b1f330927786ce52040 Mon Sep 17 00:00:00 2001 From: Zac Bergquist Date: Sat, 2 Dec 2023 18:32:48 -0700 Subject: [PATCH] Default desktop port to 3389 if not specified When specifying hosts in the config file, Teleport will automatically set the port to 3389 if it is not otherwise specified. This behavior is different with tctl or our API - in these cases, we don't default to the correct port, and attempts to connect to these desktops will fail. We now parse the desktop addr at connect time and set the port if it is not provided. Closes #31646 --- lib/srv/desktop/windows_server.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/srv/desktop/windows_server.go b/lib/srv/desktop/windows_server.go index 04c388b89b659..dddc194a023cd 100644 --- a/lib/srv/desktop/windows_server.go +++ b/lib/srv/desktop/windows_server.go @@ -760,8 +760,7 @@ func (s *WindowsService) handleConnection(proxyConn *tls.Conn) { return } if len(desktops) == 0 { - log.Error("no windows desktops with HostID %s and Name %s", s.cfg.Heartbeat.HostUUID, - desktopName) + log.Errorf("desktop %v/%v not found", s.cfg.Heartbeat.HostUUID, desktopName) sendTDPError(fmt.Sprintf("Could not find desktop %v.", desktopName)) return } @@ -795,6 +794,11 @@ func (s *WindowsService) connectRDP(ctx context.Context, log logrus.FieldLogger, return trace.Wrap(err) } + addr, err := utils.ParseHostPortAddr(desktop.GetAddr(), defaults.RDPListenPort) + if err != nil { + return trace.Wrap(err) + } + sessionID := session.NewID() // in order for the session to be recorded, the cluster's session recording mode must @@ -872,7 +876,7 @@ func (s *WindowsService) connectRDP(ctx context.Context, log logrus.FieldLogger, return s.generateUserCert(ctx, username, ttl, desktop, createUsers, groups) }, CertTTL: windows.CertTTL, - Addr: desktop.GetAddr(), + Addr: addr.String(), Conn: tdpConn, AuthorizeFn: authorize, AllowClipboard: authCtx.Checker.DesktopClipboard(),