File 2259-ssh-Enable-usage-of-supported-but-not-default-host-k.patch of Package erlang

From 99a6fe8c485af3024731bbb6a5af9afac7a0045f Mon Sep 17 00:00:00 2001
From: Hans Nilsson <hans@erlang.org>
Date: Fri, 20 Jan 2017 15:52:57 +0100
Subject: [PATCH 9/9] ssh: Enable usage of supported but not default host key
 algorithms

---
 lib/ssh/src/ssh_connection_handler.erl | 33 +++++++++++++++++++--------------
 1 file changed, 19 insertions(+), 14 deletions(-)

diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 4496c657c..dcf509ca0 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -1481,31 +1481,36 @@ renegotiation(_) -> false.
 %%--------------------------------------------------------------------
 supported_host_keys(client, _, Options) ->
     try
-	case proplists:get_value(public_key,
-				 proplists:get_value(preferred_algorithms,Options,[])
-				) of
-	    undefined ->
-		ssh_transport:default_algorithms(public_key);
-	    L ->
-		L -- (L--ssh_transport:default_algorithms(public_key))
-	end
+        find_sup_hkeys(Options)
     of
 	[] ->
-	    {stop, {shutdown, "No public key algs"}};
+	    error({shutdown, "No public key algs"});
 	Algs ->
 	    [atom_to_list(A) || A<-Algs]
     catch
 	exit:Reason ->
-	    {stop, {shutdown, Reason}}
+	    error({shutdown, Reason})
     end;
 supported_host_keys(server, KeyCb, Options) ->
-    [atom_to_list(A) || A <- proplists:get_value(public_key,
-						 proplists:get_value(preferred_algorithms,Options,[]),
-						 ssh_transport:default_algorithms(public_key)
-						),
+    [atom_to_list(A) || A <- find_sup_hkeys(Options),
 			available_host_key(KeyCb, A, Options)
     ].
 
+
+find_sup_hkeys(Options) ->
+    case proplists:get_value(public_key,
+                             proplists:get_value(preferred_algorithms,Options,[])
+                            )
+    of
+        undefined ->
+            ssh_transport:default_algorithms(public_key);
+        L ->
+            NonSupported =  L--ssh_transport:supported_algorithms(public_key),
+            L -- NonSupported
+    end.
+
+
+
 %% Alg :: atom()
 available_host_key(KeyCb, Alg, Opts) ->
     element(1, catch KeyCb:host_key(Alg, Opts)) == ok.
-- 
2.11.1

openSUSE Build Service is sponsored by