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

Tar archive creation fails if user id is too big #1612

Closed
Jenson3210 opened this issue Jan 7, 2025 · 3 comments
Closed

Tar archive creation fails if user id is too big #1612

Jenson3210 opened this issue Jan 7, 2025 · 3 comments
Assignees
Milestone

Comments

@Jenson3210
Copy link

When running our own initializr in an Openshift namespace, we have default openshift SCC's active that require standard apps to run with a random userId within a given range. However this range is by default higher than the maximum value (=2097151)

When running, the tgz creation through REST endpoint, we're seeing following error:

java.lang.IllegalArgumentException: user id 'replaced' is too big ( > 2097151 ).
    at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.failForBigNumber(TarArchiveOutputStream.java:406) ~[commons-compress-1.23.0.jar:1.23.0]
    at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.failForBigNumber(TarArchiveOutputStream.java:400) ~[commons-compress-1.23.0.jar:1.23.0]
    at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.failForBigNumbers(TarArchiveOutputStream.java:418) ~[commons-compress-1.23.0.jar:1.23.0]
    at org.apache.commons.compress.archivers.tar.TarArchiveOutputStream.putArchiveEntry(TarArchiveOutputStream.java:592) ~[commons-compress-1.23.0.jar:1.23.0]
    at io.spring.initializr.web.controller.ProjectGenerationController.lambda$createArchive$1(ProjectGenerationController.java:168) ~[initializr-web-0.20.1.jar:na]

When searching we discovered similar issues in testcontainers and docker-maven-plugin with both very similar fixes: Setting the posix BigNumberMode (testcontainers and plugin)

Looking at the stacktrace, I found this snippet which does not set it.

TarArchiveOutputStream out = new TarArchiveOutputStream(new GzipCompressorOutputStream(output));
out.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);
return out;

After adding out.setBigNumberMode(TarArchiveOutputStream.BIGNUMBER_POSIX);, it is working fine.
Unfortunately this is part of a private method in the abstract class, and overridding it requires a lot of the other methods (all private) to be overridden also. Starting from the exposed controller method, all methods need overriding for this adoption.

I think we could either make it protected or add the big filenumberMode by default? Or can we somehow feed it as a property?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jan 7, 2025
@mhalbritter mhalbritter changed the title user id 'xxx' is too big ( > 2097151 ) when running with large user id TAR archive creation fails if user id is too big Jan 7, 2025
@mhalbritter mhalbritter added type: bug and removed status: waiting-for-triage An issue we've not yet triaged labels Jan 7, 2025
@mhalbritter mhalbritter changed the title TAR archive creation fails if user id is too big Tar archive creation fails if user id is too big Jan 7, 2025
@mhalbritter
Copy link
Contributor

We already enable the POSIX extensions for long filenames (out.setLongFileMode(TarArchiveOutputStream.LONGFILE_POSIX);). I don't think there's harm in also enable that for the big number mode.

@mhalbritter mhalbritter self-assigned this Jan 7, 2025
@mhalbritter mhalbritter added this to the 0.22.0 milestone Jan 7, 2025
@Jenson3210
Copy link
Author

Thanks for the quick resolution @mhalbritter!
I do not see in the docs/milestone page what the expected due date would be for this.
Is there any upcoming release?
Or can I use the milestone version?

@mhalbritter
Copy link
Contributor

You can use the snapshot version until there's a new release. I haven't planned a release date for the next version yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants