aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.ssh.apache.agent/src/org
diff options
context:
space:
mode:
authorThomas Wolf <thomas.wolf@paranor.ch>2021-12-28 18:07:21 +0100
committerThomas Wolf <thomas.wolf@paranor.ch>2022-01-30 17:13:46 +0100
commit68bd2c146239b87d355ed6169ca0ec227a69995d (patch)
tree8d6ccafef21fa2e01d9e42385f28ea38db028932 /org.eclipse.jgit.ssh.apache.agent/src/org
parente0281c5adb89f0b109abca57970c7b89df63ede4 (diff)
downloadjgit-68bd2c146239b87d355ed6169ca0ec227a69995d.tar.gz
jgit-68bd2c146239b87d355ed6169ca0ec227a69995d.zip
sshd: handle "IdentityAgent SSH_AUTH_SOCK" in ssh config
OpenSSH has (for legacy reasons?) the option of specifying the default environment variable directly, instead of using ${SSH_AUTH_SOCK}. Make sure the plain variable name is not taken as a relative path name. Bug: 577053 Change-Id: If8f550dffc43887254f71aa0b487c50fa14d0627 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
Diffstat (limited to 'org.eclipse.jgit.ssh.apache.agent/src/org')
-rw-r--r--org.eclipse.jgit.ssh.apache.agent/src/org/eclipse/jgit/internal/transport/sshd/agent/connector/Sockets.java5
-rw-r--r--org.eclipse.jgit.ssh.apache.agent/src/org/eclipse/jgit/internal/transport/sshd/agent/connector/UnixDomainSocketConnector.java9
2 files changed, 5 insertions, 9 deletions
diff --git a/org.eclipse.jgit.ssh.apache.agent/src/org/eclipse/jgit/internal/transport/sshd/agent/connector/Sockets.java b/org.eclipse.jgit.ssh.apache.agent/src/org/eclipse/jgit/internal/transport/sshd/agent/connector/Sockets.java
index 3d95bdb51c..52cf5f22f2 100644
--- a/org.eclipse.jgit.ssh.apache.agent/src/org/eclipse/jgit/internal/transport/sshd/agent/connector/Sockets.java
+++ b/org.eclipse.jgit.ssh.apache.agent/src/org/eclipse/jgit/internal/transport/sshd/agent/connector/Sockets.java
@@ -24,11 +24,6 @@ public final class Sockets {
}
/**
- * Default SSH agent socket environment variable name.
- */
- public static final String ENV_SSH_AUTH_SOCK = "SSH_AUTH_SOCK"; //$NON-NLS-1$
-
- /**
* Domain for Unix domain sockets.
*/
public static final int AF_UNIX = 1;
diff --git a/org.eclipse.jgit.ssh.apache.agent/src/org/eclipse/jgit/internal/transport/sshd/agent/connector/UnixDomainSocketConnector.java b/org.eclipse.jgit.ssh.apache.agent/src/org/eclipse/jgit/internal/transport/sshd/agent/connector/UnixDomainSocketConnector.java
index 3b75f3a7da..95ac34f940 100644
--- a/org.eclipse.jgit.ssh.apache.agent/src/org/eclipse/jgit/internal/transport/sshd/agent/connector/UnixDomainSocketConnector.java
+++ b/org.eclipse.jgit.ssh.apache.agent/src/org/eclipse/jgit/internal/transport/sshd/agent/connector/UnixDomainSocketConnector.java
@@ -11,10 +11,10 @@ package org.eclipse.jgit.internal.transport.sshd.agent.connector;
import static org.eclipse.jgit.internal.transport.sshd.agent.connector.Sockets.AF_UNIX;
import static org.eclipse.jgit.internal.transport.sshd.agent.connector.Sockets.DEFAULT_PROTOCOL;
-import static org.eclipse.jgit.internal.transport.sshd.agent.connector.Sockets.ENV_SSH_AUTH_SOCK;
import static org.eclipse.jgit.internal.transport.sshd.agent.connector.Sockets.SOCK_STREAM;
import static org.eclipse.jgit.internal.transport.sshd.agent.connector.UnixSockets.FD_CLOEXEC;
import static org.eclipse.jgit.internal.transport.sshd.agent.connector.UnixSockets.F_SETFD;
+import static org.eclipse.jgit.transport.SshConstants.ENV_SSH_AUTH_SOCKET;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -46,7 +46,7 @@ public class UnixDomainSocketConnector extends AbstractConnector {
@Override
public String getIdentityAgent() {
- return ENV_SSH_AUTH_SOCK;
+ return ENV_SSH_AUTH_SOCKET;
}
@Override
@@ -91,8 +91,9 @@ public class UnixDomainSocketConnector extends AbstractConnector {
public UnixDomainSocketConnector(String socketFile) {
super();
String file = socketFile;
- if (StringUtils.isEmptyOrNull(file)) {
- file = SystemReader.getInstance().getenv(ENV_SSH_AUTH_SOCK);
+ if (StringUtils.isEmptyOrNull(file)
+ || ENV_SSH_AUTH_SOCKET.equals(file)) {
+ file = SystemReader.getInstance().getenv(ENV_SSH_AUTH_SOCKET);
}
this.socketFile = file;
}