This is an automated email from the ASF dual-hosted git repository. remm pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/master by this push: new 39f3b06 Very basic permissions for non posix filesystems 39f3b06 is described below commit 39f3b06ae9f18d27d5f1620d34037e17394d03f3 Author: remm <r...@apache.org> AuthorDate: Tue Feb 2 14:09:00 2021 +0100 Very basic permissions for non posix filesystems --- .../org/apache/tomcat/util/net/LocalStrings.properties | 2 ++ java/org/apache/tomcat/util/net/NioEndpoint.java | 18 ++++++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/java/org/apache/tomcat/util/net/LocalStrings.properties b/java/org/apache/tomcat/util/net/LocalStrings.properties index 54dd3d9..b1e5c2a 100644 --- a/java/org/apache/tomcat/util/net/LocalStrings.properties +++ b/java/org/apache/tomcat/util/net/LocalStrings.properties @@ -98,6 +98,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 3c9515a..bc3f2ad 100644 --- a/java/org/apache/tomcat/util/net/NioEndpoint.java +++ b/java/org/apache/tomcat/util/net/NioEndpoint.java @@ -220,11 +220,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: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org