forked from p15670423/monkey
Implement `has_sufficient_permissions` function for checking certificate files
This commit is contained in:
parent
c9a53833e2
commit
c1463b4a18
|
@ -14,10 +14,17 @@ def setup_certificate(config_options: IslandConfigOptions) -> (str, str):
|
||||||
raise FileNotFoundError(f"File not found at {file}. Exiting.")
|
raise FileNotFoundError(f"File not found at {file}. Exiting.")
|
||||||
|
|
||||||
if not has_sufficient_permissions(file):
|
if not has_sufficient_permissions(file):
|
||||||
raise InsecurePermissionsError(f"{file} has insecure permissions. Exiting.")
|
raise InsecurePermissionsError(
|
||||||
|
f"{file} has insecure permissions. Required permissions: r--------. Exiting."
|
||||||
|
)
|
||||||
|
|
||||||
return crt_path, key_path
|
return crt_path, key_path
|
||||||
|
|
||||||
|
|
||||||
def has_sufficient_permissions():
|
def has_sufficient_permissions(path: str) -> bool:
|
||||||
pass
|
required_permissions = "0o400"
|
||||||
|
|
||||||
|
file_mode = os.stat(path).st_mode
|
||||||
|
file_permissions = oct(file_mode & 0o777)
|
||||||
|
|
||||||
|
return file_permissions == required_permissions
|
||||||
|
|
Loading…
Reference in New Issue