diff options
author | Vipin Nair <[email protected]> | 2015-11-13 18:51:03 +0530 |
---|---|---|
committer | Vipin Nair <[email protected]> | 2015-12-01 22:56:03 +0530 |
commit | e14b301be3b5593a13e666885ca795e6bee54b5b (patch) | |
tree | 988f0b65a39d599e19bd10cf6aec9af042f4b408 /lib/ssh/src | |
parent | 417101bca30b5ae246b97485c7898c4e5c663b9c (diff) | |
download | otp-e14b301be3b5593a13e666885ca795e6bee54b5b.tar.gz otp-e14b301be3b5593a13e666885ca795e6bee54b5b.tar.bz2 otp-e14b301be3b5593a13e666885ca795e6bee54b5b.zip |
Support SSH key callback module options
This patch allows extra callback options to be passed to the module
implementing the SSH callback module behaviour.
A module implementing the SSH key callback API is used to customize
the handling of public key. This patch allows extra callback options
to be passed to the module implementing the SSH callback module
behaviour.
The key_cb option has been changed:
{key_cb, atom()} -> {key_cb, key_cb()}
Where:
key_cb() :: atom() | {atom(), list()}
The callback options, if specified, is made available to the callback
module via the options passed to it under the key 'key_cb_private'.
More details and some backgorund is available here[1].
[1]: http://erlang.org/pipermail/erlang-patches/2015-November/004800.html
Diffstat (limited to 'lib/ssh/src')
-rw-r--r-- | lib/ssh/src/ssh.erl | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/ssh/src/ssh.erl b/lib/ssh/src/ssh.erl index bb50e436a3..1d29c95229 100644 --- a/lib/ssh/src/ssh.erl +++ b/lib/ssh/src/ssh.erl @@ -369,8 +369,12 @@ handle_option([{user_passwords, _} = Opt | Rest], SocketOptions, SshOptions) -> handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]); handle_option([{pwdfun, _} = Opt | Rest], SocketOptions, SshOptions) -> handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]); -handle_option([{key_cb, _} = Opt | Rest], SocketOptions, SshOptions) -> - handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]); +handle_option([{key_cb, {Module, Options}} | Rest], SocketOptions, SshOptions) -> + handle_option(Rest, SocketOptions, [handle_ssh_option({key_cb, Module}), + handle_ssh_priv_option({key_cb_private, Options}) | + SshOptions]); +handle_option([{key_cb, Module} | Rest], SocketOptions, SshOptions) -> + handle_option([{key_cb, {Module, []}} | Rest], SocketOptions, SshOptions); handle_option([{keyboard_interact_fun, _} = Opt | Rest], SocketOptions, SshOptions) -> handle_option(Rest, SocketOptions, [handle_ssh_option(Opt) | SshOptions]); %%Backwards compatibility @@ -544,6 +548,9 @@ handle_ssh_option({pwdfun, Value} = Opt) when is_function(Value,4) -> Opt; handle_ssh_option({key_cb, Value} = Opt) when is_atom(Value) -> Opt; +handle_ssh_option({key_cb, {CallbackMod, CallbackOptions}} = Opt) when is_atom(CallbackMod), + is_list(CallbackOptions) -> + Opt; handle_ssh_option({keyboard_interact_fun, Value} = Opt) when is_function(Value,3) -> Opt; handle_ssh_option({compression, Value} = Opt) when is_atom(Value) -> @@ -610,6 +617,9 @@ handle_ssh_option({profile, Value} = Opt) when is_atom(Value) -> handle_ssh_option(Opt) -> throw({error, {eoptions, Opt}}). +handle_ssh_priv_option({key_cb_private, Value} = Opt) when is_list(Value) -> + Opt. + handle_inet_option({active, _} = Opt) -> throw({error, {{eoptions, Opt}, "SSH has built in flow control, " "and active is handled internally, user is not allowed" |