From 90e64dba702acb22eef4f6d70dc0ac885b1bedbf Mon Sep 17 00:00:00 2001 From: Jonathan McDowell Date: Tue, 7 Jun 2016 08:37:07 +0100 Subject: [PATCH] Parse pks_bin_dir / mail_dir in the C config handling pks_bin_dir and mail_dir are only used by the Perl that handles incoming keyserver email, but parse them in the C code rather than just ignoring them. This helps pave the way for some config file format changes and tightening up the parsing to complain about unused options. --- onak-conf.c | 17 +++++++++++++++-- onak-conf.h | 10 ++++++++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/onak-conf.c b/onak-conf.c index f97f261..0af6a45 100644 --- a/onak-conf.c +++ b/onak-conf.c @@ -53,6 +53,9 @@ struct onak_config config = { .dbinit = DBINIT, .check_sighash = true, + + .bin_dir = NULL, + .mail_dir = NULL, }; bool parsebool(char *str, bool fallback) @@ -178,12 +181,14 @@ void readconfig(const char *configfile) { } else if (!strncmp("this_site ", curline, 10)) { config.thissite = strdup(&curline[10]); } else if (!strncmp("socket_name ", curline, 12) || - !strncmp("pks_bin_dir ", curline, 12) || - !strncmp("mail_dir ", curline, 9) || !strncmp("www_port ", curline, 9)) { /* * Not applicable; ignored for compatibility with pksd. */ + } else if (!strncmp("pks_bin_dir ", curline, 12)) { + config.bin_dir = strdup(&curline[12]); + } else if (!strncmp("mail_dir ", curline, 9)) { + config.mail_dir = strdup(&curline[9]); } else if (!strncmp("db_backend ", curline, 11)) { backend->type = strdup(&curline[11]); backend->name = strdup(&curline[11]); @@ -280,4 +285,12 @@ void cleanupconfig(void) { free(config.backends_dir); config.backends_dir = NULL; } + if (config.bin_dir != NULL) { + free(config.bin_dir); + config.bin_dir = NULL; + } + if (config.mail_dir != NULL) { + free(config.mail_dir); + config.mail_dir = NULL; + } } diff --git a/onak-conf.h b/onak-conf.h index 0d937c2..d049520 100644 --- a/onak-conf.h +++ b/onak-conf.h @@ -89,6 +89,16 @@ struct onak_config { /** Should we verify signature hashes match? */ bool check_sighash; + + /* + * Options used by the email handling script. + * None of the C code uses this information, but we should be able + * to parse it. + */ + /** Location of the onak binary, so the mail script can find it. */ + char *bin_dir; + /** Where incoming mail gets queue, one file per mail. */ + char *mail_dir; }; /** -- 2.39.5