ssh_sftp options and dialyzer (OTP 21 ok, OTP 24 error?)

Rynö Jouni (FMI) Jouni.Ryno@REDACTED
Mon Oct 18 09:16:53 CEST 2021


Hi

I did notice, that OTP 24 is checking the options more carefully (does
not like daemon options for clients), but is this a spec error in OTP
24 or me not having correct options? OTP 21 is fine with this code.

The following code gives this error with erl V12.0.4 and 
Dialyzer version v4.4.1 (Debian testing)

  Checking whether the PLT /home/ryno/.dialyzer_plt is up-to-date...
yes
  Proceeding with analysis...
test_dialyzer.erl:4:1: Function test/0 has no local return
test_dialyzer.erl:12:1: Function scp_send/3 has no local return

Removing all the client options, leaving the timeout only (sftp
option), dialyzer passes. Removing the timeout option, dialyzer gives
this:


  Checking whether the PLT /home/ryno/.dialyzer_plt is up-to-date...
yes
  Proceeding with analysis...
test_dialyzer.erl:4:1: Function test/0 has no local return
test_dialyzer.erl:12:1: Function scp_send/3 has no local return
test_dialyzer.erl:14:5: The call ssh_sftp:start_channel
         (Host :: [97 | 99 | 104 | 108 | 111 | 115 | 116, ...],
          [{'auth_methods',
            [98 | 99 | 101 | 105 | 107 | 108 | 112 | 117 | 121, ...]} |
           {'save_accepted_host', 'true'} |
           {'silently_accept_hosts', 'true'} |
           {'user', [97 | 98 | 100 | 110 | 111 | 121, ...]} |
           {'user_interaction', 'false'},
           ...]) breaks the contract 
          (ssh:open_socket(), [ssh:client_options() | sftp_option()]) -
>
             {'ok', pid(), ssh:connection_ref()} | {'error', reason()};
         (ssh:connection_ref(), [sftp_option()]) ->
             {'ok', pid()} |
             {'ok', pid(), ssh:connection_ref()} |
             {'error', reason()};
         (ssh:host(), [ssh:client_options() | sftp_option()]) ->
             {'ok', pid(), ssh:connection_ref()} | {'error', reason()}
in the 2nd argument
Unknown functions:
  erlang:get_module_info/1 (/tmp/test_dialyzer.erl:-1)
  erlang:get_module_info/2 (/tmp/test_dialyzer.erl:-1)
 done in 0m0.20s


In essence, the client options are not OK at all ...


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

-module(test_dialyzer).
-export([test/0]).

test() ->
    Host = "localhost",
    User = "anybody",
    Directory = "/tmp/",
    Res = scp_send(Host, User, Directory),
    io:fwrite("res ~p~n", [Res]).
    
	
scp_send(Host, User, Directory) ->
    case ssh_sftp:start_channel(Host, 
				[{timeout, 2000},     % sftp option
				 {auth_methods, "publickey"},    % common option
				 {user, User},                   % client option
				 {silently_accept_hosts, true},  % client option
				 {save_accepted_host, true},     % client option
				 {user_interaction, false}]) of  % client option
	{error, Reason} ->
	    %% lager:error("OPMET host ssh error ~p~n", [Reason]),
	    {error, Reason};
	{ok, Pid, ConnRef} ->
	    FullFileName = Directory ++ "remove",
	    Res = case ssh_sftp:write_file(Pid, FullFileName, <<"rubbish">>, 2000) of
		{error, Reason2} ->
		    {error, Reason2};
		ok ->
		    ok
	    end,
	    ssh_sftp:stop_channel(Pid),
	    ssh:close(ConnRef),
            timer:sleep(1000),
	    Res
    end.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

regards
Jouni

-- 
Jouni Rynö                         mailto://Jouni.Ryno@fmi.fi/
                                   http://space.fmi.fi/~ryno/
 Finnish Meteorological Institute  http://www.fmi.fi/
 Observation services                  
 P.O.BOX 503                       office desk!  (+358)-29-5394656
 FI-00101 Helsinki
 Finland                           private preferred (+358)-50-5302903

md5sum(the Ultimate Question of Life, The Universe, and Everything) = 
0000000000000000000000000000002A




More information about the erlang-questions mailing list