[erlang-bugs] ssh module, enhancement proposal for custom ssh_cli.

YAMASHINA Hio hio@REDACTED
Thu Sep 25 07:00:46 CEST 2008


Hi.

I wanted to write customized ssh daemon application.
But It looks like no way to trap ssh-packets until shell
is started.
(and no way to get ssh_cm instance from shell function.)

I wrote a patch for writing original ssh-daemon application
by replace ssh_cli with another module which can be selected
by caller.

    % ssh_cli option:
    % - module name which implements child_spec/4
    % - or fun/4
    % - default is 'ssh_cli'
    % these functions should return
    % - fun/0 closure which returns child_pid.
    % - or just a child_spec.

    ssh:daemon(22, [
        {ssh_cli, ?MODULE },
        {system_dir, "xxx"},
        {pwdfun, fun pwdfun/2}
    ]).

    child_spec(_Shell, _Address, _Port, _Options) ->
        ChildSpecFun = fun() ->
            ChildPid = spawn(fun() ->
                ?MODULE:init()
            end),
            ChildPid
        end,
        ChildSpecFun.


Like previous ssh_cm:listen.

    ssh_cm:listen(
        fun() ->
            spawn_link(?MODULE, init, [])
        end,
        22,
        [
          {system_dir, "."},
          {pwdfun, fun check_auth/2}
        ]
    ).


Thank you.

-- 
YAMASHINA Hio <hio@REDACTED>, <hio@REDACTED>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: ssh-1.0.custom-ssh_cli.patch
Type: application/octet-stream
Size: 912 bytes
Desc: not available
URL: <http://erlang.org/pipermail/erlang-bugs/attachments/20080925/55c04b5c/attachment.obj>


More information about the erlang-bugs mailing list