OpenBSD pledge(2) - irc - IRC client based on c9x.me/irc client
 (HTM) git clone git://git.codemadness.org/irc
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit 3749ff97c5d5b643a4a570db0b22599445defeb2
 (DIR) parent 976e3a6bc42916575e0ff2ff758c2544bd264ea8
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Fri, 26 May 2017 13:05:50 +0200
       
       OpenBSD pledge(2)
       
       Diffstat:
         M irc.c                               |      18 ++++++++++++++++++
       
       1 file changed, 18 insertions(+), 0 deletions(-)
       ---
 (DIR) diff --git a/irc.c b/irc.c
       @@ -22,6 +22,10 @@
        #include <wchar.h>
        #include <openssl/ssl.h>
        
       +#ifndef __OpenBSD__
       +#define pledge(a,b) 0
       +#endif
       +
        #undef CTRL
        #define CTRL(x)  (x & 037)
        
       @@ -813,6 +817,11 @@ main(int argc, char *argv[])
                int o, reconn;
        
                signal(SIGPIPE, SIG_IGN);
       +        if (pledge("stdio dns inet rpath cpath wpath tty", NULL) < 0) {
       +                fprintf(stderr, "pledge: %s\n", strerror(errno));
       +                return 1;
       +        }
       +
                while ((o = getopt(argc, argv, "thk:n:u:s:p:l:")) >= 0)
                        switch (o) {
                        case 'h':
       @@ -842,6 +851,11 @@ main(int argc, char *argv[])
                                port = optarg;
                                break;
                        }
       +
       +        if (pledge("stdio dns inet rpath tty", NULL) < 0) {
       +                fprintf(stderr, "pledge: %s\n", strerror(errno));
       +                return 1;
       +        }
                if (!user)
                        user = "anonymous";
                if (!nick[0] && ircnick && strlen(ircnick) < sizeof nick)
       @@ -854,6 +868,10 @@ main(int argc, char *argv[])
                err = dial(server, port);
                if (err)
                        panic(err);
       +        if (pledge("stdio tty", NULL) < 0) {
       +                fprintf(stderr, "pledge: %s\n", strerror(errno));
       +                return 1;
       +        }
                chadd(server, 0);
                sinit(key, nick, user);
                reconn = 0;