From bc6d66cd88c7295581594ae6d7544f3439e2a18f Mon Sep 17 00:00:00 2001 From: Jens Langhammer Date: Mon, 24 Apr 2023 16:23:22 +0300 Subject: [PATCH] use open Signed-off-by: Jens Langhammer --- authentik/outposts/docker_ssh.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/authentik/outposts/docker_ssh.py b/authentik/outposts/docker_ssh.py index fea1da490..64843bbf7 100644 --- a/authentik/outposts/docker_ssh.py +++ b/authentik/outposts/docker_ssh.py @@ -32,12 +32,13 @@ class DockerInlineSSH: self.host = host self.keypair = keypair self.config_path = SSH_CONFIG_DIR / Path(self.host + ".conf") - if not open(self.config_path, "w").writable(): - # SSH Config file already exists and there's no header from us, meaning that it's - # been externally mapped into the container for more complex configs - raise SSHManagedExternallyException( - "SSH Config exists and does not contain authentik header" - ) + with open(self.config_path, "w", encoding="utf-8") as _config: + if not _config.writable(): + # SSH Config file already exists and there's no header from us, meaning that it's + # been externally mapped into the container for more complex configs + raise SSHManagedExternallyException( + "SSH Config exists and does not contain authentik header" + ) if not self.keypair: raise DockerException("keypair must be set for SSH connections")