mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-10-01 11:22:13 +00:00
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
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user