[vlc-commits] [Git][videolan/vlc][3.0.x] 2 commits: smb2: use correct error code
Jean-Baptiste Kempf (@jbk)
gitlab at videolan.org
Thu Jul 6 12:08:28 UTC 2023
Jean-Baptiste Kempf pushed to branch 3.0.x at VideoLAN / VLC
Commits:
049a6f25 by Thomas Guillem at 2023-07-06T11:51:19+00:00
smb2: use correct error code
(cherry picked from commit ea7aeedcfce6b82a9a14dde9b9d5f6521861af58)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
- - - - -
ff057385 by Thomas Guillem at 2023-07-06T11:51:19+00:00
smb2: fix anonymous login with last Windows update
Fixes #28187
(cherry picked from commit 167ab59642dae748f704d08c7f8be77bf00f1d1a)
Signed-off-by: Thomas Guillem <thomas at gllm.fr>
- - - - -
1 changed file:
- modules/access/smb2.c
Changes:
=====================================
modules/access/smb2.c
=====================================
@@ -663,7 +663,8 @@ error:
static int
vlc_smb2_connect_open_share(stream_t *access, const char *url,
- const vlc_credential *credential)
+ const vlc_credential *credential,
+ bool guest_with_valid_passwd)
{
struct access_sys *sys = access->p_sys;
@@ -673,7 +674,7 @@ vlc_smb2_connect_open_share(stream_t *access, const char *url,
if (sys->smb2 == NULL)
{
msg_Err(access, "smb2_init_context failed");
- return -1;
+ return -ENOMEM;
}
smb2_url = smb2_parse_url(sys->smb2, url);
@@ -692,7 +693,7 @@ vlc_smb2_connect_open_share(stream_t *access, const char *url,
{
username = "Guest";
/* A NULL password enable ntlmssp anonymous login */
- password = NULL;
+ password = guest_with_valid_passwd ? "" : NULL;
}
smb2_set_security_mode(sys->smb2, SMB2_NEGOTIATE_SIGNING_ENABLED);
@@ -854,13 +855,27 @@ Open(vlc_object_t *p_obj)
* keystore/user interaction) */
vlc_credential_get(&credential, access, "smb-user", "smb-pwd", NULL,
NULL);
- ret = vlc_smb2_connect_open_share(access, url, &credential);
+ ret = vlc_smb2_connect_open_share(access, url, &credential, false);
+ if (ret == -EINVAL && credential.psz_username == NULL)
+ {
+ /* Since last Windows 11 update (KB5026436), Windows SMB servers need a
+ * valid Auth (user + password) even for a guest/anonymous login. The
+ * server will return 'STATUS_INVALID_PARAMETER' (so, libsmb2 will
+ * return '-EINVAL') if the password is invalid. Therefore, try to
+ * connect again with a valid password in that case.
+ *
+ * We don't try to connect with a valid password on the first try since
+ * it seems to break anonymous login with other samba servers (but
+ * samba.c doesn't have this problem so this might be libsmb2 issue).
+ * */
+ ret = vlc_smb2_connect_open_share(access, url, &credential, true);
+ }
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))
- ret = vlc_smb2_connect_open_share(access, url, &credential);
+ ret = vlc_smb2_connect_open_share(access, url, &credential, false);
free(resolved_host);
free(url);
if (ret == 0)
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ba02ef605699a3d659fb24286284ed66b0f91dc5...ff0573857d5f7bbcc1c4330dfa705f842cc19d83
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/ba02ef605699a3d659fb24286284ed66b0f91dc5...ff0573857d5f7bbcc1c4330dfa705f842cc19d83
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list