// No instantiation
}
- /**
- * 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.
*/
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;
@Override
public String getIdentityAgent() {
- return ENV_SSH_AUTH_SOCK;
+ return ENV_SSH_AUTH_SOCKET;
}
@Override
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;
}
h.getValue(SshConstants.IDENTITY_AGENT));
}
+ @Test
+ public void testIdentityAgentSshAuthSock() throws Exception {
+ config("Host orcz\nIdentityAgent SSH_AUTH_SOCK\n");
+ HostConfig h = lookup("orcz");
+ assertEquals(SshConstants.ENV_SSH_AUTH_SOCKET,
+ h.getValue(SshConstants.IDENTITY_AGENT));
+ }
+
@Test
public void testNegativeMatch() throws Exception {
config("Host foo.bar !foobar.baz *.baz\n" + "Port 29418\n");
if (options != null) {
// HOSTNAME already done above
String value = options.get(SshConstants.IDENTITY_AGENT);
- if (value != null && !SshConstants.NONE.equals(value)) {
+ if (value != null && !SshConstants.NONE.equals(value)
+ && !SshConstants.ENV_SSH_AUTH_SOCKET.equals(value)) {
value = r.substitute(value, Replacer.DEFAULT_TOKENS, true);
value = toFile(value, home).getPath();
options.put(SshConstants.IDENTITY_AGENT, value);
/*
- * Copyright (C) 2018, 2020 Thomas Wolf <thomas.wolf@paranor.ch> and others
+ * Copyright (C) 2018, 2021 Thomas Wolf <thomas.wolf@paranor.ch> and others
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Distribution License v. 1.0 which is available at
public static final String[] DEFAULT_IDENTITIES = { //
ID_RSA, ID_DSA, ID_ECDSA, ID_ED25519
};
+
+ /**
+ * Name of the environment variable holding the Unix domain socket for
+ * communication with an SSH agent.
+ *
+ * @since 6.1
+ */
+ public static final String ENV_SSH_AUTH_SOCKET = "SSH_AUTH_SOCK";
}