aboutsummaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.ssh.jsch.test/tst/org/eclipse/jgit
Commit message (Collapse)AuthorAgeFilesLines
* JSchSshProtocol2Test: remove unnecessary castMatthias Sohn2024-10-011-2/+2
| | | | Change-Id: Id3767f43cbbfd0c05f9a7f0d5620943da874df92
* OpenSshConfigFile: line comments and quoted stringsThomas Wolf2021-11-151-2/+2
| | | | | | | | | | | Bring our SSH config parser up-to-date with respect to changes in OpenSSH. In particular, they fixed[1] the handling of line comments such that #-characters inside strings are not considered. This means that we have to parse strings with escaped quotes correctly. [1] https://bugzilla.mindrot.org/show_bug.cgi?id=3288 Change-Id: Ifbd9014127e8d51e7c8792e237f3fc2a9a0719d2 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* JSch: fix service publication for ServiceLoaderThomas Wolf2021-10-191-0/+24
| | | | | | | | | | | | The file name in META-INF/services must be the fully qualified interface name; the content the fully qualified implementation class name. This was broken in commit 9683bc71. Add a test for the default factory being found by the ServiceLoader. Change-Id: I1f180d7f60e5c1e74a39bbd9a5f0099bd8343e21 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Fix split package in bundle org.eclipse.jgit.ssh.jschMatthias Sohn2021-09-294-9/+17
| | | | | | | | The package org.eclipse.jgit.transport was split between org.eclipse.jgit and org.eclipse.jgit.ssh.jsch. Bug: 564544 Change-Id: I91d38e67c65ed97a880f8dc8f9559663b9eec33b
* SSH config: fix whitespace handlingThomas Wolf2021-05-171-0/+17
| | | | | | | Use Character.isWhitespace() instead of Character.isSpaceChar() to treat TABs as whitespace, too. Change-Id: Iffc59c13357d981ede6a1e0feb6ea6ff03fb3064 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* SSH config: fix negated patternsThomas Wolf2021-05-171-1/+56
| | | | | | | | | | | | | | | | | Negated patterns were handled wrongly. According to the OpenBSD ssh_config man page,[1] a negated pattern never matches. Negated patterns make only sense if there are positive patterns; the negated pattern then can define exceptions for the positive patterns. OpenSshConfigFile did this wrongly. It handled "!foo" as "matching everything but foo", but actually the semantics is "if the input is "foo", this entry doesn't apply. If the input is anything else, other patterns determine whether the entry may apply.". [1] https://man.openbsd.org/ssh_config Change-Id: I50f6e46581b7ece4c949eddf62f4a265573ec29e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* ssh config: do environment variable replacementThomas Wolf2021-04-011-0/+20
| | | | | | | | | OpenSSH 8.4 has introduced simple environment variable substitution for some keys. Implement that feature in our ssh config file parser, too. Bug: 572103 Change-Id: I360f2c5510eea4ec3329aeedf3d29dfefc9163f0 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* sshd: modernize ssh config file parsingThomas Wolf2021-03-191-0/+30
| | | | | | | | | | | | | OpenSSH has changed some things in ssh config files. Update our parser to implement some of these changes: * ignore trailing comments on a line * rename PubkeyAcceptedKeyTypes to PubkeyAcceptedAlgorithms Note that for the rename, openSSH still accepts both names. We do the same, translating names whenever we get or set values. Change-Id: Icccca060e6a4350a7acf05ff9e260f2c8c60ee1a Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Client-side protocol V2 support for fetchingThomas Wolf2021-01-011-0/+92
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make all transports request protocol V2 when fetching. Depending on the transport, set the GIT_PROTOCOL environment variable (file and ssh), pass the Git-Protocol header (http), or set the hidden "\0version=2\0" (git anon). We'll fall back to V0 if the server doesn't reply with a version 2 answer. A user can control which protocol the client requests via the git config protocol.version; if not set, JGit requests protocol V2 for fetching. Pushing always uses protocol V0 still. In the API, there is only a new Transport.openFetch() version that takes a collection of RefSpecs plus additional patterns to construct the Ref prefixes for the "ls-refs" command in protocol V2. If none are given, the server will still advertise all refs, even in protocol V2. BasePackConnection.readAdvertisedRefs() handles falling back to protocol V0. It newly returns true if V0 was used and the advertised refs were read, and false if V2 is used and an explicit "ls-refs" is needed. (This can't be done transparently inside readAdvertisedRefs() because a "stateless RPC" transport like TransportHttp may need to open a new connection for writing.) BasePackFetchConnection implements the changes needed for the protocol V2 "fetch" command (stateless protocol, simplified ACK handling, delimiters, section headers). In TransportHttp, change readSmartHeaders() to also recognize the "version 2" packet line as a valid smart server indication. Adapt tests, and run all the HTTP tests not only with both HTTP connection factories (JDK and Apache HttpClient) but also with both protocol V0 and V2. The SSH tests are much slower and much more focused on the SSH protocol and SSH key handling. Factor out two very simple cloning and pulling tests and make those run with protocol V2. Bug: 553083 Change-Id: I357c7f5daa7efb2872f1c64ee6f6d54229031ae1 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Revert "Client-side protocol V2 support for fetching"Thomas Wolf2020-11-031-26/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f802f06e7fd5a98f256b7b7727598491f563bf2f. I had misunderstood how protocol V2 works. This implementation only works if the negotiation during fetch is done in one round. Fixing this is substantial work in BasePackFetchConnection. Basically I think I'd have to change back negotiate to the V0 version, and have a doFetch() that does if protocol V2 doFetchV2() else doFetchV0() with doFetchV0 the old code, and doFetchV2 completely new. Plus there would need to be a HTTP test case requiring several negotiation rounds. This is a couple of days work at least, and I don't know when I will have the time to revisit this. So although the rest of the code is fine I prefer to back this out completely and not leave a only half working implementation in the code for an indeterminate time. Bug: 553083 Change-Id: Icbbbb09882b3b83f9897deac4a06d5f8dc99d84e Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch>
* Client-side protocol V2 support for fetchingThomas Wolf2020-10-291-0/+26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Make all transports request protocol V2 when fetching. Depending on the transport, set the GIT_PROTOCOL environment variable (file and ssh), pass the Git-Protocol header (http), or set the hidden "\0version=2\0" (git anon). We'll fall back to V0 if the server doesn't reply with a version 2 answer. A user can control which protocol the client requests via the git config protocol.version; if not set, JGit requests protocol V2 for fetching. Pushing always uses protocol V0 still. In the API, there is only a new Transport.openFetch() version that takes a collection of RefSpecs plus additional patterns to construct the Ref prefixes for the "ls-refs" command in protocol V2. If none are given, the server will still advertise all refs, even in protocol V2. BasePackConnection.readAdvertisedRefs() handles falling back to protocol V0. It newly returns true if V0 was used and the advertised refs were read, and false if V2 is used and an explicit "ls-refs" is needed. (This can't be done transparently inside readAdvertisedRefs() because a "stateless RPC" transport like TransportHttp may need to open a new connection for writing.) BasePackFetchConnection implements the changes needed for the protocol V2 "fetch" command (simplified ACK handling, delimiters, section headers). In TransportHttp, change readSmartHeaders() to also recognize the "version 2" packet line as a valid smart server indication. Adapt tests, and run all the HTTP tests not only with both HTTP connection factories (JDK and Apache HttpClient) but also with both protocol V0 and V2. Do the same for the SSH transport tests. Bug: 553083 Change-Id: Ice9866aa78020f5ca8f397cde84dc224bf5d41b4 Signed-off-by: Thomas Wolf <thomas.wolf@paranor.ch> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
* Decouple JSch from JGit CoreMatthias Sohn2020-06-013-0/+818
Motivation: JSch serves as 'default' implementations of the SSH transport. If a client application does not use it then there is no need to pull in this dependency. Move the classes depending on JSch to an OSGi fragment extending the org.eclipse.jgit bundle and keep them in the same package as before since moving them to another package would break API. Defer moving them to a separate package to the next major release. Add a new feature org.eclipse.jgit.ssh.jsch feature to enable installation. With that users can now decide which of the ssh client integrations (JCraft JSch or Apache Mina SSHD) they want to install. We will remove the JCraft JSch integration in a later step due to the reasons discussed in bug 520927. Bug: 553625 Change-Id: I5979c8a9dbbe878a2e8ac0fbfde7230059d74dc2 Also-by: Michael Dardis <git@md-5.net> Signed-off-by: Michael Dardis <git@md-5.net> Signed-off-by: Matthias Sohn <matthias.sohn@sap.com> Signed-off-by: David Ostrovsky <david@ostrovsky.org>