Skip to content

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

@Jenson3210

Description

@Jenson3210

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?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions