@@ -68,6 +68,8 @@ class HTTPRPCTimerInterface : public RPCTimerInterface
68
68
static std::string strRPCUserColonPass;
69
69
/* Stored RPC timer interface (for unregistration) */
70
70
static std::unique_ptr<HTTPRPCTimerInterface> httpRPCTimerInterface;
71
+ /* List of -rpcauth values */
72
+ static std::vector<std::vector<std::string>> g_rpcauth;
71
73
/* RPC Auth Whitelist */
72
74
static std::map<std::string, std::set<std::string>> g_rpc_whitelist;
73
75
static bool g_rpc_whitelist_default = false ;
@@ -99,15 +101,7 @@ static bool multiUserAuthorized(std::string strUserPass)
99
101
std::string strUser = strUserPass.substr (0 , strUserPass.find (' :' ));
100
102
std::string strPass = strUserPass.substr (strUserPass.find (' :' ) + 1 );
101
103
102
- for (const std::string& strRPCAuth : gArgs .GetArgs (" -rpcauth" )) {
103
- // Search for multi-user login/pass "rpcauth" from config
104
- std::vector<std::string> vFields;
105
- boost::split (vFields, strRPCAuth, boost::is_any_of (" :$" ));
106
- if (vFields.size () != 3 ) {
107
- // Incorrect formatting in config file
108
- continue ;
109
- }
110
-
104
+ for (const auto & vFields : g_rpcauth) {
111
105
std::string strName = vFields[0 ];
112
106
if (!TimingResistantEqual (strName, strUser)) {
113
107
continue ;
@@ -259,6 +253,13 @@ static bool InitRPCAuthentication()
259
253
if (gArgs .GetArg (" -rpcauth" ," " ) != " " )
260
254
{
261
255
LogPrintf (" Using rpcauth authentication.\n " );
256
+ for (std::string rpcauth : gArgs .GetArgs (" -rpcauth" )) {
257
+ std::vector<std::string> fields;
258
+ boost::split (fields, rpcauth, boost::is_any_of (" :$" ));
259
+ if (fields.size () == 3 ) {
260
+ g_rpcauth.push_back (fields);
261
+ }
262
+ }
262
263
}
263
264
264
265
g_rpc_whitelist_default = gArgs .GetBoolArg (" -rpcwhitelistdefault" , gArgs .IsArgSet (" -rpcwhitelist" ));
0 commit comments