You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2020/02/09 14:34:55 UTC
[commons-vfs] branch master updated: [SFTP] Configure whether exec
detection is enabled (#80)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-vfs.git
The following commit(s) were added to refs/heads/master by this push:
new 6d20129 [SFTP] Configure whether exec detection is enabled (#80)
6d20129 is described below
commit 6d20129e5f8ee658147d15a9e98a1e3974ba7150
Author: ddg-igh <dd...@users.noreply.github.com>
AuthorDate: Sun Feb 9 15:34:49 2020 +0100
[SFTP] Configure whether exec detection is enabled (#80)
* sftp add possibility to configure if detection of exec channel is disabled
* sftp apply disable detect exec channel
* Update SftpFileSystem.java
---
.../commons/vfs2/provider/sftp/SftpFileSystem.java | 7 +++++-
.../provider/sftp/SftpFileSystemConfigBuilder.java | 28 ++++++++++++++++++++++
2 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java
index 104ebc8..f5974e9 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystem.java
@@ -91,7 +91,12 @@ public class SftpFileSystem extends AbstractFileSystem {
this.session = Objects.requireNonNull(session, "session");
this.connectTimeoutMillis = SftpFileSystemConfigBuilder.getInstance()
.getConnectTimeoutMillis(fileSystemOptions);
- this.execDisabled = detectExecDisabled();
+
+ if (SftpFileSystemConfigBuilder.getInstance().isDisableDetectExecChannel(fileSystemOptions)) {
+ this.execDisabled = true;
+ } else {
+ this.execDisabled = detectExecDisabled();
+ }
}
@Override
diff --git a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java
index 98362e1..45120a1 100644
--- a/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java
+++ b/commons-vfs2/src/main/java/org/apache/commons/vfs2/provider/sftp/SftpFileSystemConfigBuilder.java
@@ -105,6 +105,7 @@ public final class SftpFileSystemConfigBuilder extends FileSystemConfigBuilder {
private static final String PROXY_OPTIONS = _PREFIX + ".PROXY_OPTIONS";
private static final String PROXY_PASSWORD = _PREFIX + ".PROXY_PASSWORD";
private static final String PROXY_PORT = _PREFIX + ".PROXY_PORT";
+ private static final String DISABLE_DETECT_EXEC_CHANEL = _PREFIX + ".DISABLE_DETECT_EXEC_CHANEL";
/** HTTP Proxy. */
public static final ProxyType PROXY_HTTP = new ProxyType("http");
@@ -258,6 +259,21 @@ public final class SftpFileSystemConfigBuilder extends FileSystemConfigBuilder {
}
/**
+ * Returns {@link true} if the detection of the exec channel should be disabled.
+ * Returns {@link false} if the detection of the exec channel should be enabled.
+ * Defaults to {@code false} if the method {@link #setDisableDetectExecChannel(FileSystemOptions, boolean)} has not been invoked.
+ *
+ * @param opts The FileSystemOptions.
+ * @return {@code true} if detection of exec channel should be disabled.
+ *
+ * @see #setDisableDetectExecChannel(FileSystemOptions, boolean)
+ */
+ public boolean isDisableDetectExecChannel(final FileSystemOptions opts) {
+ return this.getBoolean(opts, DISABLE_DETECT_EXEC_CHANEL, Boolean.FALSE);
+ }
+
+
+ /**
* Returns {@link Boolean#TRUE} if VFS should load the OpenSSH config. Defaults to {@code Boolean.FALSE} if the
* method {@link #setLoadOpenSSHConfig(FileSystemOptions, boolean)} has not been invoked.
*
@@ -763,4 +779,16 @@ public final class SftpFileSystemConfigBuilder extends FileSystemConfigBuilder {
public void setLoadOpenSSHConfig(final FileSystemOptions opts, final boolean loadOpenSSHConfig) {
this.setParam(opts, LOAD_OPENSSH_CONFIG, loadOpenSSHConfig ? Boolean.TRUE : Boolean.FALSE);
}
+
+ /**
+ * Sets whether detection of exec channel is disabled.
+ * If this value is true the FileSystem will not test if the server allows to exec commands and disable the use of the exec channel.
+ *
+ * @param opts The FileSystem options.
+ * @param disableDetectExecChannel true if the detection of exec channel should be disabled.
+ */
+ public void setDisableDetectExecChannel(final FileSystemOptions opts, final boolean disableDetectExecChannel) {
+ this.setParam(opts, DISABLE_DETECT_EXEC_CHANEL, disableDetectExecChannel ? Boolean.TRUE : Boolean.FALSE);
+ }
+
}