| tadd OpenBSD pledge(2) support using -DUSE_PLEDGE - stagit - static git page ge… | |
| git clone git://src.adamsgaard.dk/stagit | |
| Log | |
| Files | |
| Refs | |
| README | |
| LICENSE | |
| --- | |
| commit aa36e0c9b4d8da06c5dc03a461f9d3fe69a1e7fb | |
| parent eae9437f944f04619cbda9ce7eb460f6ff0d7f4c | |
| Author: Hiltjo Posthuma <[email protected]> | |
| Date: Tue, 3 May 2016 00:33:56 +0200 | |
| add OpenBSD pledge(2) support using -DUSE_PLEDGE | |
| Diffstat: | |
| M config.mk | 10 +++++++--- | |
| M stagit-index.c | 11 +++++++++++ | |
| M stagit.c | 11 +++++++++++ | |
| 3 files changed, 29 insertions(+), 3 deletions(-) | |
| --- | |
| diff --git a/config.mk b/config.mk | |
| t@@ -4,6 +4,9 @@ | |
| PREFIX = /usr/local | |
| MANPREFIX = ${PREFIX}/man | |
| +# compiler and linker | |
| +#CC = cc | |
| + | |
| GITINC = /usr/local/include | |
| GITLIB = /usr/local/lib | |
| t@@ -23,6 +26,7 @@ LDFLAGS = -s ${LIBS} | |
| #CFLAGS = -static -O2 -std=c99 ${INCS} | |
| #LDFLAGS = -static -s ${LIBS} | |
| -CPPFLAGS= -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE ${INCS} | |
| -# compiler and linker | |
| -#CC = cc | |
| +CPPFLAGS = -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE ${INCS} | |
| + | |
| +# OpenBSD 5.9+: use pledge(2) | |
| +#CPPFLAGS += -DUSE_PLEDGE | |
| diff --git a/stagit-index.c b/stagit-index.c | |
| t@@ -23,6 +23,14 @@ static char description[255] = "Repositories"; | |
| static char *name = ""; | |
| static char owner[255]; | |
| +#ifndef USE_PLEDGE | |
| +int | |
| +pledge(const char *promises, const char *paths[]) | |
| +{ | |
| + return 0; | |
| +} | |
| +#endif | |
| + | |
| /* Escape characters below as HTML 2.0 / XML 1.0. */ | |
| void | |
| xmlencode(FILE *fp, const char *s, size_t len) | |
| t@@ -154,6 +162,9 @@ main(int argc, char *argv[]) | |
| char path[PATH_MAX], repodirabs[PATH_MAX + 1]; | |
| int i, ret = 0; | |
| + if (pledge("stdio rpath", NULL) == -1) | |
| + err(1, "pledge"); | |
| + | |
| if (argc < 2) { | |
| fprintf(stderr, "%s [repodir...]\n", argv[0]); | |
| return 1; | |
| diff --git a/stagit.c b/stagit.c | |
| t@@ -64,6 +64,14 @@ static char lastoidstr[GIT_OID_HEXSZ + 2]; /* id + newline … | |
| static FILE *rcachefp, *wcachefp; | |
| static const char *cachefile; | |
| +#ifndef USE_PLEDGE | |
| +int | |
| +pledge(const char *promises, const char *paths[]) | |
| +{ | |
| + return 0; | |
| +} | |
| +#endif | |
| + | |
| void | |
| deltainfo_free(struct deltainfo *di) | |
| { | |
| t@@ -1033,6 +1041,9 @@ main(int argc, char *argv[]) | |
| size_t n; | |
| int i, fd; | |
| + if (pledge("stdio rpath wpath cpath", NULL) == -1) | |
| + err(1, "pledge"); | |
| + | |
| for (i = 1; i < argc; i++) { | |
| if (argv[i][0] != '-') { | |
| if (repodir) |