Beispiel #1
0
/* Performs login with existing credentials and ask the user for new ones on
   failure */
static int login( access_t *p_access )
{
    access_sys_t *p_sys = p_access->p_sys;

    /* Try to authenticate on the remote machine */
    if( smb_connect( p_access ) != VLC_SUCCESS )
    {
        for( int i = 0; i < BDSM_LOGIN_DIALOG_RETRY; i++ )
        {
            login_dialog( p_access );
            if( smb_connect( p_access ) == VLC_SUCCESS )
                return VLC_SUCCESS;
        }

        msg_Err( p_access, "Unable to login with username = %s, domain = %s",
                   p_sys->creds.login, p_sys->creds.domain );
        return VLC_EGENERIC;
    }
    else if( smb_session_is_guest( p_sys->p_session )  )
        msg_Warn( p_access, "Login failure but you were logged in as a Guest");

    return VLC_SUCCESS;
}
Beispiel #2
0
/* Performs login with existing credentials and ask the user for new ones on
   failure */
static int login( stream_t *p_access )
{
    int i_ret = VLC_EGENERIC;
    access_sys_t *p_sys = p_access->p_sys;
    vlc_credential credential;
    char *psz_var_domain;
    const char *psz_login, *psz_password, *psz_domain;
    bool b_guest = false;

    vlc_credential_init( &credential, &p_sys->url );
    psz_var_domain = var_InheritString( p_access, "smb-domain" );
    credential.psz_realm = psz_var_domain ? psz_var_domain : NULL;

    vlc_credential_get( &credential, p_access, "smb-user", "smb-pwd",
                        NULL, NULL );

    if( !credential.psz_username )
    {
        psz_login = "******";
        psz_password = "";
        b_guest = true;
    }
    else
    {
        psz_login = credential.psz_username;
        psz_password = credential.psz_password;
    }
    psz_domain = credential.psz_realm ? credential.psz_realm : p_sys->netbios_name;

    /* Try to authenticate on the remote machine */
    if( smb_connect( p_access, psz_login, psz_password, psz_domain )
                     != VLC_SUCCESS )
    {
        while( vlc_credential_get( &credential, p_access, "smb-user", "smb-pwd",
                                   SMB_LOGIN_DIALOG_TITLE,
                                   SMB_LOGIN_DIALOG_TEXT, p_sys->netbios_name ) )
        {
            b_guest = false;
            psz_login = credential.psz_username;
            psz_password = credential.psz_password;
            psz_domain = credential.psz_realm ? credential.psz_realm
                                              : p_sys->netbios_name;
            if( smb_connect( p_access, psz_login, psz_password, psz_domain )
                             == VLC_SUCCESS )
                goto success;
        }

        msg_Err( p_access, "Unable to login" );
        goto error;
    }
    else if( smb_session_is_guest( p_sys->p_session ) == 1 )
    {
        msg_Warn( p_access, "Login failure but you were logged in as a Guest");
        b_guest = true;
    }

success:
    msg_Warn( p_access, "Creds: username = '******', domain = '%s'",
             psz_login, psz_domain );
    if( !b_guest )
        vlc_credential_store( &credential, p_access );

    i_ret = VLC_SUCCESS;
error:
    vlc_credential_clean( &credential );
    free( psz_var_domain );
    return i_ret;
}