Skip to content

Commit

Permalink
Truncate mode bits for z/OS file permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
aguibert committed Nov 1, 2019
1 parent 7ab2430 commit adf5a28
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion core/src/main/java/org/testcontainers/utility/MountableFile.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
import org.apache.commons.compress.archivers.tar.TarConstants;
import org.apache.commons.lang.SystemUtils;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.DockerClientFactory;
Expand Down Expand Up @@ -363,7 +364,15 @@ private int getUnixFileMode(final String pathAsString) {
}

try {
return (int) Files.getAttribute(path, "unix:mode");
int unixMode = (int) Files.getAttribute(path, "unix:mode");
// Truncate mode bits for z/OS
if ("OS/390".equals(SystemUtils.OS_NAME) ||
"z/OS".equals(SystemUtils.OS_NAME) ||
"zOS".equals(SystemUtils.OS_NAME) ) {
unixMode &= TarConstants.MAXID;
unixMode |= Files.isDirectory(path) ? 040000 : 0100000;
}
return unixMode;
} catch (IOException | UnsupportedOperationException e) {
// fallback for non-posix environments
int mode = DEFAULT_FILE_MODE;
Expand Down

0 comments on commit adf5a28

Please sign in to comment.