]> git.armaanb.net Git - stagit.git/commitdiff
assume OpenBSD 5.9+, always try pledge(2) on OpenBSD
authorHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 25 May 2018 16:43:36 +0000 (18:43 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 25 May 2018 16:43:36 +0000 (18:43 +0200)
config.mk
stagit-index.c
stagit.c

index 477f4fc00af5b2e95f9f9e3df7a48690b1468771..ac47e7037fa56c1199e8942d56d982a1dcf3c2c0 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -27,6 +27,3 @@ LDFLAGS = -s ${LIBS}
 #LDFLAGS = -static -s ${LIBS}
 
 CPPFLAGS = -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE ${INCS}
-
-# OpenBSD 5.9+: use pledge(2)
-#CPPFLAGS = -D_XOPEN_SOURCE=700 -D_DEFAULT_SOURCE -D_BSD_SOURCE -DUSE_PLEDGE ${INCS}
index 6b7c699ba7dc82c1c7ca73eddc98fb1153989727..e019793a3c566aa2f1839d38684511b6be23c0eb 100644 (file)
@@ -21,10 +21,6 @@ static char description[255] = "Repositories";
 static char *name = "";
 static char owner[255];
 
-#ifndef USE_PLEDGE
-#define pledge(p1,p2) 0
-#endif
-
 void
 joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
 {
@@ -164,8 +160,10 @@ main(int argc, char *argv[])
 
        git_libgit2_init();
 
+#ifdef __OpenBSD__
        if (pledge("stdio rpath", NULL) == -1)
                err(1, "pledge");
+#endif
 
        writeheader(stdout);
 
index 06c213ce1be7fcaad7438c207fbdbe397a1d025f..86c39200c2cf50340e098b5f125e6d1d42250734 100644 (file)
--- a/stagit.c
+++ b/stagit.c
@@ -65,10 +65,6 @@ static char lastoidstr[GIT_OID_HEXSZ + 2]; /* id + newline + nul byte */
 static FILE *rcachefp, *wcachefp;
 static const char *cachefile;
 
-#ifndef USE_PLEDGE
-#define pledge(p1,p2) 0
-#endif
-
 void
 joinpath(char *buf, size_t bufsiz, const char *path, const char *path2)
 {
@@ -1057,6 +1053,7 @@ main(int argc, char *argv[])
 
        git_libgit2_init();
 
+#ifdef __OpenBSD__
        if (cachefile) {
                if (pledge("stdio rpath wpath cpath fattr", NULL) == -1)
                        err(1, "pledge");
@@ -1064,6 +1061,7 @@ main(int argc, char *argv[])
                if (pledge("stdio rpath wpath cpath", NULL) == -1)
                        err(1, "pledge");
        }
+#endif
 
        if (git_repository_open_ext(&repo, repodir,
                GIT_REPOSITORY_OPEN_NO_SEARCH, NULL) < 0) {