]> git.eshelyaron.com Git - emacs.git/commitdiff
Improve some behavior when the X server does not trust Emacs
authorPo Lu <luangruo@yahoo.com>
Fri, 9 Dec 2022 10:28:42 +0000 (18:28 +0800)
committerPo Lu <luangruo@yahoo.com>
Fri, 9 Dec 2022 10:30:23 +0000 (18:30 +0800)
* src/xterm.c (x_dnd_begin_drag_and_drop): Display error when
Emacs is untrusted instead of hanging indefinitely.
(x_focus_frame): Simply return instead of wasting time when
Emacs is untrusted.

src/xterm.c

index 4c859c46c3134a2cf2962ae82e00428eba69c6cb..872326392a6a70f96ca88ca309336f615ee65625 100644 (file)
@@ -12308,6 +12308,13 @@ x_dnd_begin_drag_and_drop (struct frame *f, Time time, Atom xaction,
   struct xi_device_t *device;
 #endif
 
+  if (FRAME_DISPLAY_INFO (f)->untrusted)
+    /* Untrusted clients cannot send messages to trusted clients or
+       read the window tree, so drag and drop will likely not work at
+       all.  */
+    error ("Drag-and-drop is not possible when the client is"
+          " not trusted by the X server.");
+
   base = SPECPDL_INDEX ();
 
   /* Bind this here to avoid juggling bindings and SAFE_FREE in
@@ -27949,12 +27956,17 @@ x_focus_frame (struct frame *f, bool noactivate)
   struct x_display_info *dpyinfo;
   Time time;
 
+  dpyinfo = FRAME_DISPLAY_INFO (f);
+
+  if (dpyinfo->untrusted)
+    /* The X server ignores all input focus related requests from
+       untrusted clients.  */
+    return;
+
   /* The code below is not reentrant wrt to dpyinfo->x_focus_frame and
      friends being set.  */
   block_input ();
 
-  dpyinfo = FRAME_DISPLAY_INFO (f);
-
   if (FRAME_X_EMBEDDED_P (f))
     /* For Xembedded frames, normally the embedder forwards key
        events.  See XEmbed Protocol Specification at