Clarify message if key file has wrong permissions

The message now includes the path to the file being checked, and the
expected permissions.

Change-Id: I5692ea55d9af8f52757dc77504cd7b875f40d396
(cherry picked from commit 751bd80e1b)
This commit is contained in:
Miles Gould 2017-03-09 15:43:14 +00:00 committed by Rob Cresswell
parent cfdaa2ec86
commit 1f2e5a875f
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