diff --git a/client.c b/client.c index 360bbf7..4856c9e 100644 --- a/client.c +++ b/client.c @@ -231,10 +231,20 @@ static bool abort_searching_for_keyserver(struct keyclient_t *keyclient) { return true; } + unsigned int client_timeout_secs = 0; if (keyclient->opts->timeout_seconds) { + /* Command line always has precedence */ + client_timeout_secs = keyclient->opts->timeout_seconds; + } else { + /* Alternatively, take the one in the configuration file */ + client_timeout_secs = keyclient->keydb->hosts[0].client_default_timeout_secs; + } + + + if (client_timeout_secs) { double time_passed = now() - keyclient->broadcast_start_time; - if (time_passed >= keyclient->opts->timeout_seconds) { - log_msg(LLVL_WARNING, "Could not unlock all volumes after %u seconds, giving up. %d volumes still locked.", keyclient->opts->timeout_seconds, locked_volume_count(keyclient)); + if (time_passed >= client_timeout_secs) { + log_msg(LLVL_WARNING, "Could not unlock all volumes after %u seconds, giving up. %d volumes still locked.", client_timeout_secs, locked_volume_count(keyclient)); return true; } } diff --git a/keydb.c b/keydb.c index 0066543..99f1c7b 100644 --- a/keydb.c +++ b/keydb.c @@ -332,7 +332,7 @@ static keydb_t* keydb_migrate(void **keydb_data, unsigned int *keydb_data_size) header = *((struct keydb_common_header_t**)keydb_data); if (header->keydb_version == 3) { if (*keydb_data_size != keydb_getsize_v3(*keydb_data)) { - log_msg(LLVL_ERROR, "keydb version 3 has wrong size (%u bytes, but expected %u bytes).", *keydb_data_size, keydb_getsize_v2(*keydb_data)); + log_msg(LLVL_ERROR, "keydb version 3 has wrong size (%u bytes, but expected %u bytes).", *keydb_data_size, keydb_getsize_v3(*keydb_data)); return NULL; } } diff --git a/keydb.h b/keydb.h index 3e79e6a..2ba9f36 100644 --- a/keydb.h +++ b/keydb.h @@ -78,6 +78,7 @@ struct host_entry_v3_t { char host_name[MAX_HOST_NAME_LENGTH]; /* Descriptive name of host */ uint8_t tls_psk[PSK_SIZE_BYTES]; /* Raw byte data of TLS-PSK that is used */ unsigned int volume_count; /* Number of volumes of this host */ + unsigned int client_default_timeout_secs; /* Client gives up by default if not everything unlocked after this time */ unsigned int host_flags; /* Bitset of enum host_flag_t */ struct volume_entry_v3_t volumes[MAX_VOLUMES_PER_HOST]; /* Volumes of this host */ } ALIGNED;