Adds unveil(2) support to ii.

---
 ii.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/ii.c b/ii.c
index 7ca3ee8..d7f66ff 100644
--- a/ii.c
+++ b/ii.c
@@ -829,7 +829,7 @@ main(int argc, char *argv[])

 #ifdef __OpenBSD__
        /* OpenBSD pledge(2) support */
-       if (pledge("stdio rpath wpath cpath dpath", NULL) == -1) {
+       if (pledge("stdio rpath wpath cpath dpath unveil", NULL) == -1) {
                fprintf(stderr, "%s: pledge: %s\n", argv0, strerror(errno));
                exit(1);
        }
@@ -842,6 +842,15 @@ main(int argc, char *argv[])
        }
        create_dirtree(ircpath);

+#ifdef __OpenBSD__
+       /* OpenBSD unveil(2) support */
+       if (unveil(ircpath, "rwc") == -1 ||
+           unveil(NULL, NULL) == -1 ) {
+               fprintf(stderr, "%s: unveil: %s\n", argv0, strerror(errno));
+               exit(1);
+       }
+#endif
+
        channelmaster = channel_add(""); /* master channel */
        if (key)
                loginkey(ircfd, key);
--
2.26.2


Reply via email to