/*
fsck.c -- Check the configuration files for problems
- Copyright (C) 2014-2021 Guus Sliepen <guus@tinc-vpn.org>
+ Copyright (C) 2014-2022 Guus Sliepen <guus@tinc-vpn.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
}
static void check_conffile(const char *nodename, bool server) {
- splay_tree_t *config = NULL;
+ splay_tree_t config;
init_configuration(&config);
bool read;
if(server) {
- read = read_server_config(config);
+ read = read_server_config(&config);
} else {
- read = read_host_config(config, nodename, true);
+ read = read_host_config(&config, nodename, true);
}
if(!read) {
- exit_configuration(&config);
+ splay_empty_tree(&config);
return;
}
int count[total_vars];
memset(count, 0, sizeof(count));
- for splay_each(config_t, conf, config) {
+ for splay_each(config_t, conf, &config) {
int var_type = 0;
for(size_t i = 0; variables[i].name; ++i) {
}
}
- exit_configuration(&config);
+ splay_empty_tree(&config);
}
#ifdef HAVE_MINGW
typedef int uid_t;
-static uid_t getuid() {
+static uid_t getuid(void) {
return 0;
}
}
#endif // HAVE_MINGW
-static char *read_node_name() {
+static char *read_node_name(void) {
if(access(tinc_conf, R_OK) == 0) {
return get_my_name(true);
}
uint8_t *encrypted = xzalloc(len);
uint8_t *decrypted = xzalloc(len);
- randomize(plaintext, len);
+ prng_randomize(plaintext, len);
plaintext[0] &= 0x7f;
if(rsa_public_encrypt(rsa_pub, plaintext, len, encrypted)) {
return true;
}
-static bool check_script_confdir() {
+static bool check_script_confdir(void) {
char fname[PATH_MAX];
DIR *dir = opendir(confbase);
}
}
-static bool check_scripts_and_configs() {
+static bool check_scripts_and_configs(void) {
// Check whether scripts are executable.
if(!check_script_confdir()) {
return false;
// Avoid touching global configuration here. Read the config files into
// a temporary configuration tree, then throw it away after fsck is done.
- splay_tree_t *config = NULL;
+ splay_tree_t config;
init_configuration(&config);
// Read the server configuration file and append host configuration for our node.
- bool success = read_server_config(config) &&
- read_host_config(config, name, true);
+ bool success = read_server_config(&config) &&
+ read_host_config(&config, name, true);
// Check both RSA and EC key pairs.
// We need working configuration to run this check.
if(success) {
- success = check_keypairs(config, name);
+ success = check_keypairs(&config, name);
}
// Check that scripts are executable and check the config for invalid variables.
// This way, we can diagnose more issues on the first run.
success = success & check_scripts_and_configs();
- exit_configuration(&config);
+ splay_empty_tree(&config);
free(name);
exe_name = NULL;