duckduckgo: gopher: fix pledge and unveil - frontends - front-ends for some sit… | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 07a5a89d2c8b3dab2fc85ff616e98d34b0edcd21 | |
parent 750369d997d681680d0a6dfc115ef6314fa18bfa | |
Author: Hiltjo Posthuma <[email protected]> | |
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(-) | |
--- | |
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); |