Bug 55273 - Different proxy http/https settings will not work in the appcenter cause only the http proxy variable is used
Different proxy http/https settings will not work in the appcenter cause only...
Status: NEW
Product: UCS
Classification: Unclassified
Component: App Center
UCS 5.0
Other Linux
: P5 minor (vote)
: ---
Assigned To: App Center maintainers
App Center maintainers
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2022-10-17 09:08 CEST by Tim Breidenbach
Modified: 2023-01-17 16:46 CET (History)
2 users (show)

See Also:
What kind of report is it?: Feature Request
What type of bug is this?: ---
Who will be affected by this bug?: ---
How will those affected feel about the bug?: ---
User Pain:
Enterprise Customer affected?:
School Customer affected?:
ISV affected?:
Waiting Support:
Flags outvoted (downgraded) after PO Review:
Ticket number:
Bug group (optional): bitesize
Max CVSS v3 score:
hahn: Patch_Available+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tim Breidenbach univentionstaff 2022-10-17 09:08:12 CEST
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.
Comment 1 Philipp Hahn univentionstaff 2023-01-17 16:46:57 CET
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)