Commit 4b17dea5 authored by Jelte Jansen's avatar Jelte Jansen

changed default_user.csv file used to store the bindctl user from $cwd to...

changed default_user.csv file used to store the bindctl user from $cwd to ~/.bind10/default_user.csv
if the directory cannot be make or the file cannot be written the default isn't stored (an error is printed but the session continues)
read/write permissions are for user only


git-svn-id: svn://bind10.isc.org/svn/bind10/trunk@1560 e5f2f494-b856-4b98-b285-d166d9295462
parent 08b92966
......@@ -115,7 +115,12 @@ class BindCmdInterpreter(Cmd):
csvfile = None
bsuccess = False
try:
csvfile = open('default_user.csv')
cvsfilepath = ""
if ('HOME' in os.environ):
cvsfilepath = os.environ['HOME']
cvsfilepath += os.sep + '.bind10' + os.sep
cvsfilepath += 'default_user.csv'
csvfile = open(cvsfilepath)
users = csv.reader(csvfile)
for row in users:
param = {'username': row[0], 'password' : row[1]}
......@@ -151,10 +156,23 @@ class BindCmdInterpreter(Cmd):
print(data)
if response.status == http.client.OK:
csvfile = open('default_user.csv', 'w')
writer = csv.writer(csvfile)
writer.writerow([username, passwd])
csvfile.close()
cvsfilepath = ""
try:
if ('HOME' in os.environ):
cvsfilepath = os.environ['HOME']
cvsfilepath += os.sep + '.bind10' + os.sep
if not os.path.exists(cvsfilepath):
os.mkdir(cvsfilepath, 0o700)
cvsfilepath += 'default_user.csv'
csvfile = open(cvsfilepath, 'w')
os.chmod(cvsfilepath, 0o600)
writer = csv.writer(csvfile)
writer.writerow([username, passwd])
csvfile.close()
except Exception as e:
# just not store it
print("Cannot write ~/.bind10/default_user.csv; default user is not stored")
print(e)
return True
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment