Skip to content

Commit

Permalink
Move the init of ConfigImport object before downloading profile
Browse files Browse the repository at this point in the history
The init phase of the ConfigImport object does the config name
duplication check.  By moving the init before the profile download we
will bail out earlier and quicker with an error in case of non-unique
configuration names and we don't issue any remote operations until we
are ready to process the retrieved data locally.

Signed-off-by: David Sommerseth <[email protected]>
  • Loading branch information
dsommers committed Jan 12, 2022
1 parent 417ada2 commit 10c81cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions openvpn/connector/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ def main():
# and a key used to decrypt the downloaded profile
token = DecodeToken(token)

systembus = dbus.SystemBus()
cfgimport = None
if ConfigModes.UNITFILE == run_mode:
cfgimport = ConfigImport(systembus, config_name)

# Download the profile from OpenVPN Cloud
profile = ProfileFetch(token)
print('Downloading OpenVPN Cloud Connector profile ... ', end='', flush=True)
profile.Download()
print('Done')

systembus = dbus.SystemBus()
if ConfigModes.AUTOLOAD == run_mode:
# Generate the openvpn3-autoload configuration
autoload = AutoloadConfig(profile, rootdir, autoload_prefix)
Expand All @@ -145,7 +149,6 @@ def main():
print('Done')

elif ConfigModes.UNITFILE == run_mode:
cfgimport = ConfigImport(systembus, config_name)
cfgimport.Import(profile)

if os.geteuid() != 0:
Expand Down

0 comments on commit 10c81cb

Please sign in to comment.