Skip to content

Commit

Permalink
Issue #5451 - Setting ServletContext temp dir to user private
Browse files Browse the repository at this point in the history
Signed-off-by: Joakim Erdfelt <joakim.erdfelt@gmail.com>
  • Loading branch information
joakime committed Oct 16, 2020
1 parent a23b01e commit 74d1473
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
Expand Up @@ -42,7 +42,6 @@

import org.eclipse.jetty.util.BufferUtil;
import org.eclipse.jetty.util.ByteArrayOutputStream2;
import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.LazyList;
import org.eclipse.jetty.util.MultiException;
import org.eclipse.jetty.util.MultiMap;
Expand Down Expand Up @@ -152,8 +151,8 @@ protected void write(byte[] bytes, int offset, int length) throws IOException

protected void createFile() throws IOException
{
Path parent = MultiPartFormInputStream.this._tmpDir.toPath();
Path tempFile = Files.createTempFile(parent, "MultiPart", "", IO.getUserOnlyFileAttribute(parent));
// Create temp file in Context tempDir (which is user private already)
Path tempFile = Files.createTempFile(MultiPartFormInputStream.this._tmpDir.toPath(), "MultiPart", "");
_file = tempFile.toFile();

OutputStream fos = Files.newOutputStream(tempFile, StandardOpenOption.WRITE);
Expand Down
2 changes: 1 addition & 1 deletion jetty-util/src/main/java/org/eclipse/jetty/util/IO.java
Expand Up @@ -474,7 +474,7 @@ public static void close(Writer writer)
* For Windows / Dos, that means {@link java.nio.file.attribute.DosFileAttributes}
* </p>
*/
public static FileAttribute<?>[] getUserOnlyFileAttribute(Path path)
public static FileAttribute<?>[] getUserPrivateFileAttribute(Path path)
{
FileStore fileStore = null;
try
Expand Down
Expand Up @@ -190,8 +190,8 @@ protected void write(byte[] bytes, int offset, int length)
protected void createFile()
throws IOException
{
Path parent = MultiPartInputStreamParser.this._tmpDir.toPath();
Path tempFile = Files.createTempFile(parent, "MultiPart", "", IO.getUserOnlyFileAttribute(parent));
// Create temp file in Context tempDir (which is user private already)
Path tempFile = Files.createTempFile(MultiPartInputStreamParser.this._tmpDir.toPath(), "MultiPart", "");
_file = tempFile.toFile();

OutputStream fos = Files.newOutputStream(tempFile, StandardOpenOption.WRITE);
Expand Down
Expand Up @@ -508,7 +508,7 @@ public void makeTempDirectory(File parent, WebAppContext context)
else
{
//ensure file will always be unique by appending random digits
tmpDir = Files.createTempDirectory(parent.toPath(), temp, IO.getUserOnlyFileAttribute(parent.toPath())).toFile();
tmpDir = Files.createTempDirectory(parent.toPath(), temp, IO.getUserPrivateFileAttribute(parent.toPath())).toFile();
}
configureTempDirectory(tmpDir, context);

Expand Down

0 comments on commit 74d1473

Please sign in to comment.