[vlc-commits] sftp: add options for username and password
Petri Hintukainen
git at videolan.org
Fri Mar 13 16:02:48 CET 2015
vlc | branch: master | Petri Hintukainen <phintuka at gmail.com> | Fri Mar 13 15:25:56 2015 +0200| [8980e78cb120834928c0d6bef31db92f628eb8b8] | committer: Jean-Baptiste Kempf
sftp: add options for username and password
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=8980e78cb120834928c0d6bef31db92f628eb8b8
---
modules/access/sftp.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/modules/access/sftp.c b/modules/access/sftp.c
index a63ca95..cbe9a5c 100644
--- a/modules/access/sftp.c
+++ b/modules/access/sftp.c
@@ -52,6 +52,12 @@ static void Close( vlc_object_t* );
#define PORT_LONGTEXT N_("SFTP port number to use on the server")
#define MTU_TEXT N_("Read size")
#define MTU_LONGTEXT N_("Size of the request for reading access")
+#define USER_TEXT N_("SFTP user name")
+#define USER_LONGTEXT N_("Sets the username for the connection, " \
+ "if no username or password are set in the url.")
+#define PASS_TEXT N_("SFTP password")
+#define PASS_LONGTEXT N_("Sets the password for the connection, " \
+ "if no username or password are set in the url.")
vlc_module_begin ()
set_shortname( "SFTP" )
@@ -61,6 +67,8 @@ vlc_module_begin ()
set_subcategory( SUBCAT_INPUT_ACCESS )
add_integer( "sftp-readsize", 8192, MTU_TEXT, MTU_LONGTEXT, true )
add_integer( "sftp-port", 22, PORT_TEXT, PORT_LONGTEXT, true )
+ add_string( "sftp-user", NULL, USER_TEXT, USER_LONGTEXT, false )
+ add_password( "sftp-pwd", NULL, PASS_TEXT, PASS_LONGTEXT, false )
add_shortcut( "sftp" )
set_callbacks( Open, Close )
vlc_module_end ()
@@ -120,13 +128,19 @@ static int Open( vlc_object_t* p_this )
goto error;
}
- /* If the user name is empty, ask the user */
- if( !EMPTY_STR( url.psz_username ) && url.psz_password )
- {
+ /* get user/password from url or options */
+ if( !EMPTY_STR( url.psz_username ) )
psz_username = strdup( url.psz_username );
+ else
+ psz_username = var_InheritString( p_access, "sftp-user" );
+
+ if( url.psz_password )
psz_password = strdup( url.psz_password );
- }
else
+ psz_password = var_InheritString( p_access, "sftp-pwd" );
+
+ /* If the user name or password is empty, ask the user */
+ if( EMPTY_STR( psz_username ) || !psz_password )
{
dialog_Login( p_access, &psz_username, &psz_password,
_("SFTP authentication"),
More information about the vlc-commits
mailing list