From 06b5216bb35720f53f6b4428b5687a845b77c840 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20N=C3=BCssgens?= Date: Wed, 20 Apr 2022 09:51:09 +0200 Subject: [PATCH] enable root to tail (all) files via sftp #607 --- .../pl/otros/vfs/browser/util/VFSUtils.java | 66 ++++++++++++------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/olv-vfs/src/main/java/pl/otros/vfs/browser/util/VFSUtils.java b/olv-vfs/src/main/java/pl/otros/vfs/browser/util/VFSUtils.java index d30f175f..83b793d8 100644 --- a/olv-vfs/src/main/java/pl/otros/vfs/browser/util/VFSUtils.java +++ b/olv-vfs/src/main/java/pl/otros/vfs/browser/util/VFSUtils.java @@ -15,15 +15,38 @@ */ package pl.otros.vfs.browser.util; -import com.google.common.base.Joiner; -import com.google.common.base.Throwables; -import com.jcraft.jsch.JSchException; -import jcifs.smb.SmbAuthException; -import net.sf.vfsjfilechooser.utils.VFSURIParser; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.time.Duration; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Map; +import java.util.Optional; +import java.util.Set; +import java.util.concurrent.locks.ReadWriteLock; +import java.util.concurrent.locks.ReentrantReadWriteLock; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import javax.swing.Icon; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang.StringUtils; -import org.apache.commons.vfs2.*; +import org.apache.commons.vfs2.CacheStrategy; +import org.apache.commons.vfs2.FileContent; +import org.apache.commons.vfs2.FileName; +import org.apache.commons.vfs2.FileObject; +import org.apache.commons.vfs2.FileSystemException; +import org.apache.commons.vfs2.FileSystemManager; +import org.apache.commons.vfs2.FileSystemOptions; +import org.apache.commons.vfs2.FileType; +import org.apache.commons.vfs2.UserAuthenticationData; import org.apache.commons.vfs2.UserAuthenticationData.Type; import org.apache.commons.vfs2.impl.DefaultFileSystemConfigBuilder; import org.apache.commons.vfs2.impl.StandardFileSystemManager; @@ -33,26 +56,22 @@ import org.apache.commons.vfs2.provider.sftp.SftpFileSystemConfigBuilder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import com.google.common.base.Joiner; +import com.google.common.base.Throwables; +import com.jcraft.jsch.JSchException; +import jcifs.smb.SmbAuthException; +import net.sf.vfsjfilechooser.utils.VFSURIParser; import pl.otros.vfs.browser.Icons; import pl.otros.vfs.browser.LinkFileObject; import pl.otros.vfs.browser.TaskContext; -import pl.otros.vfs.browser.auth.*; - -import javax.swing.*; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.time.Duration; -import java.util.*; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; -import java.util.regex.Matcher; -import java.util.regex.Pattern; +import pl.otros.vfs.browser.auth.AuthStore; +import pl.otros.vfs.browser.auth.AuthStoreUtils; +import pl.otros.vfs.browser.auth.MemoryAuthStore; +import pl.otros.vfs.browser.auth.OtrosUserAuthenticator; +import pl.otros.vfs.browser.auth.StaticPasswordProvider; +import pl.otros.vfs.browser.auth.UserAuthenticationDataWrapper; +import pl.otros.vfs.browser.auth.UserAuthenticationInfo; +import pl.otros.vfs.browser.auth.UserAuthenticatorFactory; /** * A helper class to deal with commons-vfs file abstractions @@ -336,6 +355,7 @@ public static FileObject resolveFileObject(String filePath, FileSystemOptions op builder.setUserDirIsRoot(opts, false); builder.setCompression(opts, "zlib,none"); builder.setSessionTimeout(opts, Duration.ofSeconds(5)); + builder.setDisableDetectExecChannel(opts, true); // see https://issues.apache.org/jira/browse/VFS-818 } DefaultFileSystemConfigBuilder.getInstance().setUserAuthenticator(options, authenticator);