summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Bratch <luke@bratch.co.uk>2019-05-27 12:46:22 +0100
committerLuke Bratch <luke@bratch.co.uk>2019-05-27 12:46:22 +0100
commit0b1417faa0820847d4674d496dfeb069787c3ab2 (patch)
tree9258fc30925344f844b6d7218679e0876c711eec
parentf0936ca1b231df3c5cb7cf80a1d6a88d7ea980af (diff)
Change default certfile and keyfile to be <basedir>/ instead of $HOME/.blabouncer/.
-rw-r--r--TODO2
-rw-r--r--blabouncer.c20
-rw-r--r--blabouncer.conf.example12
-rw-r--r--config.c12
4 files changed, 25 insertions, 21 deletions
diff --git a/TODO b/TODO
index 5eee410..ba948f0 100644
--- a/TODO
+++ b/TODO
@@ -20,5 +20,3 @@ Support autojoining passworded channels.
Test CTCP.
Reconnect server if we get disconnected for some reason.
-
-Change default certfile and keyfile to be basedir/ instead of $HOME.
diff --git a/blabouncer.c b/blabouncer.c
index efb2474..e5637cf 100644
--- a/blabouncer.c
+++ b/blabouncer.c
@@ -2212,6 +2212,11 @@ int main(int argc, char *argv[]) {
exit(1);
}
+ // Is the base directory set? If not, use the default.
+ if (!getconfstr("basedir", settings.conffile, settings.basedir)) {
+ snprintf(settings.basedir, PATH_MAX, "%s/.blabouncer/", getenv("HOME"));
+ }
+
// Should the bouncer use TLS for the IRC server?
settings.servertls = getconfint("servertls", settings.conffile);
@@ -2223,21 +2228,22 @@ int main(int argc, char *argv[]) {
// What is the certificate file path?
if (!getconfstr("certfile", settings.conffile, settings.certfile)) {
// If none provided, set to default
- snprintf(settings.certfile, PATH_MAX, "%s/.blabouncer/cert.pem", getenv("HOME"));
+ if (!snprintf(settings.certfile, PATH_MAX, "%s/cert.pem", settings.basedir)) {
+ fprintf(stderr, "Error while preparing default certfile location!\n");
+ exit(1);
+ }
}
// What is the certificate key file path?
if (!getconfstr("keyfile", settings.conffile, settings.keyfile)) {
// If none provided, set to default
- snprintf(settings.keyfile, PATH_MAX, "%s/.blabouncer/key.pem", getenv("HOME"));
+ if (!snprintf(settings.keyfile, PATH_MAX, "%s/key.pem", settings.basedir)) {
+ fprintf(stderr, "Error while preparing default certfile location!\n");
+ exit(1);
+ }
}
}
- // Is the base directory set? If not, use the default.
- if (!getconfstr("basedir", settings.conffile, settings.basedir)) {
- snprintf(settings.basedir, PATH_MAX, "%s/.blabouncer/", getenv("HOME"));
- }
-
// Make sure the base directory exists
struct stat st = {0};
if (stat(settings.basedir, &st) == -1) {
diff --git a/blabouncer.conf.example b/blabouncer.conf.example
index e9bc15a..805534d 100644
--- a/blabouncer.conf.example
+++ b/blabouncer.conf.example
@@ -39,18 +39,18 @@ ircserver = "irc.blatech.net"
# Real IRC server port
ircserverport = "6697"
-# Certificate file (defaults to $HOME/.blabouncer/cert.pem)
+# Base directory (defaults to $HOME/.blabouncer/)
+# Things such as the logs directory will be placed below this
+#basedir = "/home/foo/.blabouncer/"
+
+# Certificate file (defaults to <basedir>/cert.pem)
# If clienttls = "0" then this need not be set
#certfile = "/home/foo/.blabouncer/cert.pem"
-# Certificate key file (defaults to $HOME/.blabouncer/key.pem)
+# Certificate key file (defaults to <basedir>/key.pem)
# If clienttls = "0" then this need not be set
#keyfile = "/home/foo/.blabouncer/key.pem"
-# Base directory (defaults to $HOME/.blabouncer/)
-# Things such as the logs directory will be placed below this
-#basedir = "/home/foo/.blabouncer/"
-
# Enable logging ("1" for yes or "0" for no)
# Logs go to basedir/logs/ with one file per channel/nick
logging = "1"
diff --git a/config.c b/config.c
index 12237b3..798ad82 100644
--- a/config.c
+++ b/config.c
@@ -200,18 +200,18 @@ int createconfigfile(char *filename) {
"# Real IRC server port\n"
"ircserverport = \"6697\"\n"
"\n"
- "# Certificate file (defaults to $HOME/.blabouncer/cert.pem)\n"
+ "# Base directory (defaults to $HOME/.blabouncer/)\n"
+ "# Things such as the logs directory will be placed below this\n"
+ "#basedir = \"/home/foo/.blabouncer/\"\n"
+ "\n"
+ "# Certificate file (defaults to <basedir>/cert.pem)\n"
"# If clienttls = \"0\" then this need not be set\n"
"#certfile = \"/home/foo/.blabouncer/cert.pem\"\n"
"\n"
- "# Certificate key file (defaults to $HOME/.blabouncer/key.pem)\n"
+ "# Certificate key file (defaults to <basedir>/key.pem)\n"
"# If clienttls = \"0\" then this need not be set\n"
"#keyfile = \"/home/foo/.blabouncer/key.pem\"\n"
"\n"
- "# Base directory (defaults to $HOME/.blabouncer/)\n"
- "# Things such as the logs directory will be placed below this\n"
- "#basedir = \"/home/foo/.blabouncer/\"\n"
- "\n"
"# Enable logging (\"1\" for yes or \"0\" for no)\n"
"# Logs go to basedir/logs/ with one file per channel/nick\n"
"logging = \"1\"\n"