]> source.dussan.org Git - tigervnc.git/commitdiff
Improve logging around screen resizing
authorPierre Ossman <ossman@cendio.se>
Tue, 25 Jan 2022 08:56:31 +0000 (09:56 +0100)
committerPierre Ossman <ossman@cendio.se>
Tue, 25 Jan 2022 08:56:31 +0000 (09:56 +0100)
Avoid duplication, and add logging for some more error conditions so
it's possible to see in the logs why a resize has failed or produced
unexpected results.

common/rfb/VNCSConnectionST.cxx
common/rfb/VNCServerST.cxx
unix/common/randr.cxx
unix/x0vncserver/XDesktop.cxx
unix/xserver/hw/vnc/XserverDesktop.cc

index f51fb57b978b542b9c054be96a2a7e0016cecaac..9f58e7868e14fdbeaa204aafae439b50e05defcc 100644 (file)
@@ -651,11 +651,20 @@ void VNCSConnectionST::setDesktopSize(int fb_width, int fb_height,
                                       const ScreenSet& layout)
 {
   unsigned int result;
+  char buffer[2048];
 
-  if (!accessCheck(AccessSetDesktopSize) || !rfb::Server::acceptSetDesktopSize)
+  vlog.debug("Got request for framebuffer resize to %dx%d",
+             fb_width, fb_height);
+  layout.print(buffer, sizeof(buffer));
+  vlog.debug("%s", buffer);
+
+  if (!accessCheck(AccessSetDesktopSize) ||
+      !rfb::Server::acceptSetDesktopSize) {
+    vlog.debug("Rejecting unauthorized framebuffer resize request");
     result = resultProhibited;
-  else
+  } else {
     result = server->setDesktopSize(this, fb_width, fb_height, layout);
+  }
 
   writer()->writeDesktopSize(reasonClient, result);
 }
index 3a7caf5cb9b2497e6153fd3f054e7251081e1e6d..411cfd5e577ce82319e5aa7ace5db31439a7e610 100644 (file)
@@ -539,12 +539,16 @@ unsigned int VNCServerST::setDesktopSize(VNCSConnectionST* requester,
 
   // We can't handle a framebuffer larger than this, so don't let a
   // client set one (see PixelBuffer.cxx)
-  if ((fb_width > 16384) || (fb_height > 16384))
+  if ((fb_width > 16384) || (fb_height > 16384)) {
+    slog.error("Rejecting too large framebuffer resize request");
     return resultProhibited;
+  }
 
   // Don't bother the desktop with an invalid configuration
-  if (!layout.validate(fb_width, fb_height))
+  if (!layout.validate(fb_width, fb_height)) {
+    slog.error("Invalid screen layout requested by client");
     return resultInvalid;
+  }
 
   // FIXME: the desktop will call back to VNCServerST and an extra set
   // of ExtendedDesktopSize messages will be sent. This is okay
index 95c1f332305c962bc7dc4139a0d7cb855c663508..72b9a1259455be72a9bd0c587a91b00015689dd7 100644 (file)
@@ -326,8 +326,11 @@ static unsigned int _setScreenLayout(bool dryrun,
     i = getPreferredScreenOutput(outputIdMap, disabledOutputs);
 
     /* Shouldn't happen */
-    if (i == -1)
+    if (i == -1) {
+      if (logErrors)
+        vlog.error("Cannot find an available output for new screen layout");
       return rfb::resultInvalid;
+    }
     output = vncRandRGetOutputId(i);
 
     /*
index 351dbb2c5dbe8f29bd2022208ff3bb427795b55b..f2046e43e994293c902f6f345894dab643337081 100644 (file)
@@ -503,12 +503,6 @@ unsigned int XDesktop::setScreenLayout(int fb_width, int fb_height,
                                        const rfb::ScreenSet& layout)
 {
 #ifdef HAVE_XRANDR
-  char buffer[2048];
-  vlog.debug("Got request for framebuffer resize to %dx%d",
-             fb_width, fb_height);
-  layout.print(buffer, sizeof(buffer));
-  vlog.debug("%s", buffer);
-
   XRRScreenResources *res = XRRGetScreenResources(dpy, DefaultRootWindow(dpy));
   if (!res) {
     vlog.error("XRRGetScreenResources failed");
index 8a3cdb5ce88a4cda8f919e55f2f2a4b993de591d..603e1e5efc1881248573db9765e466237333574e 100644 (file)
@@ -466,12 +466,6 @@ unsigned int XserverDesktop::setScreenLayout(int fb_width, int fb_height,
 {
   unsigned int result;
 
-  char buffer[2048];
-  vlog.debug("Got request for framebuffer resize to %dx%d",
-             fb_width, fb_height);
-  layout.print(buffer, sizeof(buffer));
-  vlog.debug("%s", buffer);
-
   vncSetGlueContext(screenIndex);
   result = ::setScreenLayout(fb_width, fb_height, layout, &outputIdMap);