|
4 | 4 |
|
5 | 5 | #include <httprpc.h> |
6 | 6 |
|
7 | | -#include <chainparams.h> |
8 | 7 | #include <crypto/hmac_sha256.h> |
9 | 8 | #include <httpserver.h> |
10 | 9 | #include <rpc/protocol.h> |
11 | 10 | #include <rpc/server.h> |
12 | 11 | #include <util/strencodings.h> |
13 | 12 | #include <util/string.h> |
14 | 13 | #include <util/system.h> |
15 | | -#include <util/translation.h> |
16 | 14 | #include <walletinitinterface.h> |
17 | 15 |
|
18 | 16 | #include <algorithm> |
19 | 17 | #include <iterator> |
20 | 18 | #include <map> |
21 | 19 | #include <memory> |
22 | | -#include <stdio.h> |
23 | 20 | #include <set> |
24 | 21 | #include <string> |
| 22 | +#include <vector> |
25 | 23 |
|
26 | 24 | #include <boost/algorithm/string.hpp> |
27 | 25 |
|
@@ -254,13 +252,14 @@ static bool InitRPCAuthentication() |
254 | 252 | LogPrintf("Config options rpcuser and rpcpassword will soon be deprecated. Locally-run instances may remove rpcuser to use cookie-based auth, or may be replaced with rpcauth. Please see share/rpcauth for rpcauth auth generation.\n"); |
255 | 253 | strRPCUserColonPass = gArgs.GetArg("-rpcuser", "") + ":" + gArgs.GetArg("-rpcpassword", ""); |
256 | 254 | } |
257 | | - if (gArgs.GetArg("-rpcauth","") != "") |
258 | | - { |
| 255 | + if (gArgs.GetArg("-rpcauth", "") != "") { |
259 | 256 | LogPrintf("Using rpcauth authentication.\n"); |
260 | 257 | for (const std::string& rpcauth : gArgs.GetArgs("-rpcauth")) { |
261 | | - std::vector<std::string> fields; |
262 | | - boost::split(fields, rpcauth, boost::is_any_of(":$")); |
263 | | - if (fields.size() == 3) { |
| 258 | + std::vector<std::string> fields{SplitString(rpcauth, ':')}; |
| 259 | + const std::vector<std::string> salt_hmac{SplitString(fields.back(), '$')}; |
| 260 | + if (fields.size() == 2 && salt_hmac.size() == 2) { |
| 261 | + fields.pop_back(); |
| 262 | + fields.insert(fields.end(), salt_hmac.begin(), salt_hmac.end()); |
264 | 263 | g_rpcauth.push_back(fields); |
265 | 264 | } else { |
266 | 265 | LogPrintf("Invalid -rpcauth argument.\n"); |
|
0 commit comments