Error if rpcpassword contains hash in conf sections
This commit is contained in:
1 parent
031e3a32b2
commit
8cff83124b
2 files changed
+9
-1
No files matched your search
+1
-1
@@ -865,7 +865,7 @@ static bool GetConfigOptions(std::istream& stream, std::string& error, std::vect
|
|||||||
} else if ((pos = str.find('=')) != std::string::npos) {
|
} else if ((pos = str.find('=')) != std::string::npos) {
|
||||||
std::string name = prefix + TrimString(str.substr(0, pos), pattern);
|
std::string name = prefix + TrimString(str.substr(0, pos), pattern);
|
||||||
std::string value = TrimString(str.substr(pos + 1), pattern);
|
std::string value = TrimString(str.substr(pos + 1), pattern);
|
||||||
if (used_hash && name == "rpcpassword") {
|
if (used_hash && name.find("rpcpassword") != std::string::npos) {
|
||||||
error = strprintf("parse error on line %i, using # in rpcpassword can be ambiguous and should be avoided", linenr);
|
error = strprintf("parse error on line %i, using # in rpcpassword can be ambiguous and should be avoided", linenr);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,14 @@ class ConfArgsTest(BitcoinTestFramework):
|
|||||||
conf.write('server=1\nrpcuser=someuser\nrpcpassword=some#pass')
|
conf.write('server=1\nrpcuser=someuser\nrpcpassword=some#pass')
|
||||||
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 3, using # in rpcpassword can be ambiguous and should be avoided')
|
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 3, using # in rpcpassword can be ambiguous and should be avoided')
|
||||||
|
|
||||||
|
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
||||||
|
conf.write('server=1\nrpcuser=someuser\nmain.rpcpassword=some#pass')
|
||||||
|
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 3, using # in rpcpassword can be ambiguous and should be avoided')
|
||||||
|
|
||||||
|
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
||||||
|
conf.write('server=1\nrpcuser=someuser\n[main]\nrpcpassword=some#pass')
|
||||||
|
self.nodes[0].assert_start_raises_init_error(expected_msg='Error reading configuration file: parse error on line 4, using # in rpcpassword can be ambiguous and should be avoided')
|
||||||
|
|
||||||
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
with open(inc_conf_file_path, 'w', encoding='utf-8') as conf:
|
||||||
conf.write('testnot.datadir=1\n[testnet]\n')
|
conf.write('testnot.datadir=1\n[testnet]\n')
|
||||||
self.restart_node(0)
|
self.restart_node(0)
|
||||||
|
|||||||
Reference in new issue
Block a user