diff --git a/share/rpcauth/rpcauth.py b/share/rpcauth/rpcauth.py index 1a6c8cc901..36a2b1b7f3 100755 --- a/share/rpcauth/rpcauth.py +++ b/share/rpcauth/rpcauth.py @@ -40,8 +40,8 @@ def main(): rpcauth = f'{args.username}:{salt}${password_hmac}' if args.output: - file = open(args.output, "x", encoding="utf8") - file.write(rpcauth) + file = open(args.output, "a", encoding="utf8") + file.write(rpcauth + "\n") if args.json: odict={'username':args.username, 'password':args.password} diff --git a/src/httprpc.cpp b/src/httprpc.cpp index 9c0815aac6..c74de5baaa 100644 --- a/src/httprpc.cpp +++ b/src/httprpc.cpp @@ -335,13 +335,14 @@ static bool InitRPCAuthentication() file.open(path); if (!file.is_open()) continue; std::string rpcauth; - std::getline(file, rpcauth); - std::vector fields{SplitString(rpcauth, ':')}; - const std::vector salt_hmac{SplitString(fields.back(), '$')}; - if (fields.size() == 2 && salt_hmac.size() == 2) { - fields.pop_back(); - fields.insert(fields.end(), salt_hmac.begin(), salt_hmac.end()); - g_rpcauth.push_back(fields); + while (std::getline(file, rpcauth)) { + std::vector fields{SplitString(rpcauth, ':')}; + const std::vector salt_hmac{SplitString(fields.back(), '$')}; + if (fields.size() == 2 && salt_hmac.size() == 2) { + fields.pop_back(); + fields.insert(fields.end(), salt_hmac.begin(), salt_hmac.end()); + g_rpcauth.push_back(fields); + } } } }