$OpenBSD: patch-platform_x11_x11_main_c,v 1.4 2018/04/23 11:55:54 sthen Exp $

add pledge(2) to mupdf-x11 and mupdf-x11-curl:
  - inet dns : with HAVE_CURL only
  - proc exec : opening an external browser on uri link

Index: platform/x11/x11_main.c
--- platform/x11/x11_main.c.orig
+++ platform/x11/x11_main.c
@@ -7,6 +7,7 @@
 #include <X11/keysym.h>
 #include <X11/XF86keysym.h>
 
+#include <errno.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
@@ -735,7 +736,6 @@ void onselreq(Window requestor, Atom selection, Atom t
 void winreloadpage(pdfapp_t *app)
 {
 	XEvent xev;
-	Display *dpy = XOpenDisplay(NULL);
 
 	xev.xclient.type = ClientMessage;
 	xev.xclient.serial = 0;
@@ -746,8 +746,7 @@ void winreloadpage(pdfapp_t *app)
 	xev.xclient.data.l[0] = 0;
 	xev.xclient.data.l[1] = 0;
 	xev.xclient.data.l[2] = 0;
-	XSendEvent(dpy, xwin, 0, 0, &xev);
-	XCloseDisplay(dpy);
+	XSendEvent(xdpy, xwin, 0, 0, &xev);
 }
 
 void winopenuri(pdfapp_t *app, char *buf)
@@ -927,6 +926,20 @@ int main(int argc, char **argv)
 	tmo_at.tv_sec = 0;
 	tmo_at.tv_usec = 0;
 	timeout = NULL;
+
+#ifdef HAVE_CURL
+	if (pledge("stdio rpath inet dns proc exec", NULL) == -1)
+	{
+		fprintf(stderr, "pledge: %s\n", strerror(errno));
+		exit(1);
+	}
+#else
+	if (pledge("stdio rpath proc exec", NULL) == -1)
+	{
+		fprintf(stderr, "pledge: %s\n", strerror(errno));
+		exit(1);
+	}
+#endif
 
 	if (bps)
 		pdfapp_open_progressive(&gapp, filename, 0, bps);
