Skip to content

Commit

Permalink
Bugfix: revert /etc/resolv.conf back to the original if it was modifi…
Browse files Browse the repository at this point in the history
…ed in a finally block (only for connect code invocations), ran tests on macOS
  • Loading branch information
1951FDG committed Mar 19, 2021
1 parent 2bdaa88 commit 5aa0aa5
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions openpyn/openpyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,10 @@ def run(init: bool, server: str, country_code: str, country: str, area: str, tcp
return 1
except SystemExit:
logger.info("Shutting down safely, please wait until process exits")
finally:
if skip_dns_patch is False:
# Darwin: Revert /etc/resolv.conf back to the original if it was modified
subprocess.call(["sudo", "-u", sudo_user, __basefilepath__ + "scripts/revert-manual-dns-patch.sh"])

elif server:
try:
Expand Down Expand Up @@ -629,14 +633,14 @@ def run(init: bool, server: str, country_code: str, country: str, area: str, tcp
return 1
except SystemExit:
logger.info("Shutting down safely, please wait until process exits")
finally:
if skip_dns_patch is False:
# Darwin: Revert /etc/resolv.conf back to the original if it was modified
subprocess.call(["sudo", "-u", sudo_user, __basefilepath__ + "scripts/revert-manual-dns-patch.sh"])

else:
logger.info("To see usage options type: 'openpyn -h' or 'openpyn --help'")

if skip_dns_patch is False:
# Darwin: Revert /etc/resolv.conf back to the original if it was modified
subprocess.call(["sudo", "-u", sudo_user, __basefilepath__ + "scripts/revert-manual-dns-patch.sh"])

# if everything went ok
return 0

Expand Down

0 comments on commit 5aa0aa5

Please sign in to comment.