Univention Bugzilla – Bug 55273
Different proxy http/https settings will not work in the appcenter cause only the http proxy variable is used
Last modified: 2023-01-17 16:46:57 CET
In the utils.py for the appcenter in function urlopen the proxy is defined as `proxy_http = ucr_get('proxy/http')` but this would never read `proxy/https` if configured. It may appear that a customer wants an other setting for the proxys.
From Bug #55561 https://git.knut.univention.de/univention/ucs/-/commits/phahn/55561_proxy5 diff --git management/univention-appcenter/python/appcenter-docker/actions/docker_upgrade.py management/univention-appcenter/python/appcenter-docker/actions/docker_upgrade.py index 31174498c5..1e44e9f2d6 100644 --- management/univention-appcenter/python/appcenter-docker/actions/docker_upgrade.py +++ management/univention-appcenter/python/appcenter-docker/actions/docker_upgrade.py @@ -85,9 +85,7 @@ class Upgrade(Upgrade, Install, DockerActionMixin): # update proxy settings if app.docker: aucr = get_action('configure')() - pvars = dict() - for psetting in ['proxy/http', 'proxy/https', 'proxy/no_proxy']: - pvars[psetting] = ucr_get(psetting) + pvars = {psetting: ucr_get(psetting) for psetting in ['proxy/http', 'proxy/https', 'proxy/no_proxy']} aucr._set_config_via_tool(app, pvars) result = self._execute_container_script(app, 'update_available', credentials=False, output=True) if result is not None: diff --git management/univention-appcenter/python/appcenter/utils.py management/univention-appcenter/python/appcenter/utils.py index 8e60441929..94f6334f81 100644 --- management/univention-appcenter/python/appcenter/utils.py +++ management/univention-appcenter/python/appcenter/utils.py @@ -346,10 +346,13 @@ class HTTPSHandler(urllib_request.HTTPSHandler): def urlopen(request): if not urlopen._opener_installed: - handler = [] - proxy_http = ucr_get('proxy/http') - if proxy_http: - handler.append(urllib_request.ProxyHandler({'http': proxy_http, 'https': proxy_http})) + proxies = { + schema: proxy + for schema, proxy in ( + (schema, ucr_get(f"proxy/{schema}")) for schema in ('http', 'https') + ) if proxy + } + handler = [urllib_request.ProxyHandler(proxies)] if proxies else [] handler.append(HTTPSHandler()) opener = urllib_request.build_opener(*handler) urllib_request.install_opener(opener) diff --git management/univention-appcenter/umc/python/appcenter/util.py management/univention-appcenter/umc/python/appcenter/util.py index e738339b38..5d587ff666 100644 --- management/univention-appcenter/umc/python/appcenter/util.py +++ management/univention-appcenter/umc/python/appcenter/util.py @@ -180,10 +180,13 @@ class HTTPSHandler(urllib_request.HTTPSHandler): def install_opener(ucr): - handler = [] - proxy_http = ucr.get('proxy/http') - if proxy_http: - handler.append(urllib_request.ProxyHandler({'http': proxy_http, 'https': proxy_http})) + proxies = { + schema: proxy + for schema, proxy in ( + (schema, ucr.get(f"proxy/{schema}")) for schema in ('http', 'https') + ) if proxy + } + handler = [urllib_request.ProxyHandler(proxies)] if proxies else [] handler.append(HTTPSHandler()) opener = urllib_request.build_opener(*handler) urllib_request.install_opener(opener) UMC is also affected: diff --git management/univention-management-console-module-udm/umc/python/udm/tools.py management/univention-management-console-module-udm/umc/python/udm/tools.py index 2e79e70a86..8c82cc2803 100644 --- management/univention-management-console-module-udm/umc/python/udm/tools.py +++ management/univention-management-console-module-udm/umc/python/udm/tools.py @@ -182,9 +182,14 @@ def _check_license(ldap_connection): # i.e. it should be unnecessary to import them directly # in a module def install_opener(ucr): - proxy_http = ucr.get('proxy/http') - if proxy_http: - proxy = ProxyHandler({'http': proxy_http, 'https': proxy_http}) + proxies = { + schema: proxy + for schema, proxy in ( + (schema, ucr.get(f"proxy/{schema}")) for schema in ('http', 'https') + ) if proxy + } + if proxies: + proxy = ProxyHandler(proxies) opener = build_opener(proxy) urllib_request.install_opener(opener)