diff options
author | 2015-11-06 17:33:34 +0000 | |
---|---|---|
committer | 2015-11-06 17:33:34 +0000 | |
commit | 7ab4e1278a5b8ac4289c450b2bf85da2aad06ba4 (patch) | |
tree | efe602222ebf45e9e6f716c8795ff1f52faa4163 /mandocdb.c | |
parent | 3fffa6c6072826f70aebe72863968bffb9d714cc (diff) | |
download | mandoc-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.c | 24 |
1 files changed, 23 insertions, 1 deletions
@@ -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]); |