mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Correct the permissions of scripts in archives of boot distribution
Closes gh-14158
This commit is contained in:
parent
e84d6cd95b
commit
630e2d0b41
@ -80,7 +80,7 @@ final class ApplicationPluginAction implements PluginApplicationAction {
|
||||
bootStartScripts.getConventionMapping().map("defaultJvmOpts",
|
||||
applicationConvention::getApplicationDefaultJvmArgs);
|
||||
CopySpec binCopySpec = project.copySpec().into("bin").from(bootStartScripts);
|
||||
binCopySpec.setFileMode(0x755);
|
||||
binCopySpec.setFileMode(0755);
|
||||
distribution.getContents().with(binCopySpec);
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
@ -156,6 +157,26 @@ public class ApplicationPluginActionIntegrationTests {
|
||||
"custom-boot/bin/custom.bat");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scriptsHaveCorrectPermissions() throws IOException {
|
||||
assertThat(
|
||||
this.gradleBuild.build("bootDistTar").task(":bootDistTar").getOutcome())
|
||||
.isEqualTo(TaskOutcome.SUCCESS);
|
||||
String name = this.gradleBuild.getProjectDir().getName();
|
||||
File distribution = new File(this.gradleBuild.getProjectDir(),
|
||||
"build/distributions/" + name + "-boot.tar");
|
||||
assertThat(distribution).isFile();
|
||||
tarEntries(distribution, (entry) -> {
|
||||
int filePermissions = entry.getMode() & 0777;
|
||||
if (entry.isFile() && !entry.getName().startsWith(name + "-boot/bin/")) {
|
||||
assertThat(filePermissions).isEqualTo(0644);
|
||||
}
|
||||
else {
|
||||
assertThat(filePermissions).isEqualTo(0755);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private List<String> zipEntryNames(File distribution) throws IOException {
|
||||
List<String> entryNames = new ArrayList<>();
|
||||
try (ZipFile zipFile = new ZipFile(distribution)) {
|
||||
@ -179,4 +200,15 @@ public class ApplicationPluginActionIntegrationTests {
|
||||
return entryNames;
|
||||
}
|
||||
|
||||
private void tarEntries(File distribution, Consumer<TarArchiveEntry> consumer)
|
||||
throws IOException {
|
||||
try (TarArchiveInputStream input = new TarArchiveInputStream(
|
||||
new FileInputStream(distribution))) {
|
||||
TarArchiveEntry entry;
|
||||
while ((entry = input.getNextTarEntry()) != null) {
|
||||
consumer.accept(entry);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath files(pluginClasspath.split(','))
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'application'
|
||||
apply plugin: 'java'
|
||||
|
||||
bootJar {
|
||||
mainClassName = 'com.example.ExampleApplication'
|
||||
}
|
Loading…
Reference in New Issue
Block a user