dsm: don't store domain when it doesn't come from the user

This commit is contained in:
Thomas Guillem 2016-01-24 11:40:42 +01:00
parent e39d63e08e
commit 1ec4edf04a

View File

@ -323,7 +323,7 @@ static int login( access_t *p_access )
vlc_UrlParse( &url, p_access->psz_url ); vlc_UrlParse( &url, p_access->psz_url );
vlc_credential_init( &credential, &url ); vlc_credential_init( &credential, &url );
psz_var_domain = var_InheritString( p_access, "smb-domain" ); psz_var_domain = var_InheritString( p_access, "smb-domain" );
credential.psz_realm = psz_var_domain ? psz_var_domain : p_sys->netbios_name; credential.psz_realm = psz_var_domain ? psz_var_domain : NULL;
vlc_credential_get( &credential, p_access, "smb-user", "smb-pwd", vlc_credential_get( &credential, p_access, "smb-user", "smb-pwd",
NULL, NULL ); NULL, NULL );
@ -339,7 +339,7 @@ static int login( access_t *p_access )
psz_login = credential.psz_username; psz_login = credential.psz_username;
psz_password = credential.psz_password; psz_password = credential.psz_password;
} }
psz_domain = credential.psz_realm; psz_domain = credential.psz_realm ? credential.psz_realm : p_sys->netbios_name;
/* Try to authenticate on the remote machine */ /* Try to authenticate on the remote machine */
if( smb_connect( p_access, psz_login, psz_password, psz_domain ) if( smb_connect( p_access, psz_login, psz_password, psz_domain )
@ -352,7 +352,8 @@ static int login( access_t *p_access )
b_guest = false; b_guest = false;
psz_login = credential.psz_username; psz_login = credential.psz_username;
psz_password = credential.psz_password; psz_password = credential.psz_password;
psz_domain = credential.psz_realm; psz_domain = credential.psz_realm ? credential.psz_realm
: p_sys->netbios_name;
if( smb_connect( p_access, psz_login, psz_password, psz_domain ) if( smb_connect( p_access, psz_login, psz_password, psz_domain )
== VLC_SUCCESS ) == VLC_SUCCESS )
goto success; goto success;
@ -375,7 +376,9 @@ success:
{ {
if( asprintf( &p_sys->psz_user_opt, "smb-user=%s", psz_login ) == -1 ) if( asprintf( &p_sys->psz_user_opt, "smb-user=%s", psz_login ) == -1 )
p_sys->psz_user_opt = NULL; p_sys->psz_user_opt = NULL;
if( asprintf( &p_sys->psz_domain_opt, "smb-domain=%s", psz_domain ) == -1 ) if( credential.psz_realm != NULL
&& asprintf( &p_sys->psz_domain_opt, "smb-domain=%s",
credential.psz_realm ) == -1 )
p_sys->psz_domain_opt = NULL; p_sys->psz_domain_opt = NULL;
if( !vlc_credential_store( &credential ) if( !vlc_credential_store( &credential )