aboutsummaryrefslogtreecommitdiffstats
path: root/vespaclient-java/src/main/java/com/yahoo
diff options
context:
space:
mode:
authorTor Brede Vekterli <vekterli@yahooinc.com>2023-05-02 16:38:32 +0200
committerTor Brede Vekterli <vekterli@yahooinc.com>2023-05-02 16:38:32 +0200
commit9efc6df01c94971e9254affd2800f04b4dd0cb68 (patch)
tree301773eb31a2031d02eb2ef66e55a09f8c432e60 /vespaclient-java/src/main/java/com/yahoo
parente23486dfb4adaf88242053c9ce27acdc2beeb6ff (diff)
Create crypto tool output streams with RW permissions for owner only
Diffstat (limited to 'vespaclient-java/src/main/java/com/yahoo')
-rw-r--r--vespaclient-java/src/main/java/com/yahoo/vespa/security/tool/CliUtils.java6
1 files changed, 5 insertions, 1 deletions
diff --git a/vespaclient-java/src/main/java/com/yahoo/vespa/security/tool/CliUtils.java b/vespaclient-java/src/main/java/com/yahoo/vespa/security/tool/CliUtils.java
index a60c3647b41..b09ae17cd77 100644
--- a/vespaclient-java/src/main/java/com/yahoo/vespa/security/tool/CliUtils.java
+++ b/vespaclient-java/src/main/java/com/yahoo/vespa/security/tool/CliUtils.java
@@ -8,6 +8,7 @@ import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
+import java.nio.file.attribute.PosixFilePermissions;
/**
* @author vekterli
@@ -43,7 +44,10 @@ public class CliUtils {
return stdOut;
} else {
// TODO fail if file already exists?
- return Files.newOutputStream(Paths.get(pathOrDash));
+ var privFilePerms = PosixFilePermissions.fromString("rw-------");
+ var outPath = Paths.get(pathOrDash);
+ Files.createFile(outPath, PosixFilePermissions.asFileAttribute(privFilePerms));
+ return Files.newOutputStream(outPath);
}
}