Skip to content

Commit 0932c4a

Browse files
committed
Apply permissions consistently when creating uber jars and wars
Closes gh-46193
1 parent 17bed4c commit 0932c4a

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/main/java/org/springframework/boot/gradle/tasks/bundling/BootZipCopyAction.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ private boolean skipProcessing(FileCopyDetails details) {
256256
private void processDirectory(FileCopyDetails details) throws IOException {
257257
String name = details.getRelativePath().getPathString();
258258
ZipArchiveEntry entry = new ZipArchiveEntry(name + '/');
259-
prepareEntry(entry, name, getTime(details), getFileMode(details));
259+
prepareEntry(entry, name, getTime(details), getDirMode(details));
260260
this.out.putArchiveEntry(entry);
261261
this.out.closeArchiveEntry();
262262
this.writtenDirectories.add(name);
@@ -476,17 +476,21 @@ private Long getTime(FileCopyDetails details) {
476476

477477
private int getDirMode() {
478478
return (BootZipCopyAction.this.dirMode != null) ? BootZipCopyAction.this.dirMode
479-
: UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM;
479+
: UnixStat.DEFAULT_DIR_PERM;
480480
}
481481

482482
private int getFileMode() {
483483
return (BootZipCopyAction.this.fileMode != null) ? BootZipCopyAction.this.fileMode
484-
: UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM;
484+
: UnixStat.DEFAULT_FILE_PERM;
485+
}
486+
487+
private int getDirMode(FileCopyDetails details) {
488+
return (BootZipCopyAction.this.fileMode != null) ? BootZipCopyAction.this.dirMode : getPermissions(details);
485489
}
486490

487491
private int getFileMode(FileCopyDetails details) {
488492
return (BootZipCopyAction.this.fileMode != null) ? BootZipCopyAction.this.fileMode
489-
: UnixStat.FILE_FLAG | getPermissions(details);
493+
: getPermissions(details);
490494
}
491495

492496
private int getPermissions(FileCopyDetails details) {

spring-boot-project/spring-boot-tools/spring-boot-gradle-plugin/src/test/java/org/springframework/boot/gradle/tasks/bundling/AbstractBootArchiveIntegrationTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,10 +598,10 @@ void defaultDirAndFileModesAreUsed() throws IOException {
598598
continue;
599599
}
600600
if (entry.isDirectory()) {
601-
assertEntryMode(entry, UnixStat.DIR_FLAG | UnixStat.DEFAULT_DIR_PERM);
601+
assertEntryMode(entry, UnixStat.DEFAULT_DIR_PERM);
602602
}
603603
else {
604-
assertEntryMode(entry, UnixStat.FILE_FLAG | UnixStat.DEFAULT_FILE_PERM);
604+
assertEntryMode(entry, UnixStat.DEFAULT_FILE_PERM);
605605
}
606606
}
607607
}

0 commit comments

Comments
 (0)