diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 2a6751df332..9a076996656 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -264,12 +264,12 @@ static bool InitRPCAuthentication() } switch (GenerateAuthCookie(cookie_perms, user, pass)) { - case GenerateAuthCookieResult::ERR: + case AuthCookieResult::Error: return false; - case GenerateAuthCookieResult::DISABLED: + case AuthCookieResult::Disabled: LogInfo("RPC authentication cookie file generation is disabled."); break; - case GenerateAuthCookieResult::OK: + case AuthCookieResult::Ok: LogInfo("Using random cookie authentication."); break; } diff --git a/src/rpc/request.cpp b/src/rpc/request.cpp index 1798cdef235..cf7109a4376 100644 --- a/src/rpc/request.cpp +++ b/src/rpc/request.cpp @@ -97,9 +97,9 @@ static fs::path GetAuthCookieFile(bool temp=false) static bool g_generated_cookie = false; -GenerateAuthCookieResult GenerateAuthCookie(const std::optional& cookie_perms, - std::string& user, - std::string& pass) +AuthCookieResult GenerateAuthCookie(const std::optional& cookie_perms, + std::string& user, + std::string& pass) { const size_t COOKIE_SIZE = 32; unsigned char rand_pwd[COOKIE_SIZE]; @@ -112,12 +112,12 @@ GenerateAuthCookieResult GenerateAuthCookie(const std::optional& cook std::ofstream file; fs::path filepath_tmp = GetAuthCookieFile(true); if (filepath_tmp.empty()) { - return GenerateAuthCookieResult::DISABLED; // -norpccookiefile + return AuthCookieResult::Disabled; // -norpccookiefile } file.open(filepath_tmp.std_path()); if (!file.is_open()) { LogWarning("Unable to open cookie authentication file %s for writing", fs::PathToString(filepath_tmp)); - return GenerateAuthCookieResult::ERR; + return AuthCookieResult::Error; } file << COOKIEAUTH_USER << ":" << rand_pwd_hex; file.close(); @@ -125,14 +125,14 @@ GenerateAuthCookieResult GenerateAuthCookie(const std::optional& cook fs::path filepath = GetAuthCookieFile(false); if (!RenameOver(filepath_tmp, filepath)) { LogWarning("Unable to rename cookie authentication file %s to %s", fs::PathToString(filepath_tmp), fs::PathToString(filepath)); - return GenerateAuthCookieResult::ERR; + return AuthCookieResult::Error; } if (cookie_perms) { std::error_code code; fs::permissions(filepath, cookie_perms.value(), fs::perm_options::replace, code); if (code) { LogWarning("Unable to set permissions on cookie authentication file %s", fs::PathToString(filepath)); - return GenerateAuthCookieResult::ERR; + return AuthCookieResult::Error; } } @@ -142,7 +142,7 @@ GenerateAuthCookieResult GenerateAuthCookie(const std::optional& cook user = COOKIEAUTH_USER; pass = rand_pwd_hex; - return GenerateAuthCookieResult::OK; + return AuthCookieResult::Ok; } bool GetAuthCookie(std::string *cookie_out) diff --git a/src/rpc/request.h b/src/rpc/request.h index 4588db5122d..357f5d7ef0a 100644 --- a/src/rpc/request.h +++ b/src/rpc/request.h @@ -23,10 +23,10 @@ UniValue JSONRPCRequestObj(const std::string& strMethod, const UniValue& params, UniValue JSONRPCReplyObj(UniValue result, UniValue error, std::optional id, JSONRPCVersion jsonrpc_version); UniValue JSONRPCError(int code, const std::string& message); -enum class GenerateAuthCookieResult : uint8_t { - DISABLED, // -norpccookiefile - ERR, - OK, +enum class AuthCookieResult : uint8_t { + Disabled, // -norpccookiefile + Error, + Ok, }; /** @@ -34,11 +34,11 @@ enum class GenerateAuthCookieResult : uint8_t { * @param[in] cookie_perms Filesystem permissions to use for the cookie file. * @param[out] user Generated username, only set if `OK` is returned. * @param[out] pass Generated password, only set if `OK` is returned. - * @retval GenerateAuthCookieResult::DISABLED Authentication via cookie is disabled. - * @retval GenerateAuthCookieResult::ERROR Error occurred, auth data could not be saved to disk. - * @retval GenerateAuthCookieResult::OK Auth data was generated, saved to disk and in `user` and `pass`. + * @retval AuthCookieResult::Disabled Authentication via cookie is disabled. + * @retval AuthCookieResult::Error Error occurred, auth data could not be saved to disk. + * @retval AuthCookieResult::Ok Auth data was generated, saved to disk and in `user` and `pass`. */ -GenerateAuthCookieResult GenerateAuthCookie(const std::optional& cookie_perms, +AuthCookieResult GenerateAuthCookie(const std::optional& cookie_perms, std::string& user, std::string& pass);