Skip to content

Commit f755cc7

Browse files
committed
Merge branch 'release/0.4.4'
2 parents d35577e + 4b48ce3 commit f755cc7

File tree

6 files changed

+27
-16
lines changed

6 files changed

+27
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ A: Probably a disk full, or permission error.
133133
Via [clojars](http://clojars.org) and
134134
[Leiningen](http://github.com/technomancy/leiningen).
135135

136-
:dependencies [clj-ssh "0.4.3"]
136+
:dependencies [clj-ssh "0.4.4"]
137137

138138
or your favourite maven repository aware tool.
139139

ReleaseNotes.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
# Release Notes
22

3-
Current release is 0.4.3
3+
Current release is 0.4.4
4+
5+
## 0.4.4
6+
7+
- Make ssh key test more robust
8+
The add-identity-test ssh-agent case was failing for no apparent reason.
9+
10+
- Remove some reflection warnings
411

512
## 0.4.3
613

project.clj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
(defproject clj-ssh "0.4.3"
1+
(defproject clj-ssh "0.4.4"
22
:description "Library for using SSH from clojure."
33
:url "https://github.com/hugoduncan/clj-ssh"
44
:license {:name "Eclipse Public License"

src/clj_ssh/keychain.clj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@
2525
(format "%s" path)
2626
"-g")]
2727
(when (zero? (result :exit))
28-
(when-let [pw (second (re-find #"password: \"(.*)\"" (result :err)))]
28+
(when-let [^String pw (second
29+
(re-find #"password: \"(.*)\"" (result :err)))]
2930
(.getBytes pw "UTF-8")))))
3031

3132
(defn passphrase

src/clj_ssh/ssh.clj

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,10 @@
9393
;;; Agent
9494
(defn ssh-agent
9595
"Create a ssh-agent. By default a system ssh-agent is preferred."
96-
[{:keys [use-system-ssh-agent known-hosts-path]
96+
[{:keys [use-system-ssh-agent ^String known-hosts-path]
9797
:or {use-system-ssh-agent true
98-
known-hosts-path (str (. System getProperty "user.home") "/.ssh/known_hosts")}}]
98+
known-hosts-path (str (. System getProperty "user.home")
99+
"/.ssh/known_hosts")}}]
99100
(let [agent (JSch.)]
100101
(when use-system-ssh-agent
101102
(agent/connect agent))
@@ -145,13 +146,13 @@
145146
;; LocalIdentityRepository is not public, so we can't use
146147
;; instance?
147148
(= "com.jcraft.jsch.LocalIdentityRepository"
148-
(.getName (type id-repo))))]
149+
(.getName ^Class (type id-repo))))]
149150
(cond
150151
identity
151152
(.addIdentity agent identity passphrase)
152153

153154
(and public-key private-key)
154-
(let [id-repo (id-repository)]
155+
(let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository)]
155156
(if (local-repo? id-repo)
156157
(.addIdentity agent name private-key public-key passphrase)
157158
(let [keypair (KeyPair/load agent private-key-path public-key-path)]
@@ -160,7 +161,7 @@
160161
(.add id-repo (.forSSHAgent keypair)))))
161162

162163
(and public-key-path private-key-path)
163-
(let [id-repo (id-repository)]
164+
(let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository)]
164165
(if (local-repo? id-repo)
165166
(.addIdentity
166167
agent
@@ -172,7 +173,7 @@
172173
(.add id-repo (.forSSHAgent keypair)))))
173174

174175
private-key-path
175-
(let [id-repo (id-repository)]
176+
(let [^com.jcraft.jsch.IdentityRepository id-repo (id-repository)]
176177
(if (local-repo? id-repo)
177178
(.addIdentity agent (file-path private-key-path) passphrase)
178179
(let [keypair (KeyPair/load agent private-key-path)]
@@ -425,7 +426,7 @@ keys. All other option key pairs will be passed as SSH config options."
425426
(Thread/sleep 100))
426427
{:exit (.getExitStatus shell)
427428
:out (if (= :bytes out)
428-
(.toByteArray out-stream)
429+
(.toByteArray ^ByteArrayOutputStream out-stream)
429430
(.toString out-stream))}))))
430431

431432
(defn ssh-exec
@@ -464,10 +465,10 @@ keys. All other option key pairs will be passed as SSH config options."
464465
(Thread/sleep 100))
465466
{:exit (.getExitStatus exec)
466467
:out (if (= :bytes out)
467-
(.toByteArray out-stream)
468+
(.toByteArray ^ByteArrayOutputStream out-stream)
468469
(.toString out-stream))
469470
:err (if (= :bytes out)
470-
(.toByteArray err-stream)
471+
(.toByteArray ^ByteArrayOutputStream err-stream)
471472
(.toString err-stream))}))))
472473

473474
(defn ssh

test/clj_ssh/ssh_test.clj

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,15 @@
6060
(let [agent (ssh-agent {})]
6161
(let [n (count (.getIdentityNames agent))
6262
test-key-comment "key for test clj-ssh"
63-
has-key (some #(= (private-key-path) %) (.getIdentityNames agent))]
63+
names (vec (.getIdentityNames agent))
64+
has-key (some #(= (private-key-path) %) names)]
6465
(add-identity
6566
agent
6667
{:private-key-path (private-key-path)
6768
:public-key-path (public-key-path)})
68-
(is (or has-key (= (inc n) (count (.getIdentityNames agent)))))
69-
(is (some #(= (private-key-path) %) (.getIdentityNames agent)))))))
69+
(let [names (.getIdentityNames agent)]
70+
(is (or has-key (= (inc n) (count names))))
71+
(is (some #(= (private-key-path) %) names)))))))
7072

7173
(deftest has-identity?-test
7274
(let [key (private-key-path)

0 commit comments

Comments
 (0)