From 61a369b85e51e0d54e1651e4ff8c11fe4815a0c0 Mon Sep 17 00:00:00 2001 From: Luke Bratch Date: Thu, 16 May 2019 21:35:16 +0100 Subject: Move default configuration file location to $HOME/.blabouncer/ and create a default file automatically if it doesn't exist. --- blabouncer.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'blabouncer.c') diff --git a/blabouncer.c b/blabouncer.c index 59cf8c1..8ed8d72 100644 --- a/blabouncer.c +++ b/blabouncer.c @@ -1375,7 +1375,14 @@ int main(int argc, char *argv[]) { exit(1); } else { // If none provided, set to default - strcpy(settings.conffile, "blabouncer.conf"); + snprintf(settings.conffile, PATH_MAX, "%s/.blabouncer/blabouncer.conf", getenv("HOME")); + // Since this is the default, it might not exist yet, so let's check... + struct stat st = {0}; + if (stat(settings.conffile, &st) == -1) { + // ...it doesn't exist, so let's create it + printf("Creating default configuration file '%s'.\n", settings.conffile); + createconfigfile(settings.conffile); + } } printf("Using configuration file '%s'.\n", settings.conffile); -- cgit v1.2.3