Merge "Clarify message if key file has wrong permissions" into stable/ocata

This commit is contained in:
Jenkins 2017-05-19 09:44:49 +00:00 committed by Gerrit Code Review
commit 53e8d0744d
1 changed files with 3 additions and 1 deletions

View File

@ -46,7 +46,9 @@ def generate_key(key_length=64):
def read_from_file(key_file='.secret_key'):
if (os.stat(key_file).st_mode & 0o777) != 0o600:
raise FilePermissionError("Insecure key file permissions!")
raise FilePermissionError(
"Insecure permissions on key file %s, should be 0600." %
os.path.abspath(key_file))
with open(key_file, 'r') as f:
key = f.readline()
return key