aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/mandocdb.c
diff options
context:
space:
mode:
authorIngo Schwarze <schwarze@openbsd.org>2015-11-06 17:33:34 +0000
committerIngo Schwarze <schwarze@openbsd.org>2015-11-06 17:33:34 +0000
commit7ab4e1278a5b8ac4289c450b2bf85da2aad06ba4 (patch)
treeefe602222ebf45e9e6f716c8795ff1f52faa4163 /mandocdb.c
parent3fffa6c6072826f70aebe72863968bffb9d714cc (diff)
downloadmandoc-7ab4e1278a5b8ac4289c450b2bf85da2aad06ba4.tar.gz
mandoc-7ab4e1278a5b8ac4289c450b2bf85da2aad06ba4.tar.zst
mandoc-7ab4e1278a5b8ac4289c450b2bf85da2aad06ba4.zip
merge pledge(2) support from OpenBSD
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 26c59b62..b5760709 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -1,4 +1,4 @@
-/* $Id: mandocdb.c,v 1.206 2015/11/06 16:30:33 schwarze Exp $ */
+/* $Id: mandocdb.c,v 1.207 2015/11/06 17:33:34 schwarze Exp $ */
/*
* Copyright (c) 2011, 2012 Kristaps Dzonsons <kristaps@bsd.lv>
* Copyright (c) 2011-2015 Ingo Schwarze <schwarze@openbsd.org>
@@ -337,6 +337,13 @@ mandocdb(int argc, char *argv[])
size_t j, sz;
int ch, i;
+#if HAVE_PLEDGE
+ if (pledge("stdio rpath wpath cpath fattr flock proc exec", NULL) == -1) {
+ perror("pledge");
+ return (int)MANDOCLEVEL_SYSERR;
+ }
+#endif
+
memset(&conf, 0, sizeof(conf));
memset(stmts, 0, STMT__MAX * sizeof(sqlite3_stmt *));
@@ -410,6 +417,13 @@ mandocdb(int argc, char *argv[])
argc -= optind;
argv += optind;
+#if HAVE_PLEDGE
+ if (nodb && pledge("stdio rpath", NULL) == -1) {
+ perror("pledge");
+ return (int)MANDOCLEVEL_SYSERR;
+ }
+#endif
+
if (OP_CONFFILE == op && argc > 0) {
warnx("-C: Too many arguments");
goto usage;
@@ -435,6 +449,14 @@ mandocdb(int argc, char *argv[])
* The existing database is usable. Process
* all files specified on the command-line.
*/
+#if HAVE_PLEDGE
+ if (!nodb && pledge("stdio rpath wpath cpath fattr flock",
+ NULL) == -1) {
+ perror("pledge");
+ exitcode = (int)MANDOCLEVEL_SYSERR;
+ goto out;
+ }
+#endif
use_all = 1;
for (i = 0; i < argc; i++)
filescan(argv[i]);