X-Git-Url: https://the.earth.li/gitweb/?a=blobdiff_plain;ds=sidebyside;f=onak-conf.c;h=a67c950432e2c05322eff4de91f43a37b01059ad;hb=9ce8c6ced68d45b462abb4c6531b6476f4d1e681;hp=e4f0bc75312f1b5f4c65cbfbbf1ab27c7868f25d;hpb=6df51fef2960f533a741fb7290867387ed3fbba5;p=onak.git
diff --git a/onak-conf.c b/onak-conf.c
index e4f0bc7..a67c950 100644
--- a/onak-conf.c
+++ b/onak-conf.c
@@ -15,20 +15,22 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see .
*/
-
-#include "config.h"
-
#include
#include
#include
#include
#include
+#include "build-config.h"
+
+#include "cleankey.h"
#include "ll.h"
#include "log.h"
#include "onak-conf.h"
+#ifdef DBINIT
extern struct onak_dbctx *DBINIT(struct onak_db_config *dbcfg, bool readonly);
+#endif
/*
* config - Runtime configuration for onak.
@@ -50,9 +52,13 @@ struct onak_config config = {
.backends = NULL,
.backends_dir = NULL,
+#ifdef DBINIT
.dbinit = DBINIT,
+#else
+ .dbinit = NULL,
+#endif
- .check_sighash = true,
+ .clean_policies = ONAK_CLEAN_DROP_V3_KEYS | ONAK_CLEAN_CHECK_SIGHASH,
.bin_dir = NULL,
.mail_dir = NULL,
@@ -169,8 +175,14 @@ static bool parseoldconfigline(char *line)
} else if (!strncmp("sock_dir ", line, 9)) {
config.sock_dir = strdup(&line[9]);
} else if (!strncmp("check_sighash ", line, 9)) {
- config.check_sighash = parsebool(&line[9],
- config.check_sighash);
+ if (parsebool(&line[9], config.clean_policies &
+ ONAK_CLEAN_CHECK_SIGHASH)) {
+ config.clean_policies |=
+ ONAK_CLEAN_CHECK_SIGHASH;
+ } else {
+ config.clean_policies &=
+ ~ONAK_CLEAN_CHECK_SIGHASH;
+ }
} else {
return false;
}
@@ -272,9 +284,44 @@ static bool parseconfigline(char *line)
config.syncsites = lladd(config.syncsites,
strdup(value));
/* [verification] section */
+ } else if (MATCH("verification", "blacklist")) {
+ array_load(&config.blacklist, value);
+ } else if (MATCH("verification", "drop_v3")) {
+ if (parsebool(value, config.clean_policies &
+ ONAK_CLEAN_DROP_V3_KEYS)) {
+ config.clean_policies |=
+ ONAK_CLEAN_DROP_V3_KEYS;
+ } else {
+ config.clean_policies &=
+ ~ONAK_CLEAN_DROP_V3_KEYS;
+ }
} else if (MATCH("verification", "check_sighash")) {
- config.check_sighash = parsebool(value,
- config.check_sighash);
+ if (parsebool(value, config.clean_policies &
+ ONAK_CLEAN_CHECK_SIGHASH)) {
+ config.clean_policies |=
+ ONAK_CLEAN_CHECK_SIGHASH;
+ } else {
+ config.clean_policies &=
+ ~ONAK_CLEAN_CHECK_SIGHASH;
+ }
+ } else if (MATCH("verification", "check_packet_size")) {
+ if (parsebool(value, config.clean_policies &
+ ONAK_CLEAN_LARGE_PACKETS)) {
+ config.clean_policies |=
+ ONAK_CLEAN_LARGE_PACKETS;
+ } else {
+ config.clean_policies &=
+ ~ONAK_CLEAN_LARGE_PACKETS;
+ }
+ } else if (MATCH("verification", "update_only")) {
+ if (parsebool(value, config.clean_policies &
+ ONAK_CLEAN_UPDATE_ONLY)) {
+ config.clean_policies |=
+ ONAK_CLEAN_UPDATE_ONLY;
+ } else {
+ config.clean_policies &=
+ ~ONAK_CLEAN_UPDATE_ONLY;
+ }
} else {
return false;
}
@@ -355,6 +402,12 @@ void readconfig(const char *configfile) {
conffile = fopen(configfile, "r");
}
+ if (oldstyle) {
+ logthing(LOGTHING_CRITICAL, "Reading deprecated old-style "
+ "configuration file. This will not be "
+ "supported in the next release.");
+ }
+
if (conffile != NULL) {
if (!fgets(curline, 1023, conffile)) {
logthing(LOGTHING_CRITICAL,
@@ -448,7 +501,8 @@ void writeconfig(const char *configfile)
fprintf(conffile, "\n");
fprintf(conffile, "[verification]\n");
- WRITE_BOOL(config.check_sighash, "check_sighash");
+ WRITE_BOOL(config.clean_policies & ONAK_CLEAN_CHECK_SIGHASH,
+ "check_sighash");
fprintf(conffile, "\n");
fprintf(conffile, "[mail]\n");
@@ -559,4 +613,7 @@ void cleanupconfig(void) {
free(config.mail_dir);
config.mail_dir = NULL;
}
+ if (config.blacklist.count != 0) {
+ array_free(&config.blacklist);
+ }
}