From 5d9b0df0bff9db791bf1cd9b56ffd34686fb6d5c Mon Sep 17 00:00:00 2001 From: Jordan Bancino Date: Tue, 11 Oct 2022 11:38:34 -0400 Subject: [PATCH] Remove the redundant chroot option. This simplifies the config a bit. --- contrib/development.conf | 1 - contrib/production.conf | 16 +++++++++------- src/Telodendria.c | 16 ++++++++-------- src/TelodendriaConfig.c | 6 ------ src/include/TelodendriaConfig.h | 1 - 5 files changed, 17 insertions(+), 23 deletions(-) diff --git a/contrib/development.conf b/contrib/development.conf index 49dbce9..596c58c 100644 --- a/contrib/development.conf +++ b/contrib/development.conf @@ -4,7 +4,6 @@ server-name "localhost"; base-url "http://localhost:8008"; -chroot "./chroot"; id "jordan"; data-dir "./data"; federation "true"; diff --git a/contrib/production.conf b/contrib/production.conf index b0e73d4..bf07f88 100644 --- a/contrib/production.conf +++ b/contrib/production.conf @@ -1,12 +1,15 @@ # # Telodendria production configuration file. # -# See the following URL for the official documentation on the -# options here: +# The following man pages document the configuration: # -# https://telodendria.io/#configure +# - telodendria.conf(5) +# - Config(5) # -# Alternatively, see site/index.html in the source code. +# Alternatively, find the man pages online at the +# following URL: +# +# https://telodendria.io/#documentation # listen "8008"; @@ -15,12 +18,11 @@ server-name "example.com"; base-url "https://matrix.example.com"; identity-server "https://identity.example.com"; -chroot "/var/telodendria"; id "_telodendria" "_telodendria"; -data-dir "./data"; +data-dir "/var/telodendria"; federation "true"; registration "false"; -log "./telodendria.log" { +log "file" { level "message"; timestampFormat "default"; color "true"; diff --git a/src/Telodendria.c b/src/Telodendria.c index 63de4ca..d667481 100644 --- a/src/Telodendria.c +++ b/src/Telodendria.c @@ -211,7 +211,7 @@ main(int argc, char **argv) } #ifdef __OpenBSD__ - if (unveil(tConfig->chroot, "rwc") != 0) + if (unveil(tConfig->dataDir, "rwc") != 0) { Log(lc, LOG_ERROR, "Unveil of data directory failed: %s", strerror(errno)); exit = EXIT_FAILURE; @@ -252,14 +252,13 @@ main(int argc, char **argv) Log(lc, LOG_DEBUG, "Server Name: %s", tConfig->serverName); Log(lc, LOG_DEBUG, "Base URL: %s", tConfig->baseUrl); Log(lc, LOG_DEBUG, "Identity Server: %s", tConfig->identityServer); - Log(lc, LOG_DEBUG, "Chroot: %s", tConfig->chroot); Log(lc, LOG_DEBUG, "Run As: %s:%s", tConfig->uid, tConfig->gid); Log(lc, LOG_DEBUG, "Data Directory: %s", tConfig->dataDir); Log(lc, LOG_DEBUG, "Threads: %d", tConfig->threads); Log(lc, LOG_DEBUG, "Flags: %x", tConfig->flags); LogConfigUnindent(lc); - if (chdir(tConfig->chroot) != 0) + if (chdir(tConfig->dataDir) != 0) { Log(lc, LOG_ERROR, "Unable to change into data directory: %s.", strerror(errno)); exit = EXIT_FAILURE; @@ -267,7 +266,7 @@ main(int argc, char **argv) } else { - Log(lc, LOG_DEBUG, "Changed working directory to: %s", tConfig->chroot); + Log(lc, LOG_DEBUG, "Changed working directory to: %s", tConfig->dataDir); } Log(lc, LOG_DEBUG, "Running as uid:gid: %d:%d.", getuid(), getgid()); @@ -306,11 +305,11 @@ main(int argc, char **argv) #ifndef __OpenBSD__ if (chroot(".") == 0) { - Log(lc, LOG_DEBUG, "Changed the root directory to: %s.", tConfig->chroot); + Log(lc, LOG_DEBUG, "Changed the root directory to: %s.", tConfig->dataDir); } else { - Log(lc, LOG_WARNING, "Unable to chroot into directory: %s.", tConfig->chroot); + Log(lc, LOG_WARNING, "Unable to chroot into directory: %s.", tConfig->dataDir); } #else Log(lc, LOG_DEBUG, "Not attempting chroot() after pledge() and unveil()."); @@ -341,11 +340,11 @@ main(int argc, char **argv) /* These config values are no longer needed; don't hold them in * memory anymore */ - free(tConfig->chroot); + free(tConfig->dataDir); free(tConfig->uid); free(tConfig->gid); - tConfig->chroot = NULL; + tConfig->dataDir = NULL; tConfig->uid = NULL; tConfig->gid = NULL; @@ -380,6 +379,7 @@ finish: if (httpServer) { HttpServerFree(httpServer); + Log(lc, LOG_DEBUG, "Freed HTTP Server."); } Log(lc, LOG_DEBUG, "Exiting with code '%d'.", exit); TelodendriaConfigFree(tConfig); diff --git a/src/TelodendriaConfig.c b/src/TelodendriaConfig.c index 5baadf1..a53dc93 100644 --- a/src/TelodendriaConfig.c +++ b/src/TelodendriaConfig.c @@ -155,11 +155,6 @@ TelodendriaConfigParse(HashMap * config, LogConfig * lc) tConfig->identityServer = NULL; } - GET_DIRECTIVE("chroot"); - ASSERT_NO_CHILDREN("chroot"); - ASSERT_VALUES("chroot", 1); - COPY_VALUE(tConfig->chroot, 0); - GET_DIRECTIVE("id"); ASSERT_NO_CHILDREN("id"); COPY_VALUE(tConfig->uid, 0); @@ -390,7 +385,6 @@ TelodendriaConfigFree(TelodendriaConfig * tConfig) free(tConfig->baseUrl); free(tConfig->identityServer); - free(tConfig->chroot); free(tConfig->uid); free(tConfig->gid); free(tConfig->dataDir); diff --git a/src/include/TelodendriaConfig.h b/src/include/TelodendriaConfig.h index ccb071d..b03798e 100644 --- a/src/include/TelodendriaConfig.h +++ b/src/include/TelodendriaConfig.h @@ -56,7 +56,6 @@ typedef struct TelodendriaConfig char *baseUrl; char *identityServer; - char *chroot; char *uid; char *gid; char *dataDir;