Re: [hackers] [ii] add OpenBSD pledge support - thanks Gleydson Soares || Nico Golde

From: Ali H. Fardan <raiz_AT_firemail.cc>
Date: Fri, 02 Sep 2016 20:43:17 +0300

Would be helpful if you provided error string for pledge(), I have
also provided a pledge patch for sic and I submitted it a while ago
to the mailing list (maybe you did not notice it).

Raiz

diff --git a/sic.c b/sic.c
index ce6d216..6e37c60 100644
--- a/sic.c
+++ b/sic.c
_AT_@ -182,6 +182,10 @@ main(int argc, char *argv[]) {
          setbuf(stdout, NULL);
          setbuf(srv, NULL);
          setbuf(stdin, NULL);
+# ifdef __OpenBSD__
+ if (pledge("stdio", NULL)
+ eprint("pledge:");
+# endif
          for(;;) { /* main loop */
                  FD_ZERO(&rd);
                  FD_SET(0, &rd);


On 2016-09-02 17:13, git_AT_suckless.org wrote:
> commit 18580a159febc9c9658d82d73b90b53895c1ec00
> Author: Nico Golde <nico_AT_ngolde.de>
> AuthorDate: Fri Sep 2 16:13:43 2016 +0200
> Commit: Nico Golde <nico_AT_ngolde.de>
> CommitDate: Fri Sep 2 16:13:43 2016 +0200
>
> add OpenBSD pledge support - thanks Gleydson Soares
>
> diff --git a/config.mk b/config.mk
> index afc28d5..2cf103e 100644
> --- a/config.mk
> +++ b/config.mk
> _AT_@ -25,3 +25,6 @@ LIBS = -L${LIBDIR} -L/usr/lib -lc
> CC = cc
> CFLAGS = -g -O0 -W -Wall ${INCLUDES} -DVERSION=\"${VERSION}\"
> LDFLAGS = ${LIBS}
> +
> +# OpenBSD pledge(2) support
> +# CFLAGS+= -DUSE_PLEDGE
> diff --git a/ii.c b/ii.c
> index 745e29a..19f1b4c 100644
> --- a/ii.c
> +++ b/ii.c
> _AT_@ -490,6 +490,14 @@ int main(int argc, char *argv[]) {
> }
> }
> irc = tcpopen(port);
> +
> + #ifdef USE_PLEDGE /* OpenBSD pledge(2) support */
> + if (pledge("stdio rpath wpath cpath dpath", NULL) == -1) {
> + fputs("ii: pledge\\n", stderr);
> + exit(EXIT_FAILURE);
> + }
> + #endif
> +
> if(!snprintf(path, sizeof(path), "%s/%s", prefix, host)) {
> fputs("ii: path to irc directory too long\n", stderr);
> exit(EXIT_FAILURE);
Received on Fri Sep 02 2016 - 19:43:17 CEST

This archive was generated by hypermail 2.3.0 : Fri Sep 02 2016 - 19:48:15 CEST