add OpenBSD pledge(2) support using -DUSE_PLEDGE
This commit is contained in:
parent
eae9437f94
commit
aa36e0c9b4
3 changed files with 29 additions and 3 deletions
10
config.mk
10
config.mk
|
@ -4,6 +4,9 @@
|
|||
PREFIX = /usr/local
|
||||
MANPREFIX = ${PREFIX}/man
|
||||
|
||||
# compiler and linker
|
||||
#CC = cc
|
||||
|
||||
GITINC = /usr/local/include
|
||||
GITLIB = /usr/local/lib
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
@ -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;
|
||||
|
|
11
stagit.c
11
stagit.c
|
@ -64,6 +64,14 @@ static char lastoidstr[GIT_OID_HEXSZ + 2]; /* id + newline + nul byte */
|
|||
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)
|
||||
{
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue