Get default user/password in every case.

Tweaks to fetching user/password from namecoin.conf that should now
always set values (in particular even if namecoin.conf is there but
has no rpcuser / rpcpassword set).
This commit is contained in:
Daniel Kraft 2013-07-18 07:09:49 +02:00
parent 25f0192fd6
commit 260bc80afe
1 changed files with 10 additions and 9 deletions

View File

@ -246,6 +246,8 @@ def ensureNamecoinOptions ():
hasPort = shared.config.has_option (configSection, "namecoinrpcport") hasPort = shared.config.has_option (configSection, "namecoinrpcport")
# Try to read user/password from .namecoin configuration file. # Try to read user/password from .namecoin configuration file.
defaultUser = ""
defaultPass = ""
try: try:
nmcFolder = lookupNamecoinFolder () nmcFolder = lookupNamecoinFolder ()
nmcConfig = nmcFolder + "namecoin.conf" nmcConfig = nmcFolder + "namecoin.conf"
@ -261,23 +263,22 @@ def ensureNamecoinOptions ():
val = parts[1].rstrip () val = parts[1].rstrip ()
if key == "rpcuser" and not hasUser: if key == "rpcuser" and not hasUser:
shared.config.set (configSection, defaultUser = val
"namecoinrpcuser", val)
if key == "rpcpassword" and not hasPass: if key == "rpcpassword" and not hasPass:
shared.config.set (configSection, defaultPass = val
"namecoinrpcpassword", val)
if key == "rpcport": if key == "rpcport":
shared.namecoinDefaultRpcPort = val shared.namecoinDefaultRpcPort = val
# Will be set in config below anyway.
nmc.close () nmc.close ()
except Exception as exc: except Exception as exc:
print "Failure reading namecoin config file: %s" % str (exc) print "Failure reading namecoin config file: %s" % str (exc)
if (not hasUser):
shared.config.set (configSection, "namecoinrpcuser", "") # If still nothing found, set empty at least.
if (not hasPass): if (not hasUser):
shared.config.set (configSection, "namecoinrpcpassword", "") shared.config.set (configSection, "namecoinrpcuser", defaultUser)
if (not hasPass):
shared.config.set (configSection, "namecoinrpcpassword", defaultPass)
# Set default port now, possibly to found value. # Set default port now, possibly to found value.
if (not hasPort): if (not hasPort):