Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve incomplete installations support #2036

Merged
merged 1 commit into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/config/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,13 @@ bool readFTLconf(struct config *conf, const bool rewrite)

log_info("No config file nor backup available, using defaults");

// If we reach this point, we could not read the TOML config file When
// this functions is invoked to run without rewriting, we are likely
// running interactively and do not want to migrate settings (yet):
// using defaults is fine in this case
if(!rewrite)
return false;

// If no previous config file could be read, we are likely either running
// for the first time or we are upgrading from a version prior to v6.0
// In this case, we try to read the legacy config files
Expand Down Expand Up @@ -1661,8 +1668,8 @@ bool readFTLconf(struct config *conf, const bool rewrite)
conf->webserver.port.v.s = ports;
conf->webserver.port.t = CONF_STRING_ALLOCATED;

log_info("Initialised webserver ports at %d (HTTP) and %d (HTTPS), IPv6 support is %s",
http_port, https_port, have_ipv6 ? "enabled" : "disabled");
log_info("Config initialized with webserver ports %d (HTTP) and %d (HTTPS), IPv6 support is %s",
http_port, https_port, have_ipv6 ? "enabled" : "disabled");
}

// Initialize the TOML config file
Expand Down
8 changes: 4 additions & 4 deletions src/config/toml_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,17 @@ FILE * __attribute((malloc)) __attribute((nonnull(1))) openFTLtoml(const char *m
// Return early if opening failed
if(!fp)
{
log_info("Config %sfile %s not available: %s",
version > 0 ? "backup " : "", filename, strerror(errno));
log_info("Config %sfile %s not available (%s): %s",
version > 0 ? "backup " : "", filename, mode, strerror(errno));
return NULL;
}

// Lock file, may block if the file is currently opened
if(flock(fileno(fp), LOCK_EX) != 0)
{
const int _e = errno;
log_err("Cannot open config file %s in exclusive mode: %s",
filename, strerror(errno));
log_err("Cannot open config file %s in exclusive mode (%s): %s",
filename, mode, strerror(errno));
fclose(fp);
errno = _e;
return NULL;
Expand Down
Loading