about summary refs log tree commit diff
path: root/local.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-10-05 23:16:32 -0400
committerJune McEnroe <june@causal.agency>2021-10-05 23:30:09 -0400
commitfa944345a63a083555a1f1933aabf4ea6f27a307 (patch)
tree37a053122b20d4c306013911cb022b000cecf0b6 /local.c
parentLoad and reload local certificates like normal (diff)
downloadpounce-fa944345a63a083555a1f1933aabf4ea6f27a307.tar.gz
pounce-fa944345a63a083555a1f1933aabf4ea6f27a307.zip
Refactor XDG base directory iterator API
Finally something more reasonable for call sites.
Diffstat (limited to '')
-rw-r--r--local.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/local.c b/local.c
index 35286b3..ece94ca 100644
--- a/local.c
+++ b/local.c
@@ -27,6 +27,7 @@
 
 #include <err.h>
 #include <errno.h>
+#include <limits.h>
 #include <netdb.h>
 #include <netinet/in.h>
 #include <stdbool.h>
@@ -52,24 +53,22 @@ int localConfig(
 	if (!config) errx(EX_SOFTWARE, "tls_config_new");
 
 	int error;
-	const char *dirs = NULL;
-	for (const char *path; NULL != (path = configPath(&dirs, cert));) {
-		error = tls_config_set_cert_file(config, path);
+	char buf[PATH_MAX];
+	for (int i = 0; configPath(buf, sizeof(buf), cert, i); ++i) {
+		error = tls_config_set_cert_file(config, buf);
 		if (!error) break;
 	}
 	if (error) goto fail;
 
-	dirs = NULL;
-	for (const char *path; NULL != (path = configPath(&dirs, priv));) {
-		error = tls_config_set_key_file(config, path);
+	for (int i = 0; configPath(buf, sizeof(buf), priv, i); ++i) {
+		error = tls_config_set_key_file(config, buf);
 		if (!error) break;
 	}
 	if (error) goto fail;
 
 	if (ca) {
-		dirs = NULL;
-		for (const char *path; NULL != (path = configPath(&dirs, ca));) {
-			error = tls_config_set_ca_file(config, path);
+		for (int i = 0; configPath(buf, sizeof(buf), ca, i); ++i) {
+			error = tls_config_set_ca_file(config, buf);
 			if (!error) break;
 		}
 		if (error) goto fail;