You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2020/10/27 12:54:26 UTC
[flink] branch release-1.10 updated: [FLINK-19252][security]
Proactively create the working dir for Jaas security module
This is an automated email from the ASF dual-hosted git repository.
chesnay pushed a commit to branch release-1.10
in repository https://gitbox.apache.org/repos/asf/flink.git
The following commit(s) were added to refs/heads/release-1.10 by this push:
new 64f4f98 [FLINK-19252][security] Proactively create the working dir for Jaas security module
64f4f98 is described below
commit 64f4f98b305b79bfa9df2eda544fe83547608c25
Author: Yangze Guo <ka...@gmail.com>
AuthorDate: Tue Oct 27 20:49:01 2020 +0800
[FLINK-19252][security] Proactively create the working dir for Jaas security module
---
.../flink/runtime/security/modules/JaasModule.java | 2 +-
.../flink/runtime/security/modules/JaasModuleTest.java | 18 +++++++++++++-----
2 files changed, 14 insertions(+), 6 deletions(-)
diff --git a/flink-runtime/src/main/java/org/apache/flink/runtime/security/modules/JaasModule.java b/flink-runtime/src/main/java/org/apache/flink/runtime/security/modules/JaasModule.java
index dd560ba..16c176b 100644
--- a/flink-runtime/src/main/java/org/apache/flink/runtime/security/modules/JaasModule.java
+++ b/flink-runtime/src/main/java/org/apache/flink/runtime/security/modules/JaasModule.java
@@ -159,7 +159,7 @@ public class JaasModule implements SecurityModule {
checkArgument(workingDir != null, "working directory should not be null.");
final File jaasConfFile;
try {
- Path path = Paths.get(workingDir);
+ Path path = Files.createDirectories(Paths.get(workingDir));
Path jaasConfPath = Files.createTempFile(path, "jaas-", ".conf");
try (InputStream resourceStream = JaasModule.class.getClassLoader().getResourceAsStream(JAAS_CONF_RESOURCE_NAME)) {
Files.copy(resourceStream, jaasConfPath, StandardCopyOption.REPLACE_EXISTING);
diff --git a/flink-runtime/src/test/java/org/apache/flink/runtime/security/modules/JaasModuleTest.java b/flink-runtime/src/test/java/org/apache/flink/runtime/security/modules/JaasModuleTest.java
index d44268d..010a657 100644
--- a/flink-runtime/src/test/java/org/apache/flink/runtime/security/modules/JaasModuleTest.java
+++ b/flink-runtime/src/test/java/org/apache/flink/runtime/security/modules/JaasModuleTest.java
@@ -47,14 +47,22 @@ public class JaasModuleTest {
folder.create();
}
- /**
- * Test that the jaas config file is created in the working directory.
- */
@Test
- public void testJaasModuleFilePath() throws IOException {
+ public void testJaasModuleFilePathIfWorkingDirPresent() throws IOException {
File file = folder.newFolder();
- String workingDir = file.toPath().toString();
+ testJaasModuleFilePath(file.toPath().toString());
+ }
+ @Test
+ public void testJaasModuleFilePathIfWorkingDirNotPresent() throws IOException {
+ File file = folder.newFolder();
+ testJaasModuleFilePath(file.toPath().toString() + "/tmp");
+ }
+
+ /**
+ * Test that the jaas config file is created in the working directory.
+ */
+ private void testJaasModuleFilePath(String workingDir) {
Configuration configuration = new Configuration();
// set the string for CoreOptions.TMP_DIRS to mock the working directory.
configuration.setString(CoreOptions.TMP_DIRS, workingDir);