diff --git a/plinth/modules/torproxy/privileged.py b/plinth/modules/torproxy/privileged.py index 93ea17d2d..8ce68cc2a 100644 --- a/plinth/modules/torproxy/privileged.py +++ b/plinth/modules/torproxy/privileged.py @@ -161,12 +161,7 @@ def _enable_apt_transport_tor(): def _disable_apt_transport_tor(): """Disable package download over Tor.""" - try: - aug = get_augeas() - except Exception: - # Disable what we can, so APT is not unusable. - pass - + aug = get_augeas(raise_exception=False) for uri_path in iter_apt_uris(aug): uri = aug.get(uri_path) if uri.startswith(APT_TOR_PREFIX): diff --git a/plinth/modules/torproxy/utils.py b/plinth/modules/torproxy/utils.py index 82f1e810e..9a582625a 100644 --- a/plinth/modules/torproxy/utils.py +++ b/plinth/modules/torproxy/utils.py @@ -36,7 +36,7 @@ def iter_apt_uris(aug): [aug.match(path) for path in APT_SOURCES_URI_PATHS]) -def get_augeas(): +def get_augeas(raise_exception=True): """Return an instance of Augeaus for processing APT configuration.""" aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD) @@ -51,9 +51,10 @@ def get_augeas(): aug.load() # Check for any errors in parsing sources lists. - if aug.match('/augeas/files/etc/apt/sources.list/error') or \ - aug.match('/augeas/files/etc/apt/sources.list.d//error'): - raise Exception('Error parsing sources list') + if raise_exception: + if aug.match('/augeas/files/etc/apt/sources.list/error') or \ + aug.match('/augeas/files/etc/apt/sources.list.d//error'): + raise Exception('Error parsing sources list') return aug