duckduckgo: gopher: fix pledge and unveil - frontends - front-ends for some sites (experiment) (DIR) Log (DIR) Files (DIR) Refs (DIR) README (DIR) LICENSE --- (DIR) commit 07a5a89d2c8b3dab2fc85ff616e98d34b0edcd21 (DIR) parent 750369d997d681680d0a6dfc115ef6314fa18bfa (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org> Date: Sun, 25 Oct 2020 13:21:19 +0100 duckduckgo: gopher: fix pledge and unveil Add support for gophernicus env variable. Diffstat: M duckduckgo/gopher.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) --- (DIR) diff --git a/duckduckgo/gopher.c b/duckduckgo/gopher.c @@ -1,7 +1,7 @@ #include <sys/types.h> #include <ctype.h> -#include <err.h> +#include <errno.h> #include <locale.h> #include <stdio.h> #include <stdlib.h> @@ -10,6 +10,7 @@ #include <wchar.h> #include "duckduckgo.h" +#include "https.h" #include "util.h" #define OUT(s) fputs(s, stdout) @@ -31,11 +32,23 @@ main(void) host = p; if ((p = getenv("SERVER_PORT"))) port = p; - if ((p = getenv("X_GOPHER_SEARCH"))) + if (!(p = getenv("X_GOPHER_SEARCH"))) /* geomyidae */ + p = getenv("SEARCHREQUEST"); /* gophernicus */ + if (p) search = p; - if (pledge("stdio", NULL) == -1) - err(1, "pledge"); + if (pledge("stdio dns inet rpath unveil", NULL) == -1) { + fprintf(stderr, "pledge: %s\n", strerror(errno)); + exit(1); + } + if (unveil(TLS_CA_CERT_FILE, "r") == -1) { + fprintf(stderr, "unveil: %s\n", strerror(errno)); + exit(1); + } + if (unveil(NULL, NULL) == -1) { + fprintf(stderr, "unveil: %s\n", strerror(errno)); + exit(1); + } if (search == NULL) { printf("3\tSpecify a search term\t%s\t%s\r\n", host, port);