Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFE] support xz compressed comps.xml #103

Closed
mattiaverga opened this issue Aug 21, 2023 · 8 comments
Closed

[RFE] support xz compressed comps.xml #103

mattiaverga opened this issue Aug 21, 2023 · 8 comments
Assignees

Comments

@mattiaverga
Copy link

It seems createrepo_c version 1.x defaults to XZ compress comps.xml also.
I tried to use something like:

                    if repo_info['group'].endswith('xz'):
                        xml_content = lzma.open(repo_info['group']).read()
>                       ret = comps.fromxml_f(xml_content)
E                       TypeError: function accept string and optional xml_options dict

Is there a clever way to make this work?
fedora-infra/bodhi#5455

@kontura kontura self-assigned this Aug 21, 2023
@kontura
Copy link
Contributor

kontura commented Aug 21, 2023

I think createrepo_c-1.0.0-1.fc39.x86_64 should default to zstd even for comps.

Nonetheless you can do:

xml_content = lzma.open("./comps.xml.xz").read()
ret = comps.fromxml_str(xml_content.decode())

@j-mracek
Copy link
Contributor

I also think that createrepo_c should have the same default for all types of metadata types.

@mattiaverga
Copy link
Author

Oh, yes, bodhi tests create repo with --xz, so they override the default compression.
However it seems before createrepo_c v1.x the comps.xml file was not compressed and just plain xml.

The above suggested solution
ret = comps.fromxml_str(xml_content.decode())
works when everything it's ok, but seems to not behave as expected when the content of comps.xml is invalid, returning a bad crash as Fatal Python error: Segmentation fault instead of raising an Exception, for example in this test:
https://github.com/fedora-infra/bodhi/actions/runs/5935123593/job/16093069432?pr=5455

@kontura
Copy link
Contributor

kontura commented Aug 22, 2023

Oh, yes, bodhi tests create repo with --xz, so they override the default compression. However it seems before createrepo_c v1.x the comps.xml file was not compressed and just plain xml.

This is one of the changes in 1.0.0 version. It used to create both compressed and uncompressed variants at the same time. Now there is only the compressed comps.

The above suggested solution ret = comps.fromxml_str(xml_content.decode()) works when everything it's ok, but seems to not behave as expected when the content of comps.xml is invalid, returning a bad crash as Fatal Python error: Segmentation fault instead of raising an Exception, for example in this test: https://github.com/fedora-infra/bodhi/actions/runs/5935123593/job/16093069432?pr=5455

Yes, that is a problem.

kontura added a commit to kontura/libcomps that referenced this issue Aug 22, 2023
It is not sufficient to check the return value after the function output
is used. We should check it right after to avoid a Segmentation fault.

For: rpm-software-management#103
@kontura
Copy link
Contributor

kontura commented Aug 22, 2023

I made a PR to fix the crash: #104

kontura added a commit to kontura/libcomps that referenced this issue Aug 22, 2023
It is not sufficient to check the return value after the function output
is used. We need check it sooner to avoid a Segmentation fault.

For: rpm-software-management#103
jan-kolarik pushed a commit that referenced this issue Sep 5, 2023
It is not sufficient to check the return value after the function output
is used. We need check it sooner to avoid a Segmentation fault.

For: #103
@mattiaverga
Copy link
Author

I've tested the above patch and now the test that previously crashed completes well.
However, I now get another segfault in the following test which is slightly different in what wrong content is passed in comps.xml.

@dralley
Copy link
Contributor

dralley commented Sep 19, 2023

Note that this isn't a fully new issue. Libcomps isn't very robust to invalid inputs in general #47

@kontura
Copy link
Contributor

kontura commented Sep 27, 2023

I have created another PR to patch some of the holes: #106
But yea there is likely more.

@kontura kontura closed this as completed Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants