Bug 390551 - Internal Error when trying to access Samba domain by URL with SMB2
Summary: Internal Error when trying to access Samba domain by URL with SMB2
Status: RESOLVED FIXED
Alias: None
Product: kio-extras
Classification: Frameworks and Libraries
Component: Samba (show other bugs)
Version: 17.12.1
Platform: Fedora RPMs Linux
: HI major
Target Milestone: ---
Assignee: Plasma Bugs List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-16 11:06 UTC by Alois Steindl
Modified: 2019-08-14 15:14 UTC (History)
6 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 Alois Steindl 2018-02-16 11:06:28 UTC
When trying to open a Samba Share, dolphin (and also Nautilus and Konqueror) finds no Samba domain. If I type in the samba domain name in the address bar, e.g. 
smb://Mechanik2
dolphin indicates an internal error caused by libsmbclient.

Typing in a linux or Windows samba server on the local network, it connects fine. Typing a nonexistent name, it tells me, that it cannot connect.
 
The domain is found using e.g. findsmb; also smbtree shows the domain and connected servers.

It works as expected with Fedora 26, Scientific Linux and Knoppix.
Comment 1 Nate Graham 2018-02-19 18:26:04 UTC

*** This bug has been marked as a duplicate of bug 385708 ***
Comment 2 madcatx 2018-02-19 19:35:01 UTC
This is rather suspicious. What Samba version and KDE Applications are you using? If the version tag mentioned in the bug report is correct, the required workaround for a libsmbclient 4.7 bug should be included. Weird. Can you take a closer look and check that you are not hitting another problem? I am currently half way around the world away from my Fedora 27 box so I cannot check if there is some kind of issue specific to Fedora packages.
Comment 3 Alois Steindl 2018-02-20 20:57:42 UTC
(In reply to madcatx from comment #2)
> This is rather suspicious. What Samba version and KDE Applications are you
> using? If the version tag mentioned in the bug report is correct, the
> required workaround for a libsmbclient 4.7 bug should be included. Weird.
> Can you take a closer look and check that you are not hitting another
> problem? I am currently half way around the world away from my Fedora 27 box
> so I cannot check if there is some kind of issue specific to Fedora packages.

Thanks for replying and having a look at the problem!
The problem occurs for the samba version 4.7.4-2, the involved programs are 
dolphin and konqueror, both version 17.12.1-1, and nautilus 3.26.2-1.
There are two quite similar packages installed: samba-client-libs and libsmbclient. They contain the files libsmbclient-raw-samba4.so and libsmbclient.so.0.2.3, respectively, among many others.
Kind regards
Alois
Comment 4 madcatx 2018-02-21 11:01:05 UTC
Can you try to get us some debugging output? I am unfamiliar with GNOME's facilities for this but with KDE Apps you can proceed as follows

1. Run "kdebugdialog"
2. Search for "kio_smb" and enable it
3. Run "journalctl -f" as a regular user
4. Launch Dolphin and try to access some of the troublesome shares

Look for output like this in the journal:
úno 21 11:50:08 The-Raza kdeinit5[1306]: kio_smb: Using libsmbclient library version 4.7.4
úno 21 11:50:08 The-Raza kdeinit5[1306]: kio_smb: Detected broken libsmbclient version 4.7.4

The log should also contain a more descriptive error message instead of the rather useless "Internal error".
Comment 5 Alois Steindl 2018-02-21 11:45:38 UTC
Thanks for the helpful hints.
After trying to open "Samba Shares" within "Network" in dolphin, nautilus or konquerer, I see several messages in the shell with journalctl:

Feb 21 12:39:25 mch2pc28 /usr/libexec/gdm-x-session[1580]: kioslave: ####### CRASH ###### protocol = smb pid = 3487 signal = 11

If I open a samba-share with hostname and sharename, there are no problems, only the urls smb:// and smb://<workgroup> (in my case smb://Mechanik2) cause troubles.
With kind regards
Alois
Comment 6 madcatx 2018-02-21 13:41:13 UTC
Given there is a crash involved this bug is very likely not a duplicate of 385705. Can you post the entire journal log beginning before you launch Dolphin and going all the way until the crash? I have a trans-atlantic flight tomorrow evening so I will have a few hours to kill; I'll try to take a look at what could be going on...
Comment 7 Alois Steindl 2018-02-21 13:56:20 UTC
Hello,
I enabled all entries in kdebugdialog and at starting dolphin I got the messages:

Feb 21 14:48:14 mch2pc28 dolphin[8341]: Trying to convert empty KLocalizedString to QString.
Feb 21 14:48:14 mch2pc28 dolphin[8341]: org.kde.dolphin: Ignore KIO url: QUrl("timeline:/today")
Feb 21 14:48:14 mch2pc28 dolphin[8341]: org.kde.dolphin: Ignore KIO url: QUrl("timeline:/yesterday")
Feb 21 14:48:14 mch2pc28 dolphin[8341]: org.kde.dolphin: Ignore KIO url: QUrl("timeline:/thismonth")
Feb 21 14:48:14 mch2pc28 dolphin[8341]: org.kde.dolphin: Ignore KIO url: QUrl("timeline:/lastmonth")
Feb 21 14:48:14 mch2pc28 dolphin[8341]: org.kde.dolphin: Ignore KIO url: QUrl("search:/documents")
Feb 21 14:48:14 mch2pc28 dolphin[8341]: org.kde.dolphin: Ignore KIO url: QUrl("search:/images")
Feb 21 14:48:14 mch2pc28 dolphin[8341]: org.kde.dolphin: Ignore KIO url: QUrl("search:/audio")
Feb 21 14:48:14 mch2pc28 dolphin[8341]: org.kde.dolphin: Ignore KIO url: QUrl("search:/videos")
Feb 21 14:48:14 mch2pc28 dolphin[8341]: qt.accessibility.core: Cannot create accessible child interface for object:  PlacesView(0x5576232d5dd0)  index:  24
Feb 21 14:48:14 mch2pc28 baloo_file[1847]: QObject::connect: invalid null parameter
Feb 21 14:48:14 mch2pc28 dolphin[8341]: QObject::connect: invalid null parameter
Feb 21 14:48:14 mch2pc28 kdeinit5[1799]: QObject::connect: invalid null parameter
Feb 21 14:48:14 mch2pc28 kdeinit5[1799]: QObject::connect: invalid null parameter
Feb 21 14:48:59 mch2pc28 /usr/libexec/gdm-x-session[1580]: kioslave: ####### CRASH ###### protocol = smb pid = 8381 signal = 11
Feb 21 14:49:00 mch2pc28 /usr/libexec/gdm-x-session[1580]: kioslave: ####### CRASH ###### protocol = smb pid = 8380 signal = 11
Feb 21 14:49:05 mch2pc28 /usr/libexec/gdm-x-session[1580]: kioslave: ####### CRASH ###### protocol = smb pid = 8394 signal = 11
Feb 21 14:49:15 mch2pc28 /usr/libexec/gdm-x-session[1580]: kioslave: ####### CRASH ###### protocol = smb pid = 8401 signal = 11


If you need more information, please let me know!
With best wishes
Alois
Comment 8 madcatx 2018-02-21 15:24:50 UTC
Okay, the log does not seem to be particularly helpful. Since I cannot think of anything better right now, let me suggest the following.

1. run ps -Ao pid,cmd > curr_procs.txt
2. trigger the crash and look up the PID of the crashed process in the list of processes created in step 1. Note its name and command.
3. Run Doplhin again and find the offending process by its name/command. Note that its PID will now be different.
4. Attach gdb to the process like this: gdb -p CURRENT_PID. This must be done with root privileges.
5. Trigger the crash again and post the backtrace. gdb might complain about some missing debugging symbols but you may ignore this for now. Once we know where to look you can install the required debuginfo packages to get a better backtrace.
Comment 9 Alois Steindl 2018-02-21 23:11:00 UTC
I fear that I cannot make your suggestion work: the processes corresponding to the pids in the "crash" lines only exist for a very short time. They seem to be created, when the 'Samba shares" butten is pressed and are impossible to observe by the ps or top command. So it might be necessary to look into dolphin to find out, which processs is started.
Btw, looking at the dolphin process itself by gdb yields no information.
Comment 10 madcatx 2018-02-22 13:13:35 UTC
Okay, I expected it could go down like this. I'll try to reproduce the crash once I'm back on the university network. To that, could you post as detailed as possible step-by-step way how to trigger the crash?
Additionally, when you get the "Internal error" message in Dolphin, does the message contain any human readable description of the error that has occurred? The SMB plugin for KIO triggers this error whenever it encounters an error code it does not know how to handle specifically.
Comment 11 Alois Steindl 2018-02-22 22:31:36 UTC
Thanks for your efforts.

The error can be triggered quite simply: First make sure, that samba server is running and there is a workgroup.

Simply open dolphin and click on Network -> Samba Shares.
(I am using a german environment, so the names might be slightly different).
Using journalctl -f one sees the lines
kioslave: ######CRASH ###### protocol = smb pid = 17509 signal = 11.
Having run dolphin longer, there are repeating such lines, with pid increasing by 5-10 in every step.
In the address line "smb://" is displayed.
If I change that to smb://WORKGROUP, I get the message, that some internal error occured and one should file a bug report.

Repeating the step, I obtain the message, that the file smb://user@WORKGROUP/ doesn't exist. Nothing is displayed by journalctl.
If I enter the name of a non-existent Workgroup, I get the (correct) message, that it cannot connect to smb://wrongWORKGROUPname/

In order to ensure, that there is no silly mistake in some configuration file on my computer, I moved ~/.kde to ~/.kde-save; the behaviour remained the same.
I also downloaded the Fedora 26 and 27 Live-system isos and tried these on a different computer. With Fedora 26 it behaved properly (Clicking on Samba share displayed the WORKGROUP, and I could dig deeper into the tree.)
With Fedora 27 I got the same behaviour as described above. 

Sometimes it happened, that I was asked for credentials and dolphin tried to connect to smb://username@WORKGROUP, which of course also failed.

Fortunately the error doesn't prevent serious work. If I try to connect to a specific samba share, it works correctly.
Comment 12 madcatx 2018-03-13 12:17:59 UTC
I tried to reproduce this but I was unsuccessful. There is one thing I came across though, can you check the content of your /etc/hosts for me?
Comment 13 Alois Steindl 2018-03-13 12:45:30 UTC
Hello,
the /etc/hosts file reads now
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
128.130.47.80 mch2pc50 mch2pc50.mechanik.tuwien.ac.at
128.130.47.87 mch2pc57 mch2pc57.mechanik.tuwien.ac.at
128.130.47.58 mch2pc28 mch2pc28.mechanik.tuwien.ac.at
128.130.47.11 mch2srv1 mch2srv1.mechanik.tuwien.ac.at
128.130.47.83 mch2ws2 mch2ws2.mechanik.tuwien.ac.at

I added the lines starting with 128 when I observed the strange behaviour.

In the [global] section in /etc/samba/smb.conf I have 

	workgroup = MECHANIK2
	server string = Mch2pc28

In order to reduce the probability of a local misconfiguration I downloaded a recent image of Fedora and tried it out. WIth Fc26 it worked as expected, with FC27 I observe the problem.
Comment 14 madcatx 2018-03-14 08:13:41 UTC
As I was unable to reproduce the crash myself I tried to come up with a way how to at least catch it in a debugger. Here is what I found out:

All KIO plugins used by Dolphin have a parent process whose PID corresponds to kdeinit5. Can you try this?

gdb -p <kdeinit5 PID>
set follow-fork-mode child
c

Try to trigger the crash.
Comment 15 Alois Steindl 2018-03-14 14:36:33 UTC
Thanks for the hints!

I tried it according your suggestions and also installed the debuginfo files for libsmbclient. Unfortunately I couldn't convince gdb to follow the child of kdeinit5; so if I debug the process of kdeinit5, use the suggested commands
set follow-fork-mode child
c
nothing happens, when the problem occurs. 
But after that also a child process smb.so is shown by ps and I can debug that.
Now it encounters a signal SIGSEGV, Segmentation fault.
SMBC_fstatvfs_ctx (context=0x55555581cc20, file=0x555555853130, st=0x7fffffffcf60)
    at ../source3/libsmb/libsmb_stat.c:372
372             struct cli_state *cli = file->srv->cli;

file->srv is 0x0 at this point, and fname is "smb://".

Of course, this segfault doesn't seem to be the problematic one.
I tried now for a while to look what happens, when "smb://Mechanik2" is entered.
Unfortunately I cannot reach that point: If I try to trigger the error, the old smb process is not affected by that and a new one is created, which segfaults.

With best wishes
Alois
Comment 16 madcatx 2018-03-14 16:06:11 UTC
At least we're getting somewhere. Does the crash that you actually managed to catch lead back to the smb.so and if so, where to exactly? It might be worth a look.
Comment 17 Alois Steindl 2018-03-14 17:03:15 UTC
Yes, the segfault I can reproduce occurs at source3/libsmb/libsmb_stat.c:372 in the samba-4.7.5 distribution.
I now tried again quite a lot of times to trigger the error with smb://Mechanik2, but never caught that with gdb.
Comment 18 Nate Graham 2018-04-13 02:57:02 UTC
*** Bug 392803 has been marked as a duplicate of this bug. ***
Comment 19 Nate Graham 2018-04-14 20:10:27 UTC
For anyone seeing this, does reverting https://cgit.kde.org/kio-extras.git/commit/?id=a36b797913a844dbb26d5dc1542b3ce304f5f445 fix the issue? I wonder if Samba fixed the issue we were working around in your version of Samba but our workaround is now causing problems.
Comment 20 Nate Graham 2018-05-08 19:57:46 UTC
I don't see this problem with Samba 4.7.6 in Kubuntu 18.04. Can you still reproduce?

If so, does it help if you set "client max protocol = NT1" in /etc/samba/smb.conf?
Comment 21 Alois Steindl 2018-05-08 20:35:03 UTC
I already have samba 4.7.7 installed (Fedora 27) and the behaviour is still the same. (In the meantime also an updated Scientific Linux 7.5 version, which behaved fine originally, shows this behaviour.)
I played also around with 4.8.0 and couldn't find a difference.
If I set "client max protocol = NT1" in ~/.smb/smb.conf,
the problem vanishes.
I also tried to run the test programs in the samba distributions, they didn't show that problem. 

As the problem now seems to be related with file permissions, a maybe very simple remark/question: If I call smbtree, the program displays the available workgroup and connected machines properly, without asking for any credentials. 
Shouldn't clicking on "Samba Shares" in dolphin or konqueror behave the same? The user should find a list of available shares, without immediate need to login. Of course, if I want to open a directory, the password dialog should be opened. I do not know the internal flow of these programs sufficiently well - and didn't succeed to find that out by running the test programs and looking at the sources -, but it seems to me, that the EPERM error shouldn't be returned yet.

Actually the error doesn't cause any problems, because I need only connect to a few addresses, for which I can provide the full samba URL in the list of network shares. But a possible exception with signal 11 might cause security problems.

With best wishes
Alois
Comment 22 Nate Graham 2018-05-09 22:45:44 UTC
The fact that you can't browse for workgroups and shares is Bug 392803.

Let's use this bug to track the issue with being unable to access your domain by the URL.

Works for me with samba 4.7.6 in Kubuntu 18.04, BTW.
Comment 23 Nate Graham 2018-05-10 13:03:04 UTC
The fact that 4.7.6 works for me but 4.7.7 gives you problems makes me think that this is related to the workaround no longer being necessary and now actually causing problems (it was fixed in 4.7.7).

If you're able to test a patch, could you see if https://phabricator.kde.org/D12798 fixes the issue for you?
Comment 24 Alois Steindl 2018-05-11 13:40:58 UTC
(In reply to Nate Graham from comment #23)
> The fact that 4.7.6 works for me but 4.7.7 gives you problems makes me think
> that this is related to the workaround no longer being necessary and now
> actually causing problems (it was fixed in 4.7.7).
> 
> If you're able to test a patch, could you see if
> https://phabricator.kde.org/D12798 fixes the issue for you?

Meanwhile I upgraded my installation to Fedora Core 28 and it seems, that this patch is already present in kio-extras-17.12.3.
But the behaviour is still the same. (I have no experience in these programs: Maybe there are 2 different versions of kio_smb installed in the system: One from  kde-runtime, the other one from kio-extras; I suspect that the kio_smb.so in /usr/lib64/kde4/kio_smb.so wins; I cannot see such library file in the installed kio-extras package. (I just tried to rebuild the kio-extras rpm, but this one also contains no kio_smb.so.))

I tried earlier to debug the kio_smb file, but couldn't detect any message from the patched kio_smb.cpp file.
With best wishes
Alois
Comment 25 Nate Graham 2018-05-11 13:58:57 UTC
Git commit 6529d29166ac57777f5b4d081eab41a87ccf14f7 by Nathaniel Graham, on behalf of Michal Malý.
Committed on 11/05/2018 at 13:58.
Pushed by ngraham into branch 'master'.

Constrain libsmbclient bug workaround to affected versions only

Summary:
A bug where libsmbclient returned nonsensical error code which prevented kio_smb plugin to query user for login credentials appears to have been fixed in Samba 4.7.7 and Samba 4.8.0. Constrain the workaround for the problem only to affected version of libsmbclient.

Samba 4.7.7 release notes: https://www.samba.org/samba/history/samba-4.7.7.html
Relevant bug report: https://bugzilla.samba.org/show_bug.cgi?id=13050

Reviewers: elvisangelaccio, ngraham

Reviewed By: elvisangelaccio, ngraham

Differential Revision: https://phabricator.kde.org/D12798

M  +1    -1    smb/kio_smb.cpp

https://commits.kde.org/kio-extras/6529d29166ac57777f5b4d081eab41a87ccf14f7
Comment 26 Nate Graham 2018-05-14 21:50:05 UTC
Michal, any ideas?
Comment 27 Harald Sitter 2018-12-07 12:55:18 UTC
Git commit 55eb68ff63646050311f8b689752ad500246c916 by Harald Sitter.
Committed on 07/12/2018 at 12:55.
Pushed by sitter into branch 'master'.

fallback to dnssd service discovery if smb listDir failed on root

Summary:
This elevates a problem with newer SMB protocol versions and smbclient
not supporting discovery/browsing. when not using older (as in:
ancient) protocol versions discovery doesn't work and smb:/ gives no
results.

By falling back to DNSSD based discovery we can ensure discovery of DNSSD
remotes (namely linux and osx) is always working. Windows unfortunately
does not support DNSSD and as such will not benefit from this mode of
discovery and continue to be unlisted when using a protocol version
without browsing support.

CHANGELOG: When SMB Discovery is not working (protocol > SMB1) host discovery will now fall back to DNS-SD/Avahi/Bonjour.
Related: bug 392447

Test Plan:
smb.conf:

```
[global]
client min protocol = SMB2
```

Lists devices

Reviewers: #frameworks, #dolphin, broulik

Reviewed By: broulik

Subscribers: acrouthamel, alexde, bcooksley, ngraham, kde-frameworks-devel, kfm-devel

Tags: #dolphin, #frameworks

Differential Revision: https://phabricator.kde.org/D16299

M  +6    -0    CMakeLists.txt
M  +3    -0    config-runtime.h.cmake
M  +16   -3    smb/CMakeLists.txt
M  +1    -0    smb/kio_smb.h
M  +126  -3    smb/kio_smb_browse.cpp

https://commits.kde.org/kio-extras/55eb68ff63646050311f8b689752ad500246c916