Clarify message if key file has wrong permissions
The message now includes the path to the file being checked, and the
expected permissions.
@@ -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
