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

Replace CRLF with LF on release files #59

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gschizas
Copy link

This resolves NEXUS-21834 which prevents APT repositories from working when running under Windows

This resolves NEXUS-21834 which prevents APT repositories from working when running under Windows
@aornatovskyy
Copy link

Hi @gschizas !
First of all, thank you for your contribution, for spending time on issue investigation and providing a solution.
Looks like there is a problem with the generation metadata stage and it is better to fix the issue on that stage instead of afterward.

Can you please attach the example of a corrupted file to the ticket?

Regards,
Anatoliy

@gschizas
Copy link
Author

gschizas commented Dec 3, 2019

The problem seems to be mostly in the PGP signing.
Here's a sample response I made with mitmproxy. And here's the
full mitmproxy file (whatever that means).

You'll see that some lines end with CR+LF (lines 1-3 and 17-28) and some with just LF (lines 3-16)

@maxhermann
Copy link

Hi there,

i guess that i run into the same issue here. May i ask when the fix will be merged @aornatovskyy ?

Im using Nexus Repository for a Yocto Linux and got problems with the lineendings like gschizas.
Seems like this Yocto can't handle the mixed CRLF LF endings that well.

Regards,
Max

Copy link

@mynewzone mynewzone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

t

@gschizas
Copy link
Author

I managed to do a workaround, using URL rewrite.

Add this to web.config:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <outboundRules>
                <rule name="Replace CRLF with LF" preCondition="ReleaseFile">
                    <match filterByTags="None" pattern="\r" />
                    <action type="Rewrite" value="" />
                </rule>
                <preConditions>
                    <preCondition name="ReleaseFile">
                        <add input="{REQUEST_URI}" pattern="/repository/([-a-z0-9]*)/dists/(\w*)/InRelease" />
                    </preCondition>
                </preConditions>
            </outboundRules>
        </rewrite>
    </system.webServer>
</configuration>

And then it just works!

The REQUEST_URI does most of the heavy lifting. It should work for most cases, but if it doesn't, it's easy to extend the regular expression, or even hardcode the URL for the repo.

This is still just a workaround, but it's one that works without any changes to the code.

@maxhermann
Copy link

Thanks for your solution.

After I had read your post I came up with another idea.

We routed the ../InRelease file for all our apt-repositories to a 404 error page. This way the "apt-get update" command results in using the normal "release" file instead of the corrupted "InRelease" that is produced by the repo. Now apt-get update works again.

That could be a cleaner workaround instead of modifying the file itself.

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

Successfully merging this pull request may close these issues.

4 participants