File 5108-ssh-ssh-shell-now-sends-LANG-and-LC_ALL-env-vars-to-.patch of Package erlang

From 239aef1f838b14f83b1a8682a1a48182f698950f Mon Sep 17 00:00:00 2001
From: Hans Nilsson <hans@erlang.org>
Date: Mon, 7 Sep 2020 15:14:49 +0200
Subject: [PATCH 08/11] ssh: ssh:shell now sends LANG and LC_ALL env vars to
 server

---
 lib/ssh/src/ssh.erl                    |  2 ++
 lib/ssh/src/ssh_connection_handler.erl | 22 +++++++++++++++++-----
 lib/ssh/test/ssh_test_lib.erl          |  8 ++++++++
 3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl
index 0404327b2a..b3c1ac16fa 100644
--- a/lib/ssh/src/ssh.erl
+++ b/lib/ssh/src/ssh.erl
@@ -507,6 +507,8 @@ shell(ConnectionRef) when is_pid(ConnectionRef) ->
     case ssh_connection:session_channel(ConnectionRef, infinity) of
 	{ok,ChannelId}  ->
 	    success = ssh_connection:ptty_alloc(ConnectionRef, ChannelId, []),
+            success = ssh_connection:send_environment_vars(ConnectionRef, ChannelId,
+                                                           ["LANG", "LC_ALL"]),
 	    Args = [{channel_cb, ssh_shell},
 		    {init_args,[ConnectionRef, ChannelId]},
 		    {cm, ConnectionRef}, {channel_id, ChannelId}],
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 4b70a5adfb..b90e4b9259 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -1239,16 +1239,28 @@ handle_event(cast, {adjust_window,ChannelId,Bytes}, StateName, D) when ?CONNECTE
 	    keep_state_and_data
     end;
 
-handle_event(cast, {reply_request,success,ChannelId}, StateName, D) when ?CONNECTED(StateName) ->
+handle_event(cast, {reply_request,Resp,ChannelId}, StateName, D) when ?CONNECTED(StateName) ->
     case ssh_client_channel:cache_lookup(cache(D), ChannelId) of
 	#channel{remote_id = RemoteId} ->
 	    Msg = ssh_connection:channel_success_msg(RemoteId),
 	    update_inet_buffers(D#data.socket),
 	    {keep_state, send_msg(Msg,D)};
-
-	undefined ->
-	    keep_state_and_data
-    end;
+        #channel{remote_id = RemoteId} when Resp== success ; Resp==failure ->
+            Msg = 
+                case Resp of
+                    success -> ssh_connection:channel_success_msg(RemoteId);
+                    failure -> ssh_connection:channel_failure_msg(RemoteId)
+                end,
+            update_inet_buffers(D#data.socket),
+            {keep_state, send_msg(Msg,D)};
+
+        #channel{} ->
+            Details = io_lib:format("Unhandled reply in state ~p:~n~p", [StateName,Resp]),
+            ?send_disconnect(?SSH_DISCONNECT_PROTOCOL_ERROR, Details, StateName, D);
+ 
+ 	undefined ->
+ 	    keep_state_and_data
+     end;
 
 handle_event(cast, {request,ChannelPid, ChannelId, Type, Data}, StateName, D) when ?CONNECTED(StateName) ->
     {keep_state,  handle_request(ChannelPid, ChannelId, Type, Data, false, none, D)};
diff --git a/lib/ssh/test/ssh_test_lib.erl b/lib/ssh/test/ssh_test_lib.erl
index 0516d6ef3f..d9e57042d2 100644
--- a/lib/ssh/test/ssh_test_lib.erl
+++ b/lib/ssh/test/ssh_test_lib.erl
@@ -338,6 +338,7 @@ loop_io_server(TestCase, Buff0) ->
              %%ct:log("io_server ~p:~p ~p got ~p",[?MODULE,?LINE,self(),_REQ]),
 	     {ok, Reply, Buff} = io_request(Request, TestCase, From,
 					    ReplyAs, Buff0),
+             %%ct:log("io_server ~p:~p ~p going to reply ~p",[?MODULE,?LINE,self(),Reply]),
 	     io_reply(From, ReplyAs, Reply),
 	     loop_io_server(TestCase, Buff);
 	 {'EXIT',_, _} = _Exit ->
@@ -347,6 +348,12 @@ loop_io_server(TestCase, Buff0) ->
 	30000 -> ct:fail("timeout ~p:~p",[?MODULE,?LINE])
     end.
 
+io_request(getopts,_TestCase, _, _, Buff) ->
+    {ok, [], Buff};
+io_request({get_geometry,columns},_TestCase, _, _, Buff) ->
+    {ok, 80, Buff};
+io_request({get_geometry,rows},_TestCase, _, _, Buff) ->
+    {ok, 24, Buff};
 io_request({put_chars, Chars}, TestCase, _, _, Buff) ->
     reply(TestCase, Chars),
     {ok, ok, Buff};
@@ -370,6 +377,7 @@ io_request({get_line, _Enc, _Prompt} = Request, _, From, ReplyAs, [] = Buff) ->
 io_request({get_line, _Enc,_}, _, _, _, [Line | Buff]) ->
     {ok, Line, Buff}.
 
+
 io_reply(_, _, []) ->
     ok;
 io_reply(From, ReplyAs, Reply) ->
-- 
2.26.2

openSUSE Build Service is sponsored by