summaryrefslogtreecommitdiffstats
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
commit76c7674a39f6ce0879ba3aa3140b438db94473e2 (patch)
tree68ab1d5d56311b77087eb0ea26ea0792b18eac37 /mandocdb.c
parenta8ce1f9346beb8f6af8a2704f58ad1be8a491a40 (diff)
downloadmandoc-76c7674a39f6ce0879ba3aa3140b438db94473e2.tar.gz
merge pledge(2) support from OpenBSD
Diffstat (limited to 'mandocdb.c')
-rw-r--r--mandocdb.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/mandocdb.c b/mandocdb.c
index 94c1ba5a..b2442e47 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -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]);