Bug 453090 - Can't connect to a Windows samba share with samba-libs 4.16
Summary: Can't connect to a Windows samba share with samba-libs 4.16
Status: RESOLVED FIXED
Alias: None
Product: kio-extras
Classification: Frameworks and Libraries
Component: Samba (show other bugs)
Version: 21.12.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
: 457661 (view as bug list)
Depends on:
Blocks:
 
Reported: 2022-04-27 16:22 UTC by Jiri Palecek
Modified: 2022-09-08 14:06 UTC (History)
10 users (show)

See Also:
Latest Commit:
Version Fixed In: 22.08.2


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Palecek 2022-04-27 16:22:53 UTC
Hello

after upgrading samba-libs from 4.13 to 4.16, I can't display files on my windows computer from linux in dolphin anymore. I open the smb:// URL, the remote system shows up, then I click on it and it shows an error "Soubor nebo složka smb://laptop-jvsbr4b4.local/ neexistuje." (File or directory doesn't exist).

I bisected this in samba down to this commit:

commit 34771e1931587807d0395c7ac7f4be18654997f4 (refs/bisect/bad)
Author: Elia Geretto <elia.f.geretto@gmail.com>
Date:   Fri Mar 11 19:32:30 2022 +0100

    s3:libsmb: Fix errno for failed authentication in SMBC_server_internal()
    
    In SMBC_server_internal(), when authentication fails, the errno value is
    currently hard-coded to EPERM, while it should be EACCES instead. Use the
    NT_STATUS map to set the appropriate value.
    
    This bug was found because it breaks listing printers protected by
    authentication in GNOME Control Panel.
    
    BUG: https://bugzilla.samba.org/show_bug.cgi?id=14983
    
    Signed-off-by: Elia Geretto <elia.f.geretto@gmail.com>
    Reviewed-by: Jeremy Allison <jra@samba.org>
    Reviewed-by: Volker Lendecke <vl@samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra@samba.org>
    Autobuild-Date(master): Wed Mar 16 19:44:18 UTC 2022 on sn-devel-184
    
    (cherry picked from commit 70b9977a46e5242174b4461a7f49d5f640c1db62)

diff --git a/source3/libsmb/libsmb_server.c b/source3/libsmb/libsmb_server.c
index b92477c88fe..09d27868c0e 100644
--- a/source3/libsmb/libsmb_server.c
+++ b/source3/libsmb/libsmb_server.c
@@ -572,7 +572,7 @@ SMBC_server_internal(TALLOC_CTX *ctx,
                    !NT_STATUS_IS_OK(cli_session_setup_anon(c))) {
 
                         cli_shutdown(c);
-                        errno = EPERM;
+                       errno = map_errno_from_nt_status(status);
                         return NULL;
                 }
        }

The debugging messages from kio are:

kf.kio.slaves.smb: open "smb:///" url-type: 1 dirfd: -1 errNum: 111
kf.kio.slaves.smb: QUrl("smb://")
kf.kio.slaves.smb: QUrl("smb://laptop-jvsbr4b4.kio-discovery-wsd/")
kf.kio.slaves.smb: checkURL  QUrl("smb://laptop-jvsbr4b4.kio-discovery-wsd/")
kf.kio.slaves.smb: Resolved DNSSD name: "laptop-jvsbr4b4.local"
kf.kio.slaves.smb: checkURL return3  QUrl("smb://laptop-jvsbr4b4.local/")
kf.kio.slaves.smb: QUrl("smb://laptop-jvsbr4b4.local/")
kf.kio.slaves.smb: checkURL  QUrl("smb://laptop-jvsbr4b4.local/")
kf.kio.slaves.smb: checkURL return3  QUrl("smb://laptop-jvsbr4b4.local/")
kf.kio.slaves.smb: updateCache  "/"
kf.kio.slaves.smb: Starting discovery.
kf.kio.slaves.smb: auth_smbc_get_dat: set user= jirka , workgroup= WORKGROUP  server= laptop-jvsbr4b4.local , share= IPC$
kf.kio.slaves.smb: updateCache  "/IPC$"
kf.kio.slaves.smb: libsmb-auth-callback URL: QUrl("smb://laptop-jvsbr4b4.local/IPC$")
kf.kio.slaves.smb: auth_smbc_get_dat: set user= jirka , workgroup= WORKGROUP  server= laptop-jvsbr4b4.local , share= IPC$
kf.kio.slaves.smb: updateCache  "/IPC$"
kf.kio.slaves.smb: libsmb-auth-callback URL: QUrl("smb://laptop-jvsbr4b4.local/IPC$")
kf.kio.slaves.smb: open "smb://laptop-jvsbr4b4.local/" url-type: 2 dirfd: -1 errNum: 22
kf.kio.slaves.smb: Discovery finished.
kf.kio.slaves.smb: reporting generic error: 22
kf.kio.slaves.smb: errNum 22
kf.kio.core: "Soubor nebo složka smb://laptop-jvsbr4b4.local/ neexistuje."

SOFTWARE/OS VERSIONS
Windows: 10
Linux: 5.16.18
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version:
Comment 1 Harald Sitter 2022-04-27 16:47:46 UTC
I take it your credentials are correct? If so please file this upstream at bugzilla.samba.org you are getting EINVAL which seems an entirely unreasonable return value there.
Comment 2 Jiri Palecek 2022-04-27 21:41:22 UTC
(In reply to Harald Sitter from comment #1)
> I take it your credentials are correct? If so please file this upstream at
> bugzilla.samba.org you are getting EINVAL which seems an entirely
> unreasonable return value there.

No, these credentials are, in fact, wrong. I need to connect to the system as a different user, but that should be no problem, shouldn't it? It used to pop up a box where I entered a username/password, and often it just connects right away.

Another problem is that I don't have a Samba bugzilla account.
Comment 3 Harald Sitter 2022-04-27 21:46:23 UTC
Well, upstream shouldn't break compatibility there. We handle both EPERM and EACCESS so even the commit message says things should remain working, but they do not so that's an upstream regression from where I'm standing.
Comment 4 Jiri Palecek 2022-04-27 21:56:54 UTC
A similar problem with nautilus was already discussed here: https://bugzilla.samba.org/show_bug.cgi?id=14983

They resolved it by handling/ignoring EINVAL returns:
https://gitlab.gnome.org/GNOME/gvfs/-/issues/611
Comment 5 Stefan Schmid 2022-05-16 10:15:12 UTC
The Samba team has backported the change, and that this change will be reverted is very unlikely.
https://github.com/samba-team/samba/commits/samba-4.15.7/source3/libsmb/libsmb_server.c

Please adjust your code in KIO/Dolphin. I'm sure I'm not the only user who depends on a working implementation of smb in Dolphin.
Comment 6 Nate Graham 2022-05-16 16:06:52 UTC
I guess this is one of those unpleasant situations where upstream did something naughty and broke client software, so client software needs to deal with it. Shouldn't happen... but does happen. :(
Comment 7 Mihai DONȚU 2022-05-19 11:23:23 UTC
I can confirm the issue exists in Fedora 36 (plasma 5.24.5, frameworks 5.93.0, samba 4.16.1-4).
Comment 8 Bug Janitor Service 2022-06-22 09:46:05 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/kio-extras/-/merge_requests/165
Comment 9 Stefan Schmid 2022-06-22 11:00:18 UTC
(In reply to Bug Janitor Service from comment #8)
> A possibly relevant merge request was started @
> https://invent.kde.org/network/kio-extras/-/merge_requests/165
On my installation this patch works.
Thank you. :)
Comment 10 derek-shnosh 2022-08-04 17:56:04 UTC
Commenting to advise this bit me with samba-libs 4.15.9.

```
Operating System: Kubuntu 22.04
KDE Plasma Version: 5.24.6
KDE Frameworks Version: 5.95.0
Qt Version: 5.15.3
Kernel Version: 5.15.0-43-generic (64-bit)
Samba version: 4.15.9
```
Comment 11 Harald Sitter 2022-08-10 09:34:37 UTC
*** Bug 457661 has been marked as a duplicate of this bug. ***
Comment 12 Niels 2022-08-10 09:42:34 UTC
I'm experiencing the bug with 4.16.x too, but I also had the exact same issue with 4.15.x. I actually upgraded from 4.15.x to 4.16.x in Gentoo in the hope this would resolve the issue, but it did not.
Comment 13 Stefan Schmid 2022-08-11 07:32:56 UTC
How long are you going to fight your little ideology war on the backs of your users?

The Samba developers are not going to reverse this change and they are not going to change their ways just because you leave your users alone with this bug. There is a "merge request" that solves the current problem and still nothing happens here...

If you have a problem with the Samba developers then please discuss it with them and don't take your users hostage.

Translated with www.DeepL.com/Translator (free version)
Comment 14 Harald Sitter 2022-09-06 12:58:06 UTC
Git commit 95ebf9a66c4f503dd41205abadd7a522e758d974 by Harald Sitter, on behalf of Anthony Hung.
Committed on 06/09/2022 at 12:54.
Pushed by sitter into branch 'release/22.08'.

smb/kio_smb_browse: Check error code `EINVAL` to prompt the password dialog

With `samba-libs` >= 4.16, when user connect to the windows file sharing with incorrect user credential, the error code is `EINVAL`.

The user should get the password dialog to enter username and password if the error code is `EINVAL`.

Reference URL:
https://bugzilla.samba.org/show_bug.cgi?id=14983
https://gitlab.gnome.org/GNOME/gvfs/-/issues/611

M  +1    -1    smb/kio_smb_browse.cpp

https://invent.kde.org/network/kio-extras/commit/95ebf9a66c4f503dd41205abadd7a522e758d974
Comment 15 Harald Sitter 2022-09-06 12:59:16 UTC
Git commit eea1ecae3624c90b63a0c1378313fe8d26b00db1 by Harald Sitter, on behalf of Anthony Hung.
Committed on 06/09/2022 at 12:59.
Pushed by sitter into branch 'master'.

smb/kio_smb_browse: Check error code `EINVAL` to prompt the password dialog

With `samba-libs` >= 4.16, when user connect to the windows file sharing with incorrect user credential, the error code is `EINVAL`.

The user should get the password dialog to enter username and password if the error code is `EINVAL`.

Reference URL:
https://bugzilla.samba.org/show_bug.cgi?id=14983
https://gitlab.gnome.org/GNOME/gvfs/-/issues/611

M  +1    -1    smb/kio_smb_browse.cpp

https://invent.kde.org/network/kio-extras/commit/eea1ecae3624c90b63a0c1378313fe8d26b00db1