summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorVincent Douillet <vincent@vdouillet.fr>2024-08-29 17:46:14 +0200
committerVincent Douillet <vincent@vdouillet.fr>2024-08-29 21:53:35 +0200
commitf005928d63165d28b32851f04f29055a4d0cdad5 (patch)
tree5386f28a558046dbe6e93b439f5e026441224c56 /main.c
parent4be89075c5bb5793f8c79da8f8df1accc1f0168f (diff)
get data dir from env variable
Diffstat (limited to 'main.c')
-rw-r--r--main.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/main.c b/main.c
index 0b8e867..1561a09 100644
--- a/main.c
+++ b/main.c
@@ -53,6 +53,7 @@ static const char *const pages[PAGE__MAX] = {
int
main(void)
{
+ char *data_dir;
enum kcgi_err parse_err;
struct kreq r;
struct http_ret ret;
@@ -65,8 +66,12 @@ main(void)
http_exit(NULL, KHTTP_500, "Unable to parse request: %s",
kcgi_strerror(parse_err));
+ data_dir = config_data_dir();
+ if (data_dir == NULL)
+ http_exit(NULL, KHTTP_500, "Data dir not configured");
+
/* A bit of security cannot hurt */
- if (-1 == unveil(DATA_DIR, "r")
+ if (-1 == unveil(data_dir, "r")
|| -1 == unveil(TEMPLATE_DIR, "r")
|| -1 == unveil(NULL, NULL))
http_exit(&r, KHTTP_500, "Unveil failed: %s", strerror(errno));