-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #5451 - Private Work Dir #5457
Changes from all commits
a23b01e
74d1473
3cc549c
75e6aaf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -24,8 +24,12 @@ | |||||||||||||||||||||||||||||||||
import java.net.URISyntaxException; | ||||||||||||||||||||||||||||||||||
import java.net.URL; | ||||||||||||||||||||||||||||||||||
import java.net.URLClassLoader; | ||||||||||||||||||||||||||||||||||
import java.nio.file.FileStore; | ||||||||||||||||||||||||||||||||||
import java.nio.file.Files; | ||||||||||||||||||||||||||||||||||
import java.nio.file.Path; | ||||||||||||||||||||||||||||||||||
import java.nio.file.attribute.PosixFileAttributeView; | ||||||||||||||||||||||||||||||||||
import java.nio.file.attribute.PosixFilePermission; | ||||||||||||||||||||||||||||||||||
import java.nio.file.attribute.PosixFilePermissions; | ||||||||||||||||||||||||||||||||||
import java.util.ArrayList; | ||||||||||||||||||||||||||||||||||
import java.util.Arrays; | ||||||||||||||||||||||||||||||||||
import java.util.List; | ||||||||||||||||||||||||||||||||||
|
@@ -456,7 +460,10 @@ public void resolveTempDirectory(WebAppContext context) | |||||||||||||||||||||||||||||||||
File work = new File(jettyBase, "work"); | ||||||||||||||||||||||||||||||||||
if (work.exists() && work.isDirectory() && work.canWrite()) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
context.setPersistTempDirectory(true); | ||||||||||||||||||||||||||||||||||
if (context.getServer().isWorkDirectoryPersistent()) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
context.setPersistTempDirectory(true); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
makeTempDirectory(work, context); | ||||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
|
@@ -507,8 +514,18 @@ public void makeTempDirectory(File parent, WebAppContext context) | |||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
//ensure file will always be unique by appending random digits | ||||||||||||||||||||||||||||||||||
tmpDir = Files.createTempDirectory(parent.toPath(), temp).toFile(); | ||||||||||||||||||||||||||||||||||
Path parentPath = parent.toPath(); | ||||||||||||||||||||||||||||||||||
FileStore fileStore = Files.getFileStore(parentPath); | ||||||||||||||||||||||||||||||||||
if (fileStore.supportsFileAttributeView(PosixFileAttributeView.class)) | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
String workDirPerms = context.getTempDirectoryPosixPermissions(); | ||||||||||||||||||||||||||||||||||
Set<PosixFilePermission> permSet = PosixFilePermissions.fromString(workDirPerms); | ||||||||||||||||||||||||||||||||||
tmpDir = Files.createTempDirectory(parentPath, temp, PosixFilePermissions.asFileAttribute(permSet)).toFile(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
Comment on lines
+519
to
+524
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure we need to create a lot of new API for this. Can we just do it with attributes: context, server then system
Suggested change
We've changed tmp dir stuff a number of times... once a thing is said in API it is forever! So I think we just lean towards to loose attributes rather than API. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the String you see for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The biggest issue with attributes is making them friendly for start modules. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, where does There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I know this is closed, but will answer so record my thoughts. I see these attributes as hints to the implementation, so the string should be "org.eclipse.jetty.webapp.WebInfConfiguration.TEMP_DIRECTORY_POSIX_PERMISSIONS" and defined as a constant in WebInfConfiguration. It is easy to make friendly for start modules, because we write the XML for those modules, thus we write the XML like: <Call name="setAttribute">
<Arg>org.eclipse.jetty.webapp.WebInfConfiguration.TEMP_DIRECTORY_POSIX_PERMISSIONS</arg>
<Arg><Property name="jetty.webapp.tmpDirPosixPermissions"/></Arg>
</Call> and then we just add to the ini-template of
Ultimately, this is no different at the start module level than if we had dedicated APIs |
||||||||||||||||||||||||||||||||||
else | ||||||||||||||||||||||||||||||||||
{ | ||||||||||||||||||||||||||||||||||
tmpDir = Files.createTempDirectory(parentPath, temp).toFile(); | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||||
configureTempDirectory(tmpDir, context); | ||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should also do this with an attribute so we don't commit to a forever API: