Bug 1217192 - zypp services setting default value for zypp variable in repoindex file is not processed correctly
Summary: zypp services setting default value for zypp variable in repoindex file is no...
Status: NEW
Alias: None
Product: openSUSE Tumbleweed
Classification: openSUSE
Component: libzypp (show other bugs)
Version: Current
Hardware: Other Other
: P5 - None : Normal (vote)
Target Milestone: ---
Assignee: E-mail List
QA Contact: E-mail List
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-11-15 14:07 UTC by Lubos Kocman
Modified: 2024-04-18 10:50 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments
example repoindex (2.52 KB, text/xml)
2023-11-15 14:07 UTC, Lubos Kocman
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Lubos Kocman 2023-11-15 14:07:57 UTC
Created attachment 870774 [details]
example repoindex

lkocman@localhost:~/Downloads> grep DISTURL /usr/share/zypp/local/service/openSUSE/repo/opensuse-leap-repoindex.xml
    disturl="${OPENSUSE_DISTURL:-http://cdn.opensuse.org}"

Example repoindex (also attached to the bug)
https://github.com/lkocman/openSUSE-repos/blob/616df469398bbb946f15abf480463f738be7dfe9/opensuse-leap-repoindex.xml

lkocman@localhost:~/Downloads> sudo zypper ref -s
Refreshing service 'NVIDIA'.
Refreshing service 'openSUSE'.
Removing repository 'repo-non-oss (15.6)' .....................................................................................................................................[done]

...
Problem retrieving the repository index file for service 'openSUSE':
[|] Invalid Url scheme '${OPENSUSE_DISTURL'
History:
 - Invalid Url scheme '${OPENSUSE_DISTURL'
Comment 1 Lubos Kocman 2023-11-15 14:08:02 UTC
Related PR https://github.com/openSUSE/openSUSE-repos/pull/42
Comment 2 Lubos Kocman 2023-11-15 15:29:47 UTC
Also few more issues, there seems to be a hard check to have scheme (http:// https://) prior expanding the variable in $disturl. Also variable filename has to be lowercase (my bad for not catching it before).

So this works

$ grep DISTURL /usr/share/zypp/local/service/openSUSE/repo/opensuse-leap-repoindex.xml
disturl="http://${OPENSUSE_DISTURL}"

$ cat /etc/zypp/vars.d/opensuse_disturl
cdn.opensuse.org

This doesn't

$ grep DISTURL /usr/share/zypp/local/service/openSUSE/repo/opensuse-leap-repoindex.xml
disturl="${OPENSUSE_DISTURL}"

$ cat /etc/zypp/vars.d/opensuse_disturl
http://cdn.opensuse.org


lkocman@localhost:~> sudo zypper ref -s
Refreshing service 'NVIDIA'.
Refreshing service 'openSUSE'.
Problem retrieving the repository index file for service 'openSUSE':
[|] Url scheme is a required component
History:
 - Url scheme is a required component
Comment 3 Lubos Kocman 2023-11-15 15:37:27 UTC
And if you use e.g. http:// scheme in the record, then the :- is recognized as a port definition and complains about invalid port.
Comment 4 Michael Andres 2023-11-15 17:30:47 UTC
Hard to fix because internally even the unexpanded values are shipped as type URL (i.e. the unexpanded string must form a valid URL). 

It also has security implications. The string parsed from the repo or service info is immediately wrapped into class Url, because Url guarantees that a known password embedded in the URL is not printed to the screen or log if a Url is dumped. 

If we teach Url to ship unexpanded strings we're in danger not to detect  passwords exposed in the visible URl fragments.

Unfortunately yast-pkg-bindings seems to consume the `repoInfo().rawUrl()` (the not expanded URL). So we can not simply hide the raw strings inside libzypp. 

Needs careful thinking. Maybe Url needs to be enabled to detect embedded repo variables and then creates a valid URL with some schema zyppraw:... and with the raw string as payload. This way unexpanded URLs can be shipped safely in class Url.
Some care needs to be taken when writing zyppraw: back to a repo file. Preferably the original string should be restored, rather than the translated zyppraw: from.
Comment 5 Michael Andres 2023-11-17 15:33:38 UTC
https://github.com/openSUSE/libzypp/pull/497