If you share (samba) a folder through Dolphin (right click folder > Properties > Share tab), and the sharing action throws an error - that prevents the folder from being shared - Dolphin still acts as if the folder was successfully shared (folder icon has the extra `share` icon over it), and no errors are shown to the user. For example, if I try to share a folder on a NTFS mount that I am not the owner of, in the console I can see that Dolphin has reported: dolphin(5728) KSambaSharePrivate::add: We got some errors while running 'net usershare add' ("usershare", "add", "Pictures", "/media/Mokush/Pictures", "", "Everyone:r", "guest_ok=y") dolphin(5728) KSambaSharePrivate::add: "net usershare add: cannot share path /media/Mokush/Pictures as we are restricted to only sharing directories we own. Ask the administrator to add the line "usershare owner only = false" to the [global] section of the smb.conf to allow this. but in the UI everything seems fine, after the sharing action, as if the folder was shared, even if it wasn't. Reproducible: Always Steps to Reproduce: Could me multiple ways to reproduce this, but one would be: 1. Open Dolphin 2. Go to a NTFS mount you are not the owner of 3. Share a folder by right clicking the folder then going to Properties > Share tab 4. Select sharing properties then click Ok Actual Results: Dolphin shows the little `share` icon above the folder, and reports no errors. Expected Results: Dolphin shouldn't show the little `share` icon above the folder, and should show the error thrown by Samba in the UI, maybe using the same standard red box used for all errors.
Thanks for the bug report. I assume that the problem is somewhere in KIO. KIO is responsible for telling us about errors, and also for deciding if the "sharing" icons should be shown AFAIK.
Still an issue in KDE Frameworks 5.45. The problem seems to be in src/core/ksambashare.cpp. There's even a TODO: in there alerting us that the error messages aren't sent anywhere.
For the record: the best we can do here is forward the error message if exit code !=0. The output from net usershare (net_usershare.c) has utterly arbitrary format. Fortunately it is also fully i18n'd, so simply forwarding the output is likely perfectly reasonable as it will be a l10n'd pretty string anyway. The swaths of text may require us to use KMessageBox with setDetails to display the output though.
I spoke too soon. There's half a localization infrastructure in samba and as a result the net command is in fact not localized ... At the same time this could change at any point so modeling net command errors as part of the public api of ksambashare is also out of the question. So, I guess that leaves us with a kind of inbetween. KSambaShare should grow an errorString() that is set when a command returns a SystemError, the errorString in turn is either parsed from the net stderr and then localized on our end or the verbatim (unlocalized) stderr if we cannot identify the error reported in stderr through parsing. A bit meh
A possibly relevant merge request was started @ https://invent.kde.org/network/kdenetwork-filesharing/-/merge_requests/2
Git commit 5e1571cf2909d026f781dfaa978ab10705d30d8d by Harald Sitter. Committed on 12/08/2020 at 09:32. Pushed by sitter into branch 'master'. smb: keep stderr of net commands on add/remove this allows guis to show the backend stderr on UserShareSystemError when we haven't managed to map that to a more specific type (which we currently do not ever; there's an unresolved todo about this). M +34 -14 src/core/ksambashare.cpp M +11 -0 src/core/ksambashare.h M +2 -1 src/core/ksambashare_p.h M +3 -3 src/core/ksambasharedata.h https://invent.kde.org/frameworks/kio/commit/5e1571cf2909d026f781dfaa978ab10705d30d8d
Git commit 01a6bda31bbc32d54bef49111765aabbb771d153 by Harald Sitter. Committed on 12/08/2020 at 14:37. Pushed by sitter into branch 'master'. give add/remove errors a GUI previously we'd ignore the returned errors leaving the user hanging when adding a share fails and not even telling them why. we now route errors on add/remove through somewhat generic kmessagebox-based reporting tech. unfortunately this is fairly excessive WRT string mapping because ksambashare sports one enum for everything so API-wise a call to save() could return UserShareAclOk but in practice that of course cannot happen because that'd mean nothing. as such many of the strings are overly generic because they cannot practically appear on weak context actions like save(). very meh. this depends on the new lastSystemErrorString() API in KIO to stringify the majority of failure scenarios here, which come out of samba's 'net' command trying to share /tmp now produces a kmessagebox informing the user that the dir cannot be shared FIXED-IN: 20.12 M +1 -1 CMakeLists.txt M +90 -3 samba/filepropertiesplugin/sambausershareplugin.cpp M +4 -0 samba/filepropertiesplugin/sambausershareplugin.h https://invent.kde.org/network/kdenetwork-filesharing/commit/01a6bda31bbc32d54bef49111765aabbb771d153