rpcauthfile: Support multiple lines each with a different auth config

This commit is contained in:
Luke Dashjr 2021-01-30 16:09:07 +00:00
parent 732efacf78
commit 07bdd6864a
2 changed files with 10 additions and 9 deletions

View File

@ -40,8 +40,8 @@ def main():
rpcauth = f'{args.username}:{salt}${password_hmac}' rpcauth = f'{args.username}:{salt}${password_hmac}'
if args.output: if args.output:
file = open(args.output, "x", encoding="utf8") file = open(args.output, "a", encoding="utf8")
file.write(rpcauth) file.write(rpcauth + "\n")
if args.json: if args.json:
odict={'username':args.username, 'password':args.password} odict={'username':args.username, 'password':args.password}

View File

@ -335,13 +335,14 @@ static bool InitRPCAuthentication()
file.open(path); file.open(path);
if (!file.is_open()) continue; if (!file.is_open()) continue;
std::string rpcauth; std::string rpcauth;
std::getline(file, rpcauth); while (std::getline(file, rpcauth)) {
std::vector<std::string> fields{SplitString(rpcauth, ':')}; std::vector<std::string> fields{SplitString(rpcauth, ':')};
const std::vector<std::string> salt_hmac{SplitString(fields.back(), '$')}; const std::vector<std::string> salt_hmac{SplitString(fields.back(), '$')};
if (fields.size() == 2 && salt_hmac.size() == 2) { if (fields.size() == 2 && salt_hmac.size() == 2) {
fields.pop_back(); fields.pop_back();
fields.insert(fields.end(), salt_hmac.begin(), salt_hmac.end()); fields.insert(fields.end(), salt_hmac.begin(), salt_hmac.end());
g_rpcauth.push_back(fields); g_rpcauth.push_back(fields);
}
} }
} }
} }