This is an automated email from the ASF dual-hosted git repository.
remm pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new ec5ec91 Very basic permissions for non posix filesystems
ec5ec91 is described below
commit ec5ec916741efe3a5046a9851a96347a34f230ee
Author: remm <[email protected]>
AuthorDate: Tue Feb 2 14:13:35 2021 +0100
Very basic permissions for non posix filesystems
---
java/org/apache/tomcat/util/net/LocalStrings.properties | 2 ++
java/org/apache/tomcat/util/net/NioEndpoint.java | 17 ++++++++++++++---
2 files changed, 16 insertions(+), 3 deletions(-)
diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties
b/java/org/apache/tomcat/util/net/LocalStrings.properties
index bcf697c..76625b0 100644
--- a/java/org/apache/tomcat/util/net/LocalStrings.properties
+++ b/java/org/apache/tomcat/util/net/LocalStrings.properties
@@ -97,6 +97,8 @@ endpoint.nio.keyProcessingError=Error processing selection key
endpoint.nio.latchMustBeZero=Latch must be at count zero or null
endpoint.nio.nullLatch=Latch cannot be null
endpoint.nio.nullSocketChannel=Invalid null socket channel while processing
poller event
+endpoint.nio.perms.readFail=Failed to set read permissions for Unix domain
socket [{0}]
+endpoint.nio.perms.writeFail=Failed to set write permissions for Unix domain
socket [{0}]
endpoint.nio.pollerEventError=Error processing poller event
endpoint.nio.registerFail=Failed to register socket with selector from poller
endpoint.nio.selectorCloseFail=Failed to close selector when closing the poller
diff --git a/java/org/apache/tomcat/util/net/NioEndpoint.java
b/java/org/apache/tomcat/util/net/NioEndpoint.java
index a748819..bc552f4 100644
--- a/java/org/apache/tomcat/util/net/NioEndpoint.java
+++ b/java/org/apache/tomcat/util/net/NioEndpoint.java
@@ -277,10 +277,21 @@ public class NioEndpoint extends
AbstractJsseEndpoint<NioChannel,SocketChannel>
serverSock =
JreCompat.getInstance().openUnixDomainServerSocketChannel();
serverSock.bind(sa, getAcceptCount());
if (getUnixDomainSocketPathPermissions() != null) {
- FileAttribute<Set<PosixFilePermission>> attrs =
-
PosixFilePermissions.asFileAttribute(PosixFilePermissions.fromString(getUnixDomainSocketPathPermissions()));
Path path = Paths.get(getUnixDomainSocketPath());
- Files.setAttribute(path, attrs.name(), attrs.value());
+ Set<PosixFilePermission> permissions =
+
PosixFilePermissions.fromString(getUnixDomainSocketPathPermissions());
+ if
(path.getFileSystem().supportedFileAttributeViews().contains("posix")) {
+ FileAttribute<Set<PosixFilePermission>> attrs =
PosixFilePermissions.asFileAttribute(permissions);
+ Files.setAttribute(path, attrs.name(), attrs.value());
+ } else {
+ java.io.File file =
Paths.get(getUnixDomainSocketPath()).toFile();
+ if (permissions.contains(PosixFilePermission.OTHERS_READ)
&& !file.setReadable(true, false)) {
+ log.warn(sm.getString("endpoint.nio.perms.readFail",
path));
+ }
+ if (permissions.contains(PosixFilePermission.OTHERS_WRITE)
&& !file.setWritable(true, false)) {
+ log.warn(sm.getString("endpoint.nio.perms.writeFail",
path));
+ }
+ }
}
} else {
serverSock = ServerSocketChannel.open();
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]