Bug 334618 - Samba sharing errors are not displayed in the UI
Summary: Samba sharing errors are not displayed in the UI
Status: RESOLVED FIXED
Alias: None
Product: kdenetwork-filesharing
Classification: Frameworks and Libraries
Component: general (show other bugs)
Version: unspecified
Platform: Kubuntu Linux
: NOR normal
Target Milestone: ---
Assignee: Nate Graham
URL:
Keywords: usability
Depends on:
Blocks:
 
Reported: 2014-05-11 18:38 UTC by mokush
Modified: 2020-08-12 14:37 UTC (History)
5 users (show)

See Also:
Latest Commit:
Version Fixed In: 20.12
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mokush 2014-05-11 18:38:48 UTC
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.
Comment 1 Frank Reininghaus 2014-05-11 20:25:29 UTC
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.
Comment 2 Nate Graham 2018-05-03 20:00:27 UTC
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.
Comment 3 Harald Sitter 2020-02-27 10:34:29 UTC
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.
Comment 4 Harald Sitter 2020-03-18 14:26:43 UTC
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
Comment 5 Bug Janitor Service 2020-08-10 14:27:28 UTC
A possibly relevant merge request was started @ https://invent.kde.org/network/kdenetwork-filesharing/-/merge_requests/2
Comment 6 Harald Sitter 2020-08-12 09:32:18 UTC
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
Comment 7 Harald Sitter 2020-08-12 14:37:26 UTC
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