KarmaGYZ commented on a change in pull request #14171:
URL: https://github.com/apache/flink/pull/14171#discussion_r529165927
##########
File path:
flink-runtime/src/test/java/org/apache/flink/runtime/security/modules/JaasModuleTest.java
##########
@@ -59,10 +63,21 @@ public void testJaasModuleFilePathIfWorkingDirNotPresent()
throws IOException {
testJaasModuleFilePath(file.toPath().toString() + "/tmp");
}
+ @Test
+ public void testJaasModuleFilePathIfWorkingDirIsSymLink() throws
IOException {
+ File baseFolder = folder.newFolder();
+ File actualFolder = new File(baseFolder, "actual_folder");
+ assertTrue(actualFolder.mkdir());
+
+ Path symlink = new File(baseFolder, "symlink").toPath();
+ Files.createSymbolicLink(symlink, actualFolder.toPath());
Review comment:
We may wrap that logic to something like
`createTempFolderAndItsSymLink`. Then, we could test the symbolic link case
with `testJaasModuleFilePath(symlink.toString() + "/tmp")`. WDYT?
##########
File path:
flink-runtime/src/main/java/org/apache/flink/runtime/security/modules/JaasModule.java
##########
@@ -159,12 +159,20 @@ private static File generateDefaultConfigFile(String
workingDir) {
checkArgument(workingDir != null, "working directory should not
be null.");
final File jaasConfFile;
try {
- Path path =
Files.createDirectories(Paths.get(workingDir));
+ Path path = Paths.get(workingDir);
+ if (Files.notExists(Paths.get(workingDir))) {
+ // We intentionally favored Path.toRealPath
over Files.readSymbolicLinks as the latter one might return a
+ // relative path if the symbolic link refers to
it. Path.toRealPath resolves the relative path instead.
+ Path parent = path.getParent().toRealPath();
+ Path resolvedPath =
Paths.get(parent.toString(), path.getFileName().toString());
+
+ path = Files.createDirectories(resolvedPath);
Review comment:
This logic seems not to be tested with a symbolic link.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]