[vlc-devel] [PATCH] dsm: add "smb-force-v1" option

Steve Lhomme robux4 at ycbcr.xyz
Thu Oct 17 14:40:04 CEST 2019


LGTM without the debug parts.

On 2019-10-17 14:36, Thomas Guillem wrote:
> 
> 
> On Thu, Oct 17, 2019, at 14:32, Thomas Guillem wrote:
>> If this option is enabled, libdsm will be probed before libsmb2. Use at your
>> own risk, this option should be always disabled by default and specifically
>> requested by the user.
>> ---
>>   modules/access/dsm/access.c | 38 ++++++++++++++++++++++++++++++++++---
>>   modules/access/samba.c      |  1 +
>>   modules/access/smb2.c       |  1 +
>>   3 files changed, 37 insertions(+), 3 deletions(-)
>>
>> diff --git a/modules/access/dsm/access.c b/modules/access/dsm/access.c
>> index 776925c9eeb..7cf46cf5937 100644
>> --- a/modules/access/dsm/access.c
>> +++ b/modules/access/dsm/access.c
>> @@ -58,7 +58,15 @@ int bdsm_SdOpen( vlc_object_t * );
>>   void bdsm_SdClose( vlc_object_t * );
>>   int bdsm_sd_probe_Open( vlc_object_t * );
>>   
>> -static int Open( vlc_object_t * );
>> +#define SMB_FORCE_V1_TEXT N_("Force the SMBv1 protocol (At your own
>> risk)")
>> +#define SMB_FORCE_V1_LONGTEXT \
>> +    N_("Enable it, at your own risk, if you can't connect to Windows
>> shares. " \
>> +    "If this option is needed, you should consider updating your
>> Windows / " \
>> +    "Samba server and disabling the SMBv1 protocol as using this
>> protocol " \
>> +    "has security implications.")
>> +
>> +static int OpenNotForced( vlc_object_t * );
>> +static int OpenForced( vlc_object_t * );
>>   static void Close( vlc_object_t * );
>>   
>>   VLC_SD_PROBE_HELPER( "dsm", N_("Windows networks"), SD_CAT_LAN )
>> @@ -69,14 +77,21 @@ vlc_module_begin ()
>>       set_shortname( "dsm" )
>>       set_description( N_("libdsm SMB input") )
>>       set_help(BDSM_HELP)
>> -    set_capability( "access", 20 )
>>       set_category( CAT_INPUT )
>>       set_subcategory( SUBCAT_INPUT_ACCESS )
>>       add_string( "smb-user", NULL, SMB_USER_TEXT, SMB_USER_LONGTEXT,
>> false )
>>       add_password("smb-pwd", NULL, SMB_PASS_TEXT, SMB_PASS_LONGTEXT)
>>       add_string( "smb-domain", NULL, SMB_DOMAIN_TEXT,
>> SMB_DOMAIN_LONGTEXT, false )
>> +    add_bool( "smb-force-v1", false, SMB_FORCE_V1_TEXT,
>> SMB_FORCE_V1_LONGTEXT, false )
>>       add_shortcut( "smb", "cifs" )
>> -    set_callbacks( Open, Close )
>> +
>> +    set_capability( "access", 22 )
>> +    set_callbacks( OpenForced, Close )
>> +
>> +    add_submodule()
>> +        set_capability( "access", 20 )
>> +        set_callbacks( OpenNotForced, Close )
>> +        add_shortcut( "smb", "cifs" )
>>   
>>       add_submodule()
>>           add_shortcut( "dsm-sd" )
>> @@ -196,6 +211,23 @@ static int Open( vlc_object_t *p_this )
>>           return VLC_EGENERIC;
>>   }
>>   
>> +static int OpenForced( vlc_object_t *p_this )
>> +{
>> +    if( !var_InheritBool( p_this , "smb-force-v1" ) )
>> +        return VLC_EGENERIC;
>> +
>> +    msg_Warn( p_this, "SMB 2/3 disabled by the user, using *unsafe*
>> SMB 1" );
>> +    return Open( p_this );
>> +}
>> +
>> +static int OpenNotForced( vlc_object_t *p_this )
>> +{
>> +    if( var_InheritBool( p_this , "smb-force-v1" ) )
>> +        return VLC_EGENERIC; /* OpenForced should have breen probed
>> first */
>> +
>> +    return Open( p_this );
>> +}
>> +
>>   
>> /*****************************************************************************
>>    * Close: free unused data structures
>>    
>> *****************************************************************************/
>> diff --git a/modules/access/samba.c b/modules/access/samba.c
>> index 9f397c44b7d..cd7663c29ca 100644
>> --- a/modules/access/samba.c
>> +++ b/modules/access/samba.c
>> @@ -237,6 +237,7 @@ static void smb_auth(const char *srv, const char
>> *shr, char *wg, int wglen,
>>   
>>   static int Open(vlc_object_t *obj)
>>   {
>> +return -1;
> 
> left-over debug
> 
>>       stream_t *access = (stream_t *)obj;
>>       vlc_url_t url;
>>       vlc_credential credential;
>> diff --git a/modules/access/smb2.c b/modules/access/smb2.c
>> index 923e6d57e04..da0f0ca02c5 100644
>> --- a/modules/access/smb2.c
>> +++ b/modules/access/smb2.c
>> @@ -598,6 +598,7 @@ vlc_smb2_resolve(stream_t *access, const char
>> *host, unsigned port)
>>   static int
>>   Open(vlc_object_t *p_obj)
>>   {
>> +    fprintf(stderr, "Open\n");
> 
> left-over debug
> 
>>       stream_t *access = (stream_t *)p_obj;
>>       struct access_sys *sys = vlc_obj_calloc(p_obj, 1, sizeof (*sys));
>>       struct smb2_url *smb2_url = NULL;
>> -- 
>> 2.20.1
>>
>> _______________________________________________
>> vlc-devel mailing list
>> To unsubscribe or modify your subscription options:
>> https://mailman.videolan.org/listinfo/vlc-devel
> _______________________________________________
> 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