[vlc-devel] [PATCH] sftp: try to get username for ssh auth

Thomas Guillem thomas at gllm.fr
Tue Oct 31 11:06:21 CET 2017


Hello,

Thanks for the patch but it had been superseded by
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0c251bea6b5e632a405c1cb0954d16b4700e112a
that is a little simpler.

You can also check other improvements for sftp here:
http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=3c141fd2d80f8f88758d340154426b5e950cc3bd

http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=be8bc38f62dbc5b4376f5fb95a53fe74319bb453

http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8c8d691934866b91002e56168cb2985a9c651caf


Best regards,
Thomas.

On Thu, Oct 26, 2017, at 09:45, Ion Agorria wrote:
> Currently even user is provided, the dialog appears asking for user, in
> case of agent or public key should be tried before asking and only ask if
> fails
> ---
>  modules/access/sftp.c | 22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
> 
> diff --git a/modules/access/sftp.c b/modules/access/sftp.c
> index c119a223f8..b10bb9862d 100644
> --- a/modules/access/sftp.c
> +++ b/modules/access/sftp.c
> @@ -306,30 +306,42 @@ static int Open( vlc_object_t* p_this )
>          goto error;
>      }
>  
> +    /* Try to get username from URL and cmdline for ssh auth */
>      char* psz_userauthlist = NULL;
> +    const char* psz_current_username;
> +    if (credential_url.psz_username) {
> +        psz_current_username = credential_url.psz_username;
> +    } else {
> +        psz_current_username = var_InheritString(p_access, "sftp-user");
> +    }
>      do
>      {
> -        if (!credential.psz_username || !credential.psz_username[0])
> +        if (credential.psz_username) {
> +            psz_current_username = credential.psz_username;
> +        } 
> +        if (!psz_current_username || !psz_current_username[0]) {
> +            msg_Dbg( p_access, "sftp auth no username");
>              continue;
> +        }
>  
>          psz_userauthlist = libssh2_userauth_list( p_sys->ssh_session,
>          credential.psz_username, strlen( credential.psz_username ) );
>  
>          /* TODO: Follow PreferredAuthentications in ssh_config */
>  
>          if( strstr( psz_userauthlist, "publickey" ) != NULL &&
> -            ( AuthKeyAgent( p_access, credential.psz_username ) ==
> VLC_SUCCESS ||
> -              AuthPublicKey( p_access, psz_home, credential.psz_username
> ) == VLC_SUCCESS ) )
> +            ( AuthKeyAgent( p_access, psz_current_username ) ==
> VLC_SUCCESS ||
> +              AuthPublicKey( p_access, psz_home, psz_current_username )
> == VLC_SUCCESS ) )
>              break;
>          if( strstr( psz_userauthlist, "password" ) != NULL &&
>              libssh2_userauth_password( p_sys->ssh_session,
> -                                       credential.psz_username,
> +                                       psz_current_username,
>                                         credential.psz_password ) == 0 )
>          {
>              vlc_credential_store( &credential, p_access );
>              break;
>          }
>  
> -        msg_Warn( p_access, "sftp auth failed for %s",
> credential.psz_username );
> +        msg_Warn( p_access, "sftp auth failed for %s",
> psz_current_username );
>      } while( vlc_credential_get( &credential, p_access, "sftp-user",
>      "sftp-pwd",
>                                  _("SFTP authentication"),
>                                  _("Please enter a valid login and
>                                  password for "
> -- 
> 2.13.6
> 
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel


More information about the vlc-devel mailing list