aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ssh
diff options
context:
space:
mode:
authorIngela Anderton Andin <[email protected]>2013-11-13 10:56:13 +0100
committerIngela Anderton Andin <[email protected]>2013-11-13 14:27:35 +0100
commit7efe1b6dd3215261777b5f335b4f92dfca7cea42 (patch)
tree29ded555655000c441f4a40d3c34bf2d103cd0fb /lib/ssh
parentfe6ddb300dbf092b02260a06baf6238f4d81eb14 (diff)
downloadotp-7efe1b6dd3215261777b5f335b4f92dfca7cea42.tar.gz
otp-7efe1b6dd3215261777b5f335b4f92dfca7cea42.tar.bz2
otp-7efe1b6dd3215261777b5f335b4f92dfca7cea42.zip
ssh: Logging fun and document enhancement
Diffstat (limited to 'lib/ssh')
-rw-r--r--lib/ssh/doc/src/ssh.xml17
-rw-r--r--lib/ssh/doc/src/ssh_client_key_api.xml6
-rw-r--r--lib/ssh/doc/src/ssh_server_key_api.xml4
-rw-r--r--lib/ssh/src/ssh_connection_handler.erl22
4 files changed, 30 insertions, 19 deletions
diff --git a/lib/ssh/doc/src/ssh.xml b/lib/ssh/doc/src/ssh.xml
index acf31fc0e9..c1a51d57fc 100644
--- a/lib/ssh/doc/src/ssh.xml
+++ b/lib/ssh/doc/src/ssh.xml
@@ -53,8 +53,7 @@
returned by ssh:daemon/[1,2,3]</c></p>
<p><c>ssh_connection_ref() - opaque to the user
returned by ssh:connect/3</c></p>
- <p><c>ip_address() - {N1,N2,N3,N4} % IPv4 |
- {K1,K2,K3,K4,K5,K6,K7,K8} % IPv6</c></p>
+ <p><c>ip_address() - inet::ip_address()</c></p>
<p><c>subsystem_spec() = {subsystem_name(),
{channel_callback(), channel_init_args()}} </c></p>
<p><c>subsystem_name() = string() </c></p>
@@ -296,7 +295,7 @@
user. From a security perspective this option makes
the server very vulnerable.</p>
</item>
- <tag><c><![CDATA[{pwdfun, fun(User::string(), password::string() -> boolean()}]]></c></tag>
+ <tag><c><![CDATA[{pwdfun, fun(User::string(), password::string()) -> boolean()}]]></c></tag>
<item>
<p>Provide a function for password validation. This is called
with user and password as strings, and should return
@@ -313,17 +312,17 @@
<item>
<p>Allow an existing file-descriptor to be used
(simply passed on to the transport protocol).</p></item>
- <tag><c><![CDATA[{failfun, fun()}]]></c></tag>
+ <tag><c><![CDATA[{failfun, fun(User::string(), PeerAddress::ip_address(), Reason::term()) -> _}]]></c></tag>
<item>
- <p>Provide a fun() to implement your own logging when a user fails to authenticate.</p>
+ <p>Provide a fun to implement your own logging when a user fails to authenticate.</p>
</item>
- <tag><c><![CDATA[{connectfun, fun()}]]></c></tag>
+ <tag><c><![CDATA[{connectfun, fun(User::string(), PeerAddress::ip_address(), Method::string()) ->_}]]></c></tag>
<item>
- <p>Provide a fun() to implement your own logging when a user authenticates to the server.</p>
+ <p>Provide a fun to implement your own logging when a user authenticates to the server.</p>
</item>
- <tag><c><![CDATA[{disconnectfun, fun()}]]></c></tag>
+ <tag><c><![CDATA[{disconnectfun, fun(Reason:term()) -> _}]]></c></tag>
<item>
- <p>Provide a fun() to implement your own logging when a user disconnects from the server.</p>
+ <p>Provide a fun to implement your own logging when a user disconnects from the server.</p>
</item>
</taglist>
</desc>
diff --git a/lib/ssh/doc/src/ssh_client_key_api.xml b/lib/ssh/doc/src/ssh_client_key_api.xml
index b9b1ec4efa..2fa06f8bf1 100644
--- a/lib/ssh/doc/src/ssh_client_key_api.xml
+++ b/lib/ssh/doc/src/ssh_client_key_api.xml
@@ -41,12 +41,14 @@
<p>Type definitions that are used more than once in this module
and/or abstractions to indicate the intended use of the data
- type:</p>
+ type. For more details on public key data types
+ see the <seealso marker="public_key:public_key_records"> public_key user's guide.</seealso>
+ </p>
<p> boolean() = true | false</p>
<p> string() = [byte()] </p>
<p> public_key() = #'RSAPublicKey'{}| {integer(), #'Dss-Parms'{}}| term()</p>
- <p> private_key() = #'RSAPublicKey'{}| {integer(), #'Dss-Parms'{}}| term()</p>
+ <p> private_key() = #'RSAPrivateKey'{} | #'DSAPrivateKey'{} | term()</p>
<p> public_key_algorithm() = 'ssh-rsa'| 'ssh-dss' | atom()</p>
</section>
diff --git a/lib/ssh/doc/src/ssh_server_key_api.xml b/lib/ssh/doc/src/ssh_server_key_api.xml
index 51e1fc1f2e..ee537f2f60 100644
--- a/lib/ssh/doc/src/ssh_server_key_api.xml
+++ b/lib/ssh/doc/src/ssh_server_key_api.xml
@@ -40,7 +40,9 @@
<p>Type definitions that are used more than once in this module
and/or abstractions to indicate the intended use of the data
- type:</p>
+ type. For more details on public key data types
+ see the <seealso marker="public_key:public_key_records"> public_key user's guide.</seealso>
+ </p>
<p> boolean() = true | false</p>
<p> string() = [byte()]</p>
diff --git a/lib/ssh/src/ssh_connection_handler.erl b/lib/ssh/src/ssh_connection_handler.erl
index 753569e442..7ba2179a76 100644
--- a/lib/ssh/src/ssh_connection_handler.erl
+++ b/lib/ssh/src/ssh_connection_handler.erl
@@ -429,7 +429,7 @@ userauth(#ssh_msg_userauth_request{service = "ssh-connection",
{next_state, connected,
next_packet(State#state{auth_user = User, ssh_params = Ssh})};
{not_authorized, {User, Reason}, {Reply, Ssh}} ->
- retry_fun(User, Reason, Opts),
+ retry_fun(User, Address, Reason, Opts),
send_msg(Reply, State),
{next_state, userauth, next_packet(State#state{ssh_params = Ssh})}
end;
@@ -1399,23 +1399,31 @@ connected_fun(User, PeerAddr, Method, Opts) ->
catch Fun(User, PeerAddr, Method)
end.
-retry_fun(_, undefined, _) ->
+retry_fun(_, _, undefined, _) ->
ok;
-retry_fun(User, {error, Reason}, Opts) ->
+retry_fun(User, PeerAddr, {error, Reason}, Opts) ->
case proplists:get_value(failfun, Opts) of
undefined ->
ok;
Fun ->
- catch Fun(User, Reason)
+ do_retry_fun(Fun, User, PeerAddr, Reason)
end;
-retry_fun(User, Reason, Opts) ->
+retry_fun(User, PeerAddr, Reason, Opts) ->
case proplists:get_value(infofun, Opts) of
undefined ->
ok;
- Fun ->
- catch Fun(User, Reason)
+ Fun ->
+ do_retry_fun(Fun, User, PeerAddr, Reason)
+ end.
+
+do_retry_fun(Fun, User, PeerAddr, Reason) ->
+ case erlang:fun_info(Fun, arity) of
+ 2 -> %% Backwards compatible
+ catch Fun(User, Reason);
+ 3 ->
+ catch Fun(User, PeerAddr, Reason)
end.
ssh_info([], _State, Acc) ->