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: ASSIGNED
Alias: None
Product: kio-extras
Classification: Unclassified
Component: Samba (show other bugs)
Version: 21.12.3
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-27 16:22 UTC by Jiri Palecek
Modified: 2022-08-04 17:56 UTC (History)
9 users (show)

See Also:
Latest Commit:
Version Fixed In:


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
```