Browse Source

keystore: change vlc_credential_get return type

No functional changes.

Refs #27027
pull/136/head
Thomas Guillem 4 years ago
committed by Rémi Denis-Courmont
parent
commit
9edef14aa2
  1. 6
      include/vlc_keystore.h
  2. 2
      modules/access/dsm/access.c
  3. 2
      modules/access/ftp.c
  4. 4
      modules/access/http.c
  5. 8
      modules/access/http/access.c
  6. 4
      modules/access/live555.cpp
  7. 6
      modules/access/samba.c
  8. 2
      modules/access/sftp.c
  9. 2
      modules/access/smb2.c
  10. 6
      modules/access/unc.c
  11. 4
      modules/demux/adaptive/http/HTTPConnection.cpp
  12. 10
      src/misc/keystore.c
  13. 2
      test/src/misc/keystore.c

6
include/vlc_keystore.h

@ -231,11 +231,11 @@ vlc_credential_clean(vlc_credential *p_credential);
* keystore or the dialog
* @param psz_dialog_fmt dialog text using format
*
* @return true if vlc_credential.psz_username and vlc_credential.psz_password
* are valid, otherwise this function should not be called again.
* @return 0 if vlc_credential.psz_username and vlc_credential.psz_password
* are valid, or a negative errno code.
*/
VLC_API bool
VLC_API int
vlc_credential_get(vlc_credential *p_credential, vlc_object_t *p_parent,
const char *psz_option_username,
const char *psz_option_password,

2
modules/access/dsm/access.c

@ -522,7 +522,7 @@ static int login( stream_t *p_access )
while( connect_err == EACCES
&& vlc_credential_get( &credential, p_access, "smb-user", "smb-pwd",
SMB1_LOGIN_DIALOG_TITLE,
SMB_LOGIN_DIALOG_TEXT, p_sys->netbios_name ) )
SMB_LOGIN_DIALOG_TEXT, p_sys->netbios_name ) == 0 )
{
b_guest = false;
psz_login = credential.psz_username;

2
modules/access/ftp.c

@ -471,7 +471,7 @@ static int Login( vlc_object_t *p_access, access_sys_t *p_sys, const char *path
}
while( vlc_credential_get( &credential, p_access, "ftp-user", "ftp-pwd",
LOGIN_DIALOG_TITLE, LOGIN_DIALOG_TEXT,
url.psz_host ) );
url.psz_host ) == 0 );
if( b_logged )
{

4
modules/access/http.c

@ -259,7 +259,7 @@ static int Open( vlc_object_t *p_this )
p_sys->b_reconnect = var_InheritBool( p_access, "http-reconnect" );
if( vlc_credential_get( &credential, p_access, NULL, NULL, NULL, NULL ) )
if( vlc_credential_get( &credential, p_access, NULL, NULL, NULL, NULL ) == 0 )
{
p_sys->url.psz_username = (char *) credential.psz_username;
p_sys->url.psz_password = (char *) credential.psz_password;
@ -297,7 +297,7 @@ connect:
if( vlc_credential_get( &credential, p_access, NULL, NULL,
_("HTTP authentication"),
_("Please enter a valid login name and a "
"password for realm %s."), p_sys->auth.psz_realm ) )
"password for realm %s."), p_sys->auth.psz_realm ) == 0 )
{
p_sys->psz_username = strdup(credential.psz_username);
p_sys->psz_password = strdup(credential.psz_password);

8
modules/access/http/access.c

@ -190,7 +190,7 @@ static int Open(vlc_object_t *obj)
if (sys->resource == NULL)
goto error;
if (vlc_credential_get(&crd, obj, NULL, NULL, NULL, NULL))
if (vlc_credential_get(&crd, obj, NULL, NULL, NULL, NULL) == 0)
vlc_http_res_set_login(sys->resource,
crd.psz_username, crd.psz_password);
@ -207,9 +207,9 @@ static int Open(vlc_object_t *obj)
if (psz_realm == NULL)
break;
crd.psz_realm = psz_realm;
if (!vlc_credential_get(&crd, obj, NULL, NULL, _("HTTP authentication"),
_("Please enter a valid login name and "
"a password for realm %s."), crd.psz_realm))
if (vlc_credential_get(&crd, obj, NULL, NULL, _("HTTP authentication"),
_("Please enter a valid login name and "
"a password for realm %s."), crd.psz_realm) != 0)
break;
vlc_http_res_set_login(sys->resource,

4
modules/access/live555.cpp

@ -623,7 +623,7 @@ static int Connect( demux_t *p_demux )
/* Credentials can be NULL since they may not be needed */
if( vlc_credential_get( &credential, p_demux, "rtsp-user", "rtsp-pwd",
NULL, NULL) )
NULL, NULL) == 0 )
{
psz_user = credential.psz_username;
psz_pwd = credential.psz_password;
@ -678,7 +678,7 @@ describe:
if( vlc_credential_get( &credential, p_demux, "rtsp-user", "rtsp-pwd",
_("RTSP authentication"),
_("Please enter a valid login name and a password.") ) )
_("Please enter a valid login name and a password.") ) == 0 )
{
psz_user = credential.psz_username;
psz_pwd = credential.psz_password;

6
modules/access/samba.c

@ -347,9 +347,9 @@ static int Open(vlc_object_t *obj)
break;
errno = 0;
if (!vlc_credential_get(&credential, access, "smb-user",
"smb-pwd", SMB_LOGIN_DIALOG_TITLE,
SMB_LOGIN_DIALOG_TEXT, url.psz_host))
if (vlc_credential_get(&credential, access, "smb-user",
"smb-pwd", SMB_LOGIN_DIALOG_TITLE,
SMB_LOGIN_DIALOG_TEXT, url.psz_host) != 0)
break;
}

2
modules/access/sftp.c

@ -463,7 +463,7 @@ static int Open( vlc_object_t* p_this )
} while( vlc_credential_get( &credential, p_access, "sftp-user", "sftp-pwd",
_("SFTP authentication"),
_("Please enter a valid login and password for "
"the SFTP connection to %s"), url.psz_host ) );
"the SFTP connection to %s"), url.psz_host ) == 0 );
/* Create the sftp session */
p_sys->sftp_session = libssh2_sftp_init( p_sys->ssh_session );

2
modules/access/smb2.c

@ -864,7 +864,7 @@ Open(vlc_object_t *p_obj)
while (VLC_SMB2_STATUS_DENIED(ret)
&& vlc_credential_get(&credential, access, "smb-user", "smb-pwd",
SMB_LOGIN_DIALOG_TITLE, SMB_LOGIN_DIALOG_TEXT,
sys->encoded_url.psz_host))
sys->encoded_url.psz_host) == 0)
ret = vlc_smb2_connect_open_share(access, url, &credential);
free(resolved_host);
free(url);

6
modules/access/unc.c

@ -326,9 +326,9 @@ static int Open(vlc_object_t *obj)
break;
errno = 0;
if (!vlc_credential_get(&credential, access, "smb-user",
"smb-pwd", SMB_LOGIN_DIALOG_TITLE,
SMB_LOGIN_DIALOG_TEXT, url.psz_host))
if (vlc_credential_get(&credential, access, "smb-user",
"smb-pwd", SMB_LOGIN_DIALOG_TITLE,
SMB_LOGIN_DIALOG_TEXT, url.psz_host) != 0)
break;
}

4
modules/demux/adaptive/http/HTTPConnection.cpp

@ -311,7 +311,7 @@ RequestStatus LibVLCHTTPConnection::request(const std::string &path,
vlc_UrlParse(&crd_url, params.getUrl().c_str());
vlc_credential_init(&crd, &crd_url);
if (vlc_credential_get(&crd, p_object, NULL, NULL, NULL, NULL))
if (vlc_credential_get(&crd, p_object, NULL, NULL, NULL, NULL) == 0)
{
vlc_http_res_set_login(source->http_res,
crd.psz_username, crd.psz_password);
@ -337,7 +337,7 @@ RequestStatus LibVLCHTTPConnection::request(const std::string &path,
if (vlc_credential_get(&crd, p_object, NULL, NULL,
_("HTTP authentication"),
_("Please enter a valid login name and a "
"password for realm %s."), psz_realm))
"password for realm %s."), psz_realm) == 0)
{
if(source->abortandlogin(crd.psz_username, crd.psz_password))
{

10
src/misc/keystore.c

@ -372,7 +372,7 @@ vlc_credential_clean(vlc_credential *p_credential)
}
#undef vlc_credential_get
bool
int
vlc_credential_get(vlc_credential *p_credential, vlc_object_t *p_parent,
const char *psz_option_username,
const char *psz_option_password,
@ -385,7 +385,7 @@ vlc_credential_get(vlc_credential *p_credential, vlc_object_t *p_parent,
if (!is_url_valid(p_url))
{
msg_Err(p_parent, "vlc_credential_get: invalid url");
return false;
return -EINVAL;
}
p_credential->b_from_keystore = false;
@ -457,7 +457,7 @@ vlc_credential_get(vlc_credential *p_credential, vlc_object_t *p_parent,
default:
case GET_FROM_DIALOG:
if (!psz_dialog_title || !psz_dialog_fmt)
return false;
return -ENOENT;
char *psz_dialog_username = NULL;
char *psz_dialog_password = NULL;
va_list ap;
@ -483,7 +483,7 @@ vlc_credential_get(vlc_credential *p_credential, vlc_object_t *p_parent,
if (i_ret != 1)
{
p_credential->psz_username = p_credential->psz_password = NULL;
return false;
return -ENOENT;
}
p_credential->psz_username = p_credential->psz_dialog_username;
@ -495,7 +495,7 @@ vlc_credential_get(vlc_credential *p_credential, vlc_object_t *p_parent,
break;
}
}
return is_credential_valid(p_credential);
return is_credential_valid(p_credential) ? 0 : -ENOENT;
}
#undef vlc_credential_store

2
test/src/misc/keystore.c

@ -298,7 +298,7 @@ test(vlc_object_t *p_obj, unsigned int i_id, const struct testcase *p_test)
bool b_found = false;
while (vlc_credential_get(&credential, p_obj, psz_opt_user, psz_opt_pwd,
"test authentication", "this a test"))
"test authentication", "this a test") == 0)
{
bool realm_match = !p_test->result.psz_realm
|| (credential.psz_realm

Loading…
Cancel
Save