On Fri, Sep 08, 2023 at 08:55:10AM -0300, Lucas de Sena wrote:
[...]
> Quoting from `xenocara/app/xclock/xclock.c`:
>
> > {
> > /* force reading of XErrorDB into memory to avoid adding "rpath" to
> > pledge below */
> > char buf[1];
> >
> > (void)XGetErrorDatabaseText(XtDisplay(toplevel), "XProtoError", "0", "",
> > buf, 1);
> > }
> > if (pledge("stdio", NULL) == -1)
> > err(1, "pledge");
In xclock.c, this happens right before XtAppMainLoop, and it looks like
we could do the exact same thing for xeyes... Is this better?
Index: xeyes.c
===================================================================
RCS file: /cvs/xenocara/app/xeyes/xeyes.c,v
retrieving revision 1.5
diff -u -p -r1.5 xeyes.c
--- xeyes.c 29 Aug 2021 17:50:32 -0000 1.5
+++ xeyes.c 12 Sep 2023 01:34:03 -0000
@@ -32,6 +32,10 @@ from the X Consortium.
# include "config.h"
#endif
+#ifdef HAVE_PLEDGE
+# include <unistd.h>
+# include <err.h>
+#endif
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <X11/Shell.h>
@@ -142,6 +146,19 @@ main(int argc, char **argv)
XtRealizeWidget (toplevel);
(void) XSetWMProtocols (XtDisplay(toplevel), XtWindow(toplevel),
&wm_delete_window, 1);
+
+#ifdef HAVE_PLEDGE
+ {
+ /* force reading of XErrorDB into memory to avoid adding "rpath" to
+ * pledge below */
+ char buf[1];
+
+ (void)XGetErrorDatabaseText(XtDisplay(toplevel), "XProtoError", "0",
"", buf, 1);
+ }
+ if (pledge("stdio", NULL) == -1)
+ err(1, "pledge");
+#endif
+
XtAppMainLoop(app_context);
return 0;