$OpenBSD$
--- src/pdfgrep.cc.orig	Mon Mar  6 15:21:15 2017
+++ src/pdfgrep.cc	Mon Mar  6 15:24:27 2017
@@ -423,6 +423,12 @@ static void handle_poppler_errors(const string &msg, v
 int main(int argc, char** argv)
 {
 	Options options;
+
+	if (pledge("stdio rpath wpath cpath tty", NULL) == -1) {
+		fprintf (stderr, "pdfgrep: pledge\n");
+		exit (1);
+	}
+
 	init_colors(options.outconf.colors);
 
 	// Set locale to user-preference. If this locale is an UTF-8 locale, the
@@ -649,6 +655,11 @@ int main(int argc, char** argv)
 	bool color_tty = isatty(STDOUT_FILENO) && getenv("TERM") &&
 		strcmp(getenv("TERM"), "dumb");
 
+	if (pledge("stdio rpath wpath cpath", NULL) == -1) {
+		fprintf (stderr, "pdfgrep: pledge\n");
+		exit (1);
+	}
+
 	options.outconf.color =
 		use_colors == COLOR_ALWAYS
 		|| (use_colors == COLOR_AUTO && color_tty);
@@ -689,6 +700,11 @@ int main(int argc, char** argv)
 			char *limitstr = getenv("PDFGREP_CACHE_LIMIT");
 			unsigned int limit = limitstr ? strtoul(limitstr, NULL, 10) : 200;
 			limit_cachesize(options.cache_directory.c_str(), limit);
+		}
+	} else {
+		if (pledge("stdio rpath", NULL) == -1) {
+			fprintf (stderr, "pdfgrep: pledge\n");
+			exit (1);
 		}
 	}
 
