$OpenBSD: patch-source_tools_pdfshow_c,v 1.7 2019/07/30 13:41:14 sthen Exp $

add pledge(2) to "mutool show":
  - rpath : dropped after opening
  - no need of wpath cpath for -o, as the open is already done at this place

Index: source/tools/pdfshow.c
--- source/tools/pdfshow.c.orig
+++ source/tools/pdfshow.c
@@ -5,6 +5,9 @@
 #include "mupdf/fitz.h"
 #include "mupdf/pdf.h"
 
+#include <unistd.h>
+#include <errno.h>
+#include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
 #include <string.h>
@@ -560,6 +563,12 @@ int pdfshow_main(int argc, char **argv)
 	char *output = NULL;
 	int c;
 
+	if (pledge("stdio rpath", NULL) == -1)
+	{
+		fprintf(stderr, "pledge: %s\n", strerror(errno));
+		exit(1);
+	}
+
 	ctx = fz_new_context(NULL, NULL, FZ_STORE_UNLIMITED);
 	if (!ctx)
 	{
@@ -594,6 +603,13 @@ int pdfshow_main(int argc, char **argv)
 	fz_try(ctx)
 	{
 		doc = pdf_open_document(ctx, filename);
+
+		if (pledge("stdio", NULL) == -1)
+		{
+			fprintf(stderr, "pledge: %s\n", strerror(errno));
+			exit(1);
+		}
+
 		if (pdf_needs_password(ctx, doc))
 			if (!pdf_authenticate_password(ctx, doc, password))
 				fz_warn(ctx, "cannot authenticate password: %s", filename);
