From dc299828f99a0d7af42b80d4cb14d20856a47a0a Mon Sep 17 00:00:00 2001 From: "Dave Walker (Daviey)" Date: Fri, 27 Nov 2020 12:57:45 +0000 Subject: [PATCH] Fix OpenVPN import issue Previously, the command `htb lab import` would fail. This is because it was writing an empty file, as the write() would be buffered and not flush to file before the `nmcli` import was called. This change explicitly calls flush() to commit the changes to the file, meaning the contents is written to the file. Fixes: calebstewart/python-htb#6 Signed-off-by: Dave Walker (Daviey) --- htb/__main__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/htb/__main__.py b/htb/__main__.py index aa56481..c376803 100755 --- a/htb/__main__.py +++ b/htb/__main__.py @@ -912,6 +912,7 @@ def _nm_import_vpn(self, name, force=True) -> NetworkManager.Connection: with tempfile.NamedTemporaryFile() as ovpn: # Write the configuration to a file ovpn.write(self.cnxn.lab.config) + ovpn.flush() # Import the connection w/ Network Manager CLI p = subprocess.run(