tadd unveil(2) and fix error status if polls/ cannot be created - vote - simple… | |
git clone git://src.adamsgaard.dk/vote | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit 22acb208bf624709b5693518ec831f9bbc2c8319 | |
parent 74b58729c204508d0e3fbe2162a3325d2f3d5aeb | |
Author: Anders Damsgaard <[email protected]> | |
Date: Sun, 27 Sep 2020 01:55:10 +0200 | |
add unveil(2) and fix error status if polls/ cannot be created | |
Diffstat: | |
M vote.c | 8 +++++++- | |
1 file changed, 7 insertions(+), 1 deletion(-) | |
--- | |
diff --git a/vote.c b/vote.c | |
t@@ -58,6 +58,12 @@ int | |
main() { | |
struct stat sb; | |
+ if (unveil(getenv("PWD"), NULL) == -1 && unveil(NULL, NULL) == -1) { | |
+ fprintf(stderr, "unveil: %s\n", strerror(errno)); | |
+ OUT("Status: 500 Internal Server Error\r\n\r\n"); | |
+ exit(1); | |
+ } | |
+ | |
if (pledge("stdio cpath rpath", NULL) == -1) { | |
fprintf(stderr, "pledge: %s\n", strerror(errno)); | |
OUT("Status: 500 Internal Server Error\r\n\r\n"); | |
t@@ -68,7 +74,7 @@ main() { | |
if (mkdir(POLLS_DIR, 0755) == -1) { | |
fprintf(stderr, "mkdir polls/ failed: %s\n", strerror(… | |
OUT("Status: 500 Internal Server Error\r\n\r\n"); | |
- exit(0); | |
+ exit(1); | |
} | |
} | |