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

Thomas Guillem thomas at gllm.fr
Thu Oct 17 13:30:58 CEST 2019


---
 modules/access/smb2.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/modules/access/smb2.c b/modules/access/smb2.c
index 923e6d57e04..99f2446401a 100644
--- a/modules/access/smb2.c
+++ b/modules/access/smb2.c
@@ -61,6 +61,13 @@
 static int Open(vlc_object_t *);
 static void Close(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 seriously consider to update your " \
+    "Windows / Samba server and disable the SMBv1 protocol since this protocol " \
+    "is not safe at all.")
+
 vlc_module_begin()
     set_shortname("smb2")
     set_description(N_("SMB2 / SMB3 input"))
@@ -71,6 +78,7 @@ vlc_module_begin()
     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", "smb2")
     set_callbacks(Open, Close)
 vlc_module_end()
@@ -603,6 +611,13 @@ Open(vlc_object_t *p_obj)
     struct smb2_url *smb2_url = NULL;
     char *var_domain = NULL;
 
+    if (var_InheritBool(p_obj, "smb-force-v1"))
+    {
+        msg_Warn(access, "SMB 2/3 disabled by the user, using *unsafe* SMB 1");
+        /* Return an error and use libdsm for the SMB 1 connection. */
+        return VLC_EGENERIC;
+    }
+
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
     access->p_sys = sys;
-- 
2.20.1



More information about the vlc-devel mailing list