logs: Use correct path and more appropriate macros in cookie-related code

filepath_tmp -> filepath in last message.

More material changes to nearby code in next commit.
This commit is contained in:
Hodlinator 2024-12-02 10:38:07 +01:00
parent 6e28c76907
commit e82ad88452
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View file

@ -301,7 +301,7 @@ static bool InitRPCAuthentication()
if (cookie_perms_arg) {
auto perm_opt = InterpretPermString(*cookie_perms_arg);
if (!perm_opt) {
LogInfo("Invalid -rpccookieperms=%s; must be one of 'owner', 'group', or 'all'.\n", *cookie_perms_arg);
LogError("Invalid -rpccookieperms=%s; must be one of 'owner', 'group', or 'all'.", *cookie_perms_arg);
return false;
}
cookie_perms = *perm_opt;

View file

@ -108,7 +108,7 @@ bool GenerateAuthCookie(std::string* cookie_out, std::optional<fs::perms> cookie
fs::path filepath_tmp = GetAuthCookieFile(true);
file.open(filepath_tmp);
if (!file.is_open()) {
LogInfo("Unable to open cookie authentication file %s for writing\n", fs::PathToString(filepath_tmp));
LogWarning("Unable to open cookie authentication file %s for writing", fs::PathToString(filepath_tmp));
return false;
}
file << cookie;
@ -116,14 +116,14 @@ bool GenerateAuthCookie(std::string* cookie_out, std::optional<fs::perms> cookie
fs::path filepath = GetAuthCookieFile(false);
if (!RenameOver(filepath_tmp, filepath)) {
LogInfo("Unable to rename cookie authentication file %s to %s\n", fs::PathToString(filepath_tmp), fs::PathToString(filepath));
LogWarning("Unable to rename cookie authentication file %s to %s", fs::PathToString(filepath_tmp), fs::PathToString(filepath));
return false;
}
if (cookie_perms) {
std::error_code code;
fs::permissions(filepath, cookie_perms.value(), fs::perm_options::replace, code);
if (code) {
LogInfo("Unable to set permissions on cookie authentication file %s\n", fs::PathToString(filepath_tmp));
LogWarning("Unable to set permissions on cookie authentication file %s", fs::PathToString(filepath));
return false;
}
}