aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/ssh/doc/src/introduction.xml3
-rw-r--r--lib/ssh/doc/src/ssh.xml2
-rw-r--r--lib/ssh/doc/src/ssh_channel.xml39
-rw-r--r--lib/ssh/doc/src/ssh_client_key_api.xml9
-rw-r--r--lib/ssh/doc/src/ssh_connection.xml26
-rw-r--r--lib/ssh/doc/src/ssh_server_key_api.xml5
-rw-r--r--lib/ssh/doc/src/ssh_sftpd.xml4
-rw-r--r--lib/ssh/doc/src/using_ssh.xml11
-rw-r--r--lib/ssh/src/Makefile4
-rw-r--r--lib/ssh/src/ssh.app.src2
-rw-r--r--lib/ssh/src/ssh_channel.erl7
-rw-r--r--lib/ssh/src/ssh_cli.erl4
-rw-r--r--lib/ssh/src/ssh_daemon_channel.erl (renamed from lib/ssh/src/ssh_subsystem.erl)31
-rw-r--r--lib/ssh/src/ssh_sftp.erl10
-rw-r--r--lib/ssh/src/ssh_sftpd.erl7
-rw-r--r--lib/ssh/src/ssh_shell.erl8
16 files changed, 101 insertions, 71 deletions
diff --git a/lib/ssh/doc/src/introduction.xml b/lib/ssh/doc/src/introduction.xml
index aac8de0f76..ae75414999 100644
--- a/lib/ssh/doc/src/introduction.xml
+++ b/lib/ssh/doc/src/introduction.xml
@@ -5,6 +5,7 @@
<header>
<copyright>
<year>2012</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
@@ -47,7 +48,7 @@
<section>
<title>Prerequisites</title>
- <p>It is assumed that the reader is familiar with the concepts of <seealso marker="doc/design_principals:users_guide">OTP</seealso>
+ <p>It is assumed that the reader is familiar with the concepts of <seealso marker="doc/design_principals:des_princ">OTP</seealso>
and has a basic understanding of <url href="http://en.wikipedia.org/wiki/Public-key_cryptography">public keys</url>.</p>
</section>
diff --git a/lib/ssh/doc/src/ssh.xml b/lib/ssh/doc/src/ssh.xml
index 7f7d887d5e..f57ee13460 100644
--- a/lib/ssh/doc/src/ssh.xml
+++ b/lib/ssh/doc/src/ssh.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>2004</year><year>2012</year>
+ <year>2004</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
diff --git a/lib/ssh/doc/src/ssh_channel.xml b/lib/ssh/doc/src/ssh_channel.xml
index f0083ae8d1..66b3b8b656 100644
--- a/lib/ssh/doc/src/ssh_channel.xml
+++ b/lib/ssh/doc/src/ssh_channel.xml
@@ -5,7 +5,7 @@
<header>
<copyright>
<year>2009</year>
- <year>2012</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
@@ -31,7 +31,7 @@
<p>SSH services (clients and servers) are implemented as channels
that are multiplexed over an SSH connection and communicates via
the <url href="http://www.ietf.org/rfc/rfc4254.txt"> SSH
- Connection Protocol </url>. This module provides a callback API
+ Connection Protocol</url>. This module provides a callback API
that takes care of generic channel aspects such as flow control
and close messages and lets the callback functions take care of
the service (application) specific parts. This behavior also ensures
@@ -41,12 +41,12 @@
the SSH applications supervisor tree.
</p>
- <note> When implementing a SSH subsystem use the
- <c>-behaviour(ssh_subsystem).</c> instead of <c>-behaviour(ssh_channel).</c>
+ <note> <p>When implementing a SSH subsystem use the
+ <c>-behaviour(ssh_daemon_channel).</c> instead of <c>-behaviour(ssh_channel).</c>
as the only relevant callback functions for subsystems are
- init/1, handle_ssh_msg/2, handle_msg/2 and terminate/2, so the ssh_subsystem
+ init/1, handle_ssh_msg/2, handle_msg/2 and terminate/2, so the ssh_daemon_channel
behaviour is limited version of the ssh_channel behaviour.
- </note>
+ </p> </note>
</description>
<section>
@@ -83,7 +83,7 @@
<desc>
<p>Makes a synchronous call to the channel process by sending
a message and waiting until a reply arrives or a timeout
- occurs. The channel will call <seealso mark =
+ occurs. The channel will call <seealso marker =
"#Module:handle_call-3">Module:handle_call/3</seealso>
to handle the message. If the channel process does not exist
<c>{error, closed}</c> is returned.
@@ -104,7 +104,7 @@
<p>Sends an asynchronous message to the channel process and
returns ok immediately, ignoring if the destination node or
channel process does not exist. The channel will call
- <seealso mark = "#Module:handle_cast-3">Module:handle_cast/2</seealso>
+ <seealso marker = "#Module:handle_cast-2">Module:handle_cast/2</seealso>
to handle the message.
</p>
</desc>
@@ -114,7 +114,7 @@
<name>enter_loop(State) -> _ </name>
<fsummary> Makes an existing process an ssh_channel process. </fsummary>
<type>
- <v> State = term() - as returned by <seealso mark = "#init-1">ssh_channel:init/1</seealso></v>
+ <v> State = term() - as returned by <seealso marker = "#init-1">ssh_channel:init/1</seealso></v>
</type>
<desc>
<p> Makes an existing process an <c>ssh_channel</c>
@@ -124,7 +124,7 @@
one of the start functions in proc_lib, see <seealso
marker="stdlib:proc_lib">proc_lib(3)</seealso>. The
user is responsible for any initialization of the process
- and needs to call <seealso mark = "#init-1">ssh_channel:init/1</seealso>
+ and needs to call <seealso marker = "#init-1">ssh_channel:init/1</seealso>
</p>
</desc>
</func>
@@ -155,7 +155,7 @@
marker="ssh#connect-3">ssh:connect/3</seealso></item>
<tag><c><![CDATA[{channel_id, channel_id()}]]></c></tag>
- <item> Id of the ssh channel.</item>
+ <item> Id of the SSH channel.</item>
</taglist>
@@ -222,8 +222,8 @@
<title> CALLBACK TIMEOUTS</title>
<p>The timeout values that may be returned by the callback functions
- has the same semantics as in a <seealso marker="stdlib#gen_server">gen_server</seealso>
- If the timeout occurs <seealso marker="#handle_msg">handle_msg/2</seealso>
+ has the same semantics as in a <seealso marker="stdlib:gen_server">gen_server</seealso>
+ If the timeout occurs <seealso marker="#Module:handle_msg-2">handle_msg/2</seealso>
will be called as <c>handle_msg(timeout, State). </c></p>
</section>
@@ -334,7 +334,6 @@
</p>
<p>For more detailed information on timeouts see the section
<seealso marker="#cb_timeouts">CALLBACK TIMEOUTS</seealso>. </p>
- <marker id="handle_msg"></marker>
</desc>
</func>
@@ -342,10 +341,11 @@
<name>Module:handle_msg(Msg, State) -> {ok, State} |
{stop, ChannelId, State}</name>
- <fsummary> Handle other messages than ssh connection protocol,
+ <fsummary> Handle other messages than SSH connection protocol,
call or cast messages sent to the channel.</fsummary>
<type>
<v>Msg = timeout | term()</v>
+ <v>ChannelId = ssh_channel_id()</v>
<v>State = term() </v>
</type>
<desc>
@@ -361,7 +361,7 @@
ssh_connection_ref()}]]></c></tag>
<item>This is the first messages that will be received by
the channel, it is sent just before the <seealso
- marker="#init-2">ssh_channel:init/1</seealso> function
+ marker="#init-1">ssh_channel:init/1</seealso> function
returns successfully. This is especially useful if the
server wants to send a message to the client without first
receiving a message from it. If the message is not
@@ -374,19 +374,20 @@
<func>
<name>Module:handle_ssh_msg(Msg, State) -> {ok, State} | {stop,
- ssh_channel_id(), State}</name>
+ ChannelId, State}</name>
<fsummary> Handles ssh connection protocol messages. </fsummary>
<type>
<v>Msg = <seealso marker="ssh_connection"> ssh_connection:event() </seealso> </v>
+ <v>ChannelId = ssh_channel_id()</v>
<v>State = term()</v>
</type>
<desc>
- <p> Handles ssh connection protocol messages that may need
+ <p> Handles SSH connection protocol messages that may need
service specific attention.
</p>
<p> The following message is completely taken care of by the
- ssh channel behavior</p>
+ SSH channel behavior</p>
<taglist>
<tag><c><![CDATA[{closed, ssh_channel_id()}]]></c></tag>
diff --git a/lib/ssh/doc/src/ssh_client_key_api.xml b/lib/ssh/doc/src/ssh_client_key_api.xml
index abc1070e78..929b71414f 100644
--- a/lib/ssh/doc/src/ssh_client_key_api.xml
+++ b/lib/ssh/doc/src/ssh_client_key_api.xml
@@ -5,6 +5,7 @@
<header>
<copyright>
<year>2012</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
@@ -62,7 +63,7 @@
<d> Normally an RSA or DSA public key but handling of other public keys can be added</d>
<v>ConnectOptions = proplists:proplist() </v>
- <d>Options provided to <seealso marker="ssh#daemon">ssh:connect/[3,4]</seealso></d>
+ <d>Options provided to <seealso marker="ssh#connect">ssh:connect/[3,4]</seealso></d>
<v>Reason = term() </v>
</type>
<desc>
@@ -85,7 +86,7 @@
can be handled.</d>
<v> ConnectOptions = proplists:proplist() </v>
- <d>Options provided to <seealso marker="ssh#daemon">ssh:connect/[3,4]</seealso></d>
+ <d>Options provided to <seealso marker="ssh#connect-3">ssh:connect/[3,4]</seealso></d>
<v> Result = boolean()</v>
</type>
@@ -104,7 +105,7 @@
can be handled.</d>
<v> ConnectOptions = proplists:proplist() </v>
- <d>Options provided to <seealso marker="ssh#daemon">ssh:connect/[3,4]</seealso></d>
+ <d>Options provided to <seealso marker="ssh#connect-3">ssh:connect/[3,4]</seealso></d>
<v> PrivateKey = private_key()</v>
<d> The private key of the user matching the <c>Algorithm</c></d>
@@ -114,7 +115,7 @@
<desc>
<p>Fetches the users "public key" matching the <c>Algorithm</c>.
- <note>The private key contains the public key</note>
+ <note><p>The private key contains the public key</p></note>
</p>
</desc>
</func>
diff --git a/lib/ssh/doc/src/ssh_connection.xml b/lib/ssh/doc/src/ssh_connection.xml
index c66622307f..efd4865a6f 100644
--- a/lib/ssh/doc/src/ssh_connection.xml
+++ b/lib/ssh/doc/src/ssh_connection.xml
@@ -5,7 +5,7 @@
<header>
<copyright>
<year>2008</year>
- <year>2012</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
@@ -42,7 +42,7 @@
marker="ssh_channel">ssh_channel</seealso> behavior is used to
implement the channel process these will be handled by
<seealso
- marker="ssh_channel#CallbackModule:handled_ssh_msg-2">handle_ssh_msg/2 </seealso>.</p>
+ marker="ssh_channel#Module:handle_ssh_msg-2">handle_ssh_msg/2 </seealso>.</p>
</description>
<section>
@@ -69,12 +69,12 @@
<taglist>
<tag><c><![CDATA[{data, ssh_channel_id(), ssh_data_type_code(), binary() = Data}]]></c></tag>
<item> Data has arrived on the channel. This event is sent as
- result of calling <seealso marker="#send-3"> ssh_connection:send/[3,4,5] </seealso></item>
+ result of calling <seealso marker="ssh_connection#send-3"> ssh_connection:send/[3,4,5] </seealso></item>
<tag><c><![CDATA[{eof, ssh_channel_id()}]]></c></tag>
<item>Indicates that the other side will not send any more
data. This event is sent as result of calling <seealso
- marker="#send_eof-2"> ssh_connection:send_eof/2</seealso>
+ marker="ssh_connection#send_eof-2"> ssh_connection:send_eof/2</seealso>
</item>
</taglist>
</item>
@@ -104,12 +104,12 @@
following message can be sent to return the exit status of the
command. A zero 'exit_status' usually means that the command
terminated successfully. This event is sent as result of calling
- <seealso marker="#exit_status">
+ <seealso marker="ssh_connection#exit_status-3">
ssh_connection:exit_status/3</seealso></item>
<tag><c><![CDATA[{closed, ssh_channel_id()}]]></c></tag>
<item> This event is sent as result of calling
- <seealso marker="#close">ssh_connection:close/2</seealso> Both the handling of this
+ <seealso marker="ssh_connection#close-2">ssh_connection:close/2</seealso> Both the handling of this
event and sending of it will be taken care of by the
<seealso marker="ssh_channel">ssh_channel</seealso> behavior.</item>
@@ -122,17 +122,17 @@
<p> Channels implementing a shell and command execution on the
server side should handle the following messages that may be sent by client channel processes. </p>
- <p><note>Events that includes a <c> WantReply</c> expects the event handling
- process to call <seealso marker="#reply_request">ssh_connection:reply_request/4</seealso>
+ <note> <p>Events that includes a <c> WantReply</c> expects the event handling
+ process to call <seealso marker="ssh_connection#reply_request-4">ssh_connection:reply_request/4</seealso>
with the boolean value of <c> WantReply</c> as the second
- argument. </note> </p>
+ argument. </p></note>
<taglist>
<tag><c><![CDATA[{env, ssh_channel_id(), boolean() = WantReply,
string() = Var, string() = Value}]]></c></tag>
<item> Environment variables may be passed to the shell/command
to be started later. This event is sent as result of calling <seealso
- marker="#setenv"> ssh_connection:setenv/5</seealso>
+ marker="ssh_connection#setenv-5"> ssh_connection:setenv/5</seealso>
</item>
<tag><c><![CDATA[{pty, ssh_channel_id(),
@@ -157,7 +157,7 @@
<tag><c><![CDATA[{shell, boolean() = WantReply}]]></c></tag>
<item> This message will request that the user's default shell
be started at the other end. This event is sent as result of calling <seealso
- marker="#shell"> ssh_connection:shell/2</seealso>
+ marker="ssh_connection#shell-2"> ssh_connection:shell/2</seealso>
</item>
<tag><c><![CDATA[{window_change, ssh_channel_id(), integer() = CharWidth,
@@ -171,7 +171,7 @@
boolean() = WantReply, string() = Cmd}]]></c></tag>
<item> This message will request that the server starts
execution of the given command. This event is sent as result of calling <seealso
- marker="#exec">ssh_connection:exec/4 </seealso>
+ marker="ssh_connection#exec-4">ssh_connection:exec/4 </seealso>
</item>
</taglist>
</item>
@@ -194,7 +194,7 @@
<note><p>Channels implemented with the <seealso marker="ssh_channel"> ssh_channel
behavior</seealso> will normaly not need to call this function as flow control
will be handled by the behavior. The behavior will adjust the window every time
- the callback <seealso marker="ssh_channel#handled_ssh_msg-2">
+ the callback <seealso marker="ssh_channel#Module:handle_ssh_msg-2">
handle_ssh_msg/2 </seealso> has returned after processing channel data</p> </note>
</desc>
</func>
diff --git a/lib/ssh/doc/src/ssh_server_key_api.xml b/lib/ssh/doc/src/ssh_server_key_api.xml
index 78ff105387..c4562e1211 100644
--- a/lib/ssh/doc/src/ssh_server_key_api.xml
+++ b/lib/ssh/doc/src/ssh_server_key_api.xml
@@ -5,6 +5,7 @@
<header>
<copyright>
<year>2012</year>
+ <year>2013</year>
<holder>Ericsson AB, All Rights Reserved</holder>
</copyright>
<legalnotice>
@@ -58,7 +59,7 @@
<d> Host key algorithm. Should support 'ssh-rsa'| 'ssh-dss' but additional algorithms
can be handled.</d>
<v> DaemonOptions = proplists:proplist() </v>
- <d>Options provided to <seealso marker="ssh#daemon">ssh:daemon/[2,3]</seealso></d>
+ <d>Options provided to <seealso marker="ssh#daemon-2">ssh:daemon/[2,3]</seealso></d>
<v> Key = private_key()</v>
<d> The private key of the host matching the <c>Algorithm</c></d>
<v>Reason = term() </v>
@@ -77,7 +78,7 @@
<v> User = string()</v>
<d> The user owning the public key</d>
<v> DaemonOptions = proplists:proplist() </v>
- <d> Options provided to <seealso marker="ssh#daemon">ssh:daemon/[2,3]</seealso></d>
+ <d> Options provided to <seealso marker="ssh#daemon-2">ssh:daemon/[2,3]</seealso></d>
<v> Result = boolean()</v>
</type>
<desc>
diff --git a/lib/ssh/doc/src/ssh_sftpd.xml b/lib/ssh/doc/src/ssh_sftpd.xml
index 3666bc7692..748e24d44b 100644
--- a/lib/ssh/doc/src/ssh_sftpd.xml
+++ b/lib/ssh/doc/src/ssh_sftpd.xml
@@ -4,7 +4,7 @@
<erlref>
<header>
<copyright>
- <year>2005</year><year>2012</year>
+ <year>2005</year><year>2013</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -61,7 +61,7 @@
<item>
<p>Determines which module to call for accessing
the file server. The default value is <c>ssh_sftpd_file</c> that uses the
- <seealso marker="kernel#file">file</seealso> and <seealso marker="kernel#filelib">filelib</seealso> API:s to access the standard OTP file
+ <seealso marker="kernel:file">file</seealso> and <seealso marker="kernel:filelib">filelib</seealso> API:s to access the standard OTP file
server. This option may be used to plug in
other file servers.</p>
</item>
diff --git a/lib/ssh/doc/src/using_ssh.xml b/lib/ssh/doc/src/using_ssh.xml
index 87b811d591..c3bb7a22aa 100644
--- a/lib/ssh/doc/src/using_ssh.xml
+++ b/lib/ssh/doc/src/using_ssh.xml
@@ -29,7 +29,7 @@
<section>
<title> General information</title>
<p>The examples in the following sections use the utility function
- <seealso marker="ssh#start"> ssh:start/0 </seealso> that starts
+ <seealso marker="ssh:start"> ssh:start/0 </seealso> that starts
all needed applications (crypto, public_key and ssh). All examples
are run in an Erlang shell, or in a bash shell using openssh to
illustrate how the erlang ssh application can be used. The
@@ -70,7 +70,7 @@
<p> The option system_dir must be a directory containing a host
key file and it defaults to /etc/ssh. For details see section
Configuration Files in <seealso
- marker="ssh_app">ssh(6)</seealso>.
+ marker="ssh_app#">ssh(6)</seealso>.
</p>
<note><p>Normally the /etc/ssh directory is only readable by root. </p>
@@ -137,12 +137,13 @@
<title>One Time Execution</title>
<p>In the following example the Erlang shell is the client process
- that receives the channel replies. <note> If you run this example
+ that receives the channel replies. </p>
+
+ <note><p> If you run this example
in your environment you may get fewer or more messages back as
this depends on the OS and shell on the machine running the ssh
daemon. See also <seealso marker="ssh_connection#exec-4">ssh_connection:exec/4</seealso>
- </note>
- </p>
+ </p></note>
<code type="erl" >
1> ssh:start().
diff --git a/lib/ssh/src/Makefile b/lib/ssh/src/Makefile
index 27e43a88ed..93d0b54f57 100644
--- a/lib/ssh/src/Makefile
+++ b/lib/ssh/src/Makefile
@@ -1,7 +1,7 @@
#
# %CopyrightBegin%
#
-# Copyright Ericsson AB 2004-2012. All Rights Reserved.
+# Copyright Ericsson AB 2004-2013. All Rights Reserved.
#
# The contents of this file are subject to the Erlang Public License,
# Version 1.1, (the "License"); you may not use this file except in
@@ -41,7 +41,7 @@ RELSYSDIR = $(RELEASE_PATH)/lib/ssh-$(VSN)
BEHAVIOUR_MODULES= \
ssh_sftpd_file_api \
ssh_channel \
- ssh_subsystem \
+ ssh_daemon_channel \
ssh_client_key_api \
ssh_server_key_api
diff --git a/lib/ssh/src/ssh.app.src b/lib/ssh/src/ssh.app.src
index a0ba7cf7d9..49707f3378 100644
--- a/lib/ssh/src/ssh.app.src
+++ b/lib/ssh/src/ssh.app.src
@@ -17,6 +17,7 @@
ssh_connection_handler,
ssh_connection_manager,
ssh_connection_sup,
+ ssh_daemon_channel,
ssh_shell,
sshc_sup,
sshd_sup,
@@ -29,7 +30,6 @@
ssh_sftpd,
ssh_sftpd_file,
ssh_sftpd_file_api,
- ssh_subsystem,
ssh_subsystem_sup,
ssh_sup,
ssh_system_sup,
diff --git a/lib/ssh/src/ssh_channel.erl b/lib/ssh/src/ssh_channel.erl
index 4e8f8538c2..062ed764ca 100644
--- a/lib/ssh/src/ssh_channel.erl
+++ b/lib/ssh/src/ssh_channel.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2008-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2008-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -48,10 +48,7 @@
{ok, NewState :: term()} | {error, Reason :: term()}.
-callback handle_msg(Msg ::term(), State :: term()) ->
- {noreply, NewState :: term()} |
- {noreply, NewState :: term(), timeout() | hibernate} |
- {stop, Reason :: term(), NewState :: term()}.
-
+ {ok, State::term()} | {stop, ChannelId::integer(), State::term()}.
-callback handle_ssh_msg({ssh_cm, ConnectionRef::term(), SshMsg::term()},
State::term()) -> {ok, State::term()} |
diff --git a/lib/ssh/src/ssh_cli.erl b/lib/ssh/src/ssh_cli.erl
index c8c610f8ef..7232cc482c 100644
--- a/lib/ssh/src/ssh_cli.erl
+++ b/lib/ssh/src/ssh_cli.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2005-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2005-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -24,7 +24,7 @@
-module(ssh_cli).
--behaviour(ssh_channel).
+-behaviour(ssh_daemon_channel).
-include("ssh.hrl").
-include("ssh_connect.hrl").
diff --git a/lib/ssh/src/ssh_subsystem.erl b/lib/ssh/src/ssh_daemon_channel.erl
index 5a9fa32668..ab3efbcaff 100644
--- a/lib/ssh/src/ssh_subsystem.erl
+++ b/lib/ssh/src/ssh_daemon_channel.erl
@@ -1,4 +1,28 @@
--module(ssh_subsystem).
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2013. All Rights Reserved.
+%%
+%% The contents of this file are subject to the Erlang Public License,
+%% Version 1.1, (the "License"); you may not use this file except in
+%% compliance with the License. You should have received a copy of the
+%% Erlang Public License along with this software. If not, it can be
+%% retrieved online at http://www.erlang.org/.
+%%
+%% Software distributed under the License is distributed on an "AS IS"
+%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
+%% the License for the specific language governing rights and limitations
+%% under the License.
+%%
+%% %CopyrightEnd%
+%%
+
+%%
+%% Description: a gen_server implementing a simple
+%% terminal (using the group module) for a CLI
+%% over SSH
+
+-module(ssh_daemon_channel).
%% API to special server side channel that can be pluged into the erlang ssh daemeon
-callback init(Args :: term()) ->
@@ -11,10 +35,7 @@
term().
-callback handle_msg(Msg ::term(), State :: term()) ->
- {noreply, NewState :: term()} |
- {noreply, NewState :: term(), timeout() | hibernate} |
- {stop, Reason :: term(), NewState :: term()}.
-
+ {ok, State::term()} | {stop, ChannelId::integer(), State::term()}.
-callback handle_ssh_msg({ssh_cm, ConnectionRef::term(), SshMsg::term()},
State::term()) -> {ok, State::term()} |
{stop, ChannelId::integer(),
diff --git a/lib/ssh/src/ssh_sftp.erl b/lib/ssh/src/ssh_sftp.erl
index f000558100..f3afbe01bf 100644
--- a/lib/ssh/src/ssh_sftp.erl
+++ b/lib/ssh/src/ssh_sftp.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2005-2011. All Rights Reserved.
+%% Copyright Ericsson AB 2005-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -47,7 +47,7 @@
recv_window/2, list_dir/3, read_file/3, write_file/4]).
%% ssh_channel callbacks
--export([init/1, handle_call/3, handle_msg/2, handle_ssh_msg/2, terminate/2]).
+-export([init/1, handle_call/3, handle_cast/2, code_change/3, handle_msg/2, handle_ssh_msg/2, terminate/2]).
%% TODO: Should be placed elsewhere ssh_sftpd should not call functions in ssh_sftp!
-export([info_to_attr/1, attr_to_info/1]).
@@ -436,6 +436,12 @@ handle_call({{timeout, Timeout}, Msg}, From, #state{req_id = Id} = State) ->
timer:send_after(Timeout, {timeout, Id, From}),
do_handle_call(Msg, From, State).
+handle_cast(_,State) ->
+ {noreply, State}.
+
+code_change(_OldVsn, State, _Extra) ->
+ {ok, State}.
+
do_handle_call({open, Async,FileName,Mode}, From, #state{xf = XF} = State) ->
{Access,Flags,Attrs} = open_mode(XF#ssh_xfer.vsn, Mode),
ReqID = State#state.req_id,
diff --git a/lib/ssh/src/ssh_sftpd.erl b/lib/ssh/src/ssh_sftpd.erl
index c7e8373840..3d469d3c6e 100644
--- a/lib/ssh/src/ssh_sftpd.erl
+++ b/lib/ssh/src/ssh_sftpd.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2005-2012. All Rights Reserved.
+%% Copyright Ericsson AB 2005-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -23,8 +23,7 @@
-module(ssh_sftpd).
-%%-behaviour(gen_server).
--behaviour(ssh_subsystem).
+-behaviour(ssh_daemon_channel).
-include_lib("kernel/include/file.hrl").
@@ -159,7 +158,7 @@ handle_ssh_msg({ssh_cm, _, {exit_status, ChannelId, Status}}, State) ->
{stop, ChannelId, State}.
%%--------------------------------------------------------------------
-%% Function: handle_ssh_msg(Args) -> {ok, State} | {stop, ChannelId, State}
+%% Function: handle_msg(Args) -> {ok, State} | {stop, ChannelId, State}
%%
%% Description: Handles other messages
%%--------------------------------------------------------------------
diff --git a/lib/ssh/src/ssh_shell.erl b/lib/ssh/src/ssh_shell.erl
index 6590486a4c..8031450617 100644
--- a/lib/ssh/src/ssh_shell.erl
+++ b/lib/ssh/src/ssh_shell.erl
@@ -1,7 +1,7 @@
%%
%% %CopyrightBegin%
%%
-%% Copyright Ericsson AB 2009-2010. All Rights Reserved.
+%% Copyright Ericsson AB 2009-2013. All Rights Reserved.
%%
%% The contents of this file are subject to the Erlang Public License,
%% Version 1.1, (the "License"); you may not use this file except in
@@ -23,7 +23,9 @@
-include("ssh_connect.hrl").
--behaviour(ssh_channel).
+%%% As this is an user interactive client it behaves like a daemon
+%%% channel inspite of it being a client.
+-behaviour(ssh_daemon_channel).
%% ssh_channel callbacks
-export([init/1, handle_msg/2, handle_ssh_msg/2, terminate/2]).
@@ -123,7 +125,7 @@ handle_ssh_msg({ssh_cm, _, {exit_status, ChannelId, Status}}, State) ->
{stop, ChannelId, State}.
%%--------------------------------------------------------------------
-%% Function: handle_ssh_msg(Args) -> {ok, State} | {stop, ChannelId, State}
+%% Function: handle_msg(Args) -> {ok, State} | {stop, ChannelId, State}
%%
%% Description: Handles other channel messages
%%--------------------------------------------------------------------