diff --git a/WORKSPACE b/WORKSPACE index 66bdd67cb..0eabeccbc 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -22,6 +22,12 @@ load( "maven_jar", ) +maven_jar( + name = "eddsa", + artifact = "net.i2p.crypto:eddsa:0.3.0", + sha1 = "1901c8d4d8bffb7d79027686cfb91e704217c3e1", +) + maven_jar( name = "jsch", artifact = "com.jcraft:jsch:0.1.54", diff --git a/lib/BUILD b/lib/BUILD index 4803466ec..0c5c22426 100644 --- a/lib/BUILD +++ b/lib/BUILD @@ -27,6 +27,15 @@ java_library( exports = ["@commons-logging//jar"], ) +java_library( + name = "eddsa", + visibility = [ + "//org.eclipse.jgit.ssh.apache:__pkg__", + "//org.eclipse.jgit.ssh.apache.test:__pkg__", + ], + exports = ["@eddsa//jar"], +) + java_library( name = "gson", visibility = [ @@ -163,9 +172,9 @@ java_library( testonly = 1, visibility = ["//visibility:public"], exports = [ - "@mockito//jar", "@byte_buddy//jar", "@byte_buddy_agent//jar", + "@mockito//jar", "@objenesis//jar", ], ) diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.ssh.apache.feature/feature.xml b/org.eclipse.jgit.packaging/org.eclipse.jgit.ssh.apache.feature/feature.xml index b80ff3799..2f15de18a 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.ssh.apache.feature/feature.xml +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.ssh.apache.feature/feature.xml @@ -47,4 +47,11 @@ version="0.0.0" unpack="false"/> + + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.target index dfc5438c2..59b66b040 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.target @@ -1,7 +1,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.tpd index 7fbc58a7f..0693be4ac 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.10-staging.tpd @@ -1,7 +1,7 @@ target "jgit-4.9-staging" with source configurePhase include "projects/jetty-9.4.11.tpd" -include "orbit/I20181128011035-2018-12.tpd" +include "orbit/S20181128170323-2018-12.tpd" location "http://download.eclipse.org/staging/2018-12/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target index 6b1b08f7b..8705ad0d9 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.target @@ -1,7 +1,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd index be40b3956..44c5f0a44 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.5.tpd @@ -1,7 +1,7 @@ target "jgit-4.5" with source configurePhase include "projects/jetty-9.4.11.tpd" -include "orbit/I20181128011035-2018-12.tpd" +include "orbit/S20181128170323-2018-12.tpd" location "http://download.eclipse.org/releases/mars/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target index ffc0d3781..94f1ceb00 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.target @@ -1,7 +1,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd index 559822ab0..d286e35cc 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.6.tpd @@ -1,7 +1,7 @@ target "jgit-4.6" with source configurePhase include "projects/jetty-9.4.11.tpd" -include "orbit/I20181128011035-2018-12.tpd" +include "orbit/S20181128170323-2018-12.tpd" location "http://download.eclipse.org/releases/neon/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target index 92b6b5f05..505ea25d4 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.target @@ -1,7 +1,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd index ecce9c405..173051fde 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.7.tpd @@ -1,7 +1,7 @@ target "jgit-4.7" with source configurePhase include "projects/jetty-9.4.11.tpd" -include "orbit/I20181128011035-2018-12.tpd" +include "orbit/S20181128170323-2018-12.tpd" location "http://download.eclipse.org/releases/oxygen/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target index 90058881d..d162a99ee 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.target @@ -1,7 +1,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd index cdac3c53e..a9a21a248 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.8.tpd @@ -1,7 +1,7 @@ target "jgit-4.8" with source configurePhase include "projects/jetty-9.4.11.tpd" -include "orbit/I20181128011035-2018-12.tpd" +include "orbit/S20181128170323-2018-12.tpd" location "http://download.eclipse.org/releases/photon/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target index da23d0459..474284747 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.target @@ -1,7 +1,7 @@ - + @@ -76,7 +76,7 @@ - + diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd index c51619cf3..3deaacf3d 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/jgit-4.9.tpd @@ -1,7 +1,7 @@ target "jgit-4.9" with source configurePhase include "projects/jetty-9.4.11.tpd" -include "orbit/I20181128011035-2018-12.tpd" +include "orbit/S20181128170323-2018-12.tpd" location "http://download.eclipse.org/releases/2018-09/" { org.eclipse.osgi lazy diff --git a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/I20181128011035-2018-12.tpd b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20181128170323-2018-12.tpd similarity index 97% rename from org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/I20181128011035-2018-12.tpd rename to org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20181128170323-2018-12.tpd index 8347d1233..fc89c2783 100644 --- a/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/I20181128011035-2018-12.tpd +++ b/org.eclipse.jgit.packaging/org.eclipse.jgit.target/orbit/S20181128170323-2018-12.tpd @@ -1,7 +1,7 @@ -target "I20181128011035-2018-12" with source configurePhase +target "S20181128170323-2018-12" with source configurePhase // see http://download.eclipse.org/tools/orbit/downloads/ -location "http://download.eclipse.org/tools/orbit/downloads/drops/I20181128011035/repository" { +location "http://download.eclipse.org/tools/orbit/downloads/drops/S20181128170323/repository" { org.apache.ant [1.10.5.v20180808-0324,1.10.5.v20180808-0324] org.apache.ant.source [1.10.5.v20180808-0324,1.10.5.v20180808-0324] org.apache.commons.codec [1.10.0.v20180409-1845,1.10.0.v20180409-1845] diff --git a/org.eclipse.jgit.ssh.apache.test/BUILD b/org.eclipse.jgit.ssh.apache.test/BUILD index 3742aff06..a13cf0b30 100644 --- a/org.eclipse.jgit.ssh.apache.test/BUILD +++ b/org.eclipse.jgit.ssh.apache.test/BUILD @@ -8,6 +8,7 @@ junit_tests( srcs = glob(["tst/**/*.java"]), tags = ["sshd"], deps = [ + "//lib:eddsa", "//lib:junit", "//lib:sshd-core", "//lib:sshd-sftp", diff --git a/org.eclipse.jgit.ssh.apache.test/META-INF/MANIFEST.MF b/org.eclipse.jgit.ssh.apache.test/META-INF/MANIFEST.MF index 38dc19067..b87ef7cff 100644 --- a/org.eclipse.jgit.ssh.apache.test/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.ssh.apache.test/META-INF/MANIFEST.MF @@ -8,6 +8,7 @@ Bundle-Vendor: %Provider-Name Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Import-Package: org.eclipse.jgit.internal.transport.sshd.proxy;version="[5.2.0,5.3.0)", org.eclipse.jgit.junit;version="[5.2.0,5.3.0)", + org.eclipse.jgit.junit.ssh;version="[5.2.0,5.3.0)", org.eclipse.jgit.lib;version="[5.2.0,5.3.0)", org.eclipse.jgit.transport;version="[5.2.0,5.3.0)", org.eclipse.jgit.transport.ssh;version="[5.2.0,5.3.0)", diff --git a/org.eclipse.jgit.ssh.apache.test/tst/org/eclipse/jgit/transport/sshd/ApacheSshTest.java b/org.eclipse.jgit.ssh.apache.test/tst/org/eclipse/jgit/transport/sshd/ApacheSshTest.java index 69a9165aa..ee58083a5 100644 --- a/org.eclipse.jgit.ssh.apache.test/tst/org/eclipse/jgit/transport/sshd/ApacheSshTest.java +++ b/org.eclipse.jgit.ssh.apache.test/tst/org/eclipse/jgit/transport/sshd/ApacheSshTest.java @@ -53,6 +53,7 @@ import org.eclipse.jgit.transport.SshSessionFactory; import org.eclipse.jgit.transport.ssh.SshTestBase; import org.eclipse.jgit.transport.sshd.SshdSessionFactory; import org.eclipse.jgit.util.FS; +import org.junit.Test; import org.junit.experimental.theories.Theories; import org.junit.runner.RunWith; @@ -81,4 +82,24 @@ public class ApacheSshTest extends SshTestBase { } } + // Using an ed25519 (unencrypted) user key is tested in the super class in + // testSshKeys(). sshd 2.0.0 cannot yet read encrypted ed25519 keys. + + @Test + public void testEd25519HostKey() throws Exception { + File newHostKey = new File(getTemporaryDirectory(), "newhostkey"); + copyTestResource("id_ed25519", newHostKey); + server.addHostKey(newHostKey.toPath(), true); + File newHostKeyPub = new File(getTemporaryDirectory(), + "newhostkey.pub"); + copyTestResource("id_ed25519.pub", newHostKeyPub); + createKnownHostsFile(knownHosts, "localhost", testPort, newHostKeyPub); + cloneWith("ssh://git/doesntmatter", defaultCloneDir, null, // + "Host git", // + "HostName localhost", // + "Port " + testPort, // + "User " + TEST_USER, // + "IdentityFile " + privateKey1.getAbsolutePath()); + } + } diff --git a/org.eclipse.jgit.ssh.apache/BUILD b/org.eclipse.jgit.ssh.apache/BUILD index d6a145381..a1a6c8e24 100644 --- a/org.eclipse.jgit.ssh.apache/BUILD +++ b/org.eclipse.jgit.ssh.apache/BUILD @@ -10,6 +10,7 @@ java_library( resource_strip_prefix = "org.eclipse.jgit.ssh.apache/resources", resources = RESOURCES, deps = [ + "//lib:eddsa", "//lib:slf4j-api", "//lib:sshd-core", "//lib:sshd-sftp", diff --git a/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF b/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF index e5d66536f..124651815 100644 --- a/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.ssh.apache/META-INF/MANIFEST.MF @@ -31,7 +31,8 @@ Export-Package: org.eclipse.jgit.internal.transport.sshd;version="5.2.0";x-inter org.eclipse.jgit.util, org.apache.sshd.client.session, org.apache.sshd.client.keyverifier" -Import-Package: org.apache.sshd.agent;version="[2.0.0,2.1.0)", +Import-Package: net.i2p.crypto.eddsa;version="[0.3.0,0.4.0)", + org.apache.sshd.agent;version="[2.0.0,2.1.0)", org.apache.sshd.client;version="[2.0.0,2.1.0)", org.apache.sshd.client.auth;version="[2.0.0,2.1.0)", org.apache.sshd.client.auth.keyboard;version="[2.0.0,2.1.0)", diff --git a/org.eclipse.jgit.ssh.apache/pom.xml b/org.eclipse.jgit.ssh.apache/pom.xml index f9100855e..366c393e4 100644 --- a/org.eclipse.jgit.ssh.apache/pom.xml +++ b/org.eclipse.jgit.ssh.apache/pom.xml @@ -63,6 +63,7 @@ ${project.build.directory}/META-INF/SOURCE-MANIFEST.MF + 0.3.0 @@ -84,6 +85,12 @@ ${apache-sshd-version} + + net.i2p.crypto + eddsa + ${eddsa-version} + + org.slf4j slf4j-api diff --git a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java index 92a2fbd27..dde55b6d7 100644 --- a/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java +++ b/org.eclipse.jgit.test/src/org/eclipse/jgit/transport/ssh/SshTestBase.java @@ -80,6 +80,7 @@ public abstract class SshTestBase extends SshTestHarness { "id_ecdsa_256", // "id_ecdsa_384", // "id_ecdsa_521", // + "id_ed25519", // // And now encrypted. Passphrase is "testpass". "id_dsa_testpass", // "id_rsa_1024_testpass", // @@ -805,7 +806,8 @@ public abstract class SshTestBase extends SshTestHarness { // JSch fails on ECDSA 384/521 keys. Compare // https://sourceforge.net/p/jsch/patches/10/ assumeTrue(!(getSessionFactory() instanceof JschConfigSessionFactory - && (keyName.startsWith("id_ecdsa_384") + && (keyName.contains("ed25519") + || keyName.startsWith("id_ecdsa_384") || keyName.startsWith("id_ecdsa_521")))); File cloned = new File(getTemporaryDirectory(), "cloned"); String keyFileName = keyName + "_key"; diff --git a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java index e34c3cebd..e5fcbf9d7 100644 --- a/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java +++ b/org.eclipse.jgit.test/tst/org/eclipse/jgit/util/HookTest.java @@ -199,7 +199,8 @@ public class HookTest extends RepositoryTestCase { assumeSupportedPlatform(); writeHookFile(PreCommitHook.NAME, - "#!/bin/sh\necho \"test $1 $2\"\nread INPUT\necho $INPUT\necho 1>&2 \"stderr\""); + "#!/bin/sh\necho \"test $1 $2\"\nread INPUT\necho $INPUT\n" + + "echo $GIT_DIR\necho $GIT_WORK_TREE\necho 1>&2 \"stderr\""); ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream(); ProcessResult res = FS.DETECTED.runHookIfPresent(db, @@ -208,7 +209,9 @@ public class HookTest extends RepositoryTestCase { "arg1", "arg2" }, new PrintStream(out), new PrintStream(err), "stdin"); - assertEquals("unexpected hook output", "test arg1 arg2\nstdin\n", + assertEquals("unexpected hook output", + "test arg1 arg2\nstdin\n" + db.getDirectory().getAbsolutePath() + + '\n' + db.getWorkTree().getAbsolutePath() + '\n', out.toString("UTF-8")); assertEquals("unexpected output on stderr stream", "stderr\n", err.toString("UTF-8")); diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshConstants.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshConstants.java index fd6301bb4..2b79d7105 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshConstants.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/SshConstants.java @@ -197,6 +197,6 @@ public final class SshConstants { /** All known default identity file names. */ public static final String[] DEFAULT_IDENTITIES = { // - ID_RSA, ID_DSA, ID_ECDSA // , ID_ED25519 // not yet... + ID_RSA, ID_DSA, ID_ECDSA, ID_ED25519 }; } diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java index 7f0308f07..e864ba76c 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/FS.java @@ -1110,6 +1110,13 @@ public abstract class FS { hookPath); ProcessBuilder hookProcess = runInShell(cmd, args); hookProcess.directory(runDirectory); + Map environment = hookProcess.environment(); + environment.put(Constants.GIT_DIR_KEY, + repository.getDirectory().getAbsolutePath()); + if (!repository.isBare()) { + environment.put(Constants.GIT_WORK_TREE_KEY, + repository.getWorkTree().getAbsolutePath()); + } try { return new ProcessResult(runProcess(hookProcess, outRedirect, errRedirect, stdinArgs), Status.OK);