tor: Remove workaround for old Augeas bug

The upstream issue was fixed in 2015:
https://github.com/hercules-team/augeas/pull/295

Tests:

- In stable container, add options like [arch=amd64] to apt
  sources.list.

- Enable package download through Tor. "tor+" is prepended to sources
  URL.

- Disable package download through Tor. "tor+" is removed from sources
  URL.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy 2022-11-19 19:52:36 -05:00 committed by Sunil Mohan Adapa
parent 2489074fa0
commit 3fac4f55fe
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
2 changed files with 1 additions and 27 deletions

View File

@ -14,8 +14,7 @@ import augeas
from plinth import action_utils
from plinth.actions import privileged
from plinth.modules.tor.utils import (APT_TOR_PREFIX, get_augeas,
get_real_apt_uri_path, iter_apt_uris)
from plinth.modules.tor.utils import APT_TOR_PREFIX, get_augeas, iter_apt_uris
SERVICE_FILE = '/etc/firewalld/services/tor-{0}.xml'
TOR_CONFIG = '/files/etc/tor/instances/plinth/torrc'
@ -415,7 +414,6 @@ def _enable_apt_transport_tor():
"""Enable package download over Tor."""
aug = get_augeas()
for uri_path in iter_apt_uris(aug):
uri_path = get_real_apt_uri_path(aug, uri_path)
uri = aug.get(uri_path)
if uri.startswith('http://') or uri.startswith('https://'):
aug.set(uri_path, APT_TOR_PREFIX + uri)
@ -432,7 +430,6 @@ def _disable_apt_transport_tor():
pass
for uri_path in iter_apt_uris(aug):
uri_path = get_real_apt_uri_path(aug, uri_path)
uri = aug.get(uri_path)
if uri.startswith(APT_TOR_PREFIX):
aug.set(uri_path, uri[len(APT_TOR_PREFIX):])

View File

@ -63,28 +63,6 @@ def iter_apt_uris(aug):
[aug.match(path) for path in APT_SOURCES_URI_PATHS])
def get_real_apt_uri_path(aug, path):
"""Return the actual path which contains APT URL.
XXX: This is a workaround for Augeas bug parsing Apt source files
with '[options]'. Remove this workaround after Augeas lens is
fixed.
"""
uri = aug.get(path)
if uri[0] == '[':
parent_path = path.rsplit('/', maxsplit=1)[0]
skipped = False
for child_path in aug.match(parent_path + '/*')[1:]:
if skipped:
return child_path
value = aug.get(child_path)
if value[-1] == ']':
skipped = True
return path
def get_augeas():
"""Return an instance of Augeaus for processing APT configuration."""
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
@ -121,7 +99,6 @@ def is_apt_transport_tor_enabled():
return False
for uri_path in iter_apt_uris(aug):
uri_path = get_real_apt_uri_path(aug, uri_path)
uri = aug.get(uri_path)
if not uri.startswith(APT_TOR_PREFIX) and \
(uri.startswith('http://') or uri.startswith('https://')):