Skip to content

Commit

Permalink
Fix OpenVPN import issue
Browse files Browse the repository at this point in the history
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#6
Signed-off-by: Dave Walker (Daviey) <[email protected]>
  • Loading branch information
Daviey committed Nov 27, 2020
1 parent ffc26c3 commit dc29982
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions htb/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit dc29982

Please sign in to comment.