Permission denied calling SMBC_getatr when file not exists
Description of problem:
Permission denied calling SMBC_getatr
when file not exists.
Apparently SMBC_getatr
no longer uses errno
but instead returns NTSTATUS
:
https://github.com/samba-team/samba/commit/d4f8fdd69a1278d8473d541dc6b32014a369bcd0
Reverting the previous commit fixes the bug:
I rebuilt the samba SRPM using a mock and added the patch to SPEC and everything works perfect:
https://koji.fedoraproject.org/koji/buildinfo?buildID=2062333
$ git format-patch -1 --stdout d4f8fdd69a1278d8473d541dc6b32014a369bcd0 > 0001-libsmb-Convert-SMBC_getatr-to-NTSTATUS.patch
0001-libsmb-Convert-SMBC_getatr-to-NTSTATUS.patch
https://koji.fedoraproject.org/koji/buildinfo?buildID=2062333
...
Patch100: 0001-libsmb-Convert-SMBC_getatr-to-NTSTATUS.patch
...
%prep
xzcat %{SOURCE0} | gpgv2 --quiet --keyring %{SOURCE2} %{SOURCE1} -
%autosetup -n samba-%{version}%{pre_release} -N
%autopatch -M 99
%patch100 -p1 -R
...
Version-Release number of selected component (if applicable):
$ rpm -qa gvfs-*
gvfs-client-1.50.2-2.fc37.x86_64
gvfs-afc-1.50.2-2.fc37.x86_64
gvfs-fuse-1.50.2-2.fc37.x86_64
gvfs-goa-1.50.2-2.fc37.x86_64
gvfs-afp-1.50.2-2.fc37.x86_64
gvfs-archive-1.50.2-2.fc37.x86_64
gvfs-gphoto2-1.50.2-2.fc37.x86_64
gvfs-mtp-1.50.2-2.fc37.x86_64
gvfs-smb-1.50.2-2.fc37.x86_64
$ rpm -qa gvfs-smb samba-* libsmbclient*
gvfs-smb-1.50.2-2.fc37.x86_64
samba-common-4.17.0-1.fc37.noarch
samba-client-libs-4.17.0-1.fc37.x86_64
samba-common-libs-4.17.0-1.fc37.x86_64
libsmbclient-4.17.0-1.fc37.x86_64
samba-client-4.17.0-1.fc37.x86_64
$ rpm -q glib2
glib2-2.73.3-3.fc37.x86_64
How reproducible:
Steps to Reproduce:
Working:
$ gio mount -u "smb://bar@SERVER/foo/"
$ gio mount "smb://bar@SERVER/foo/"
$ date | gio save /run/user/1000/gvfs/smb-share:server=SERVER\,share=foo\,user=bar/folder/test.txt
$ echo $?
0
$ cat /run/user/1000/gvfs/smb-share:server=SERVER\,share=foo\,user=bar/folder/test.txt
Thu Sep 15 03:49:57 PM -05 2022
Not working (Permission denied):
$ gio mount -u "smb://bar@SERVER/foo/"
$ gio mount "smb://bar@SERVER/foo/"
$ date | tee /run/user/1000/gvfs/smb-share\:server\=SERVER\,share\=foo\,user\=bar/folder/another-test.txt
tee: '/run/user/1000/gvfs/smb-share:server=192.168.44.1,share=backups,user=bar/folder/another-test.txt': Permission denied
Thu Sep 15 03:55:20 PM -05 2022
$ echo $?
1
$ date | tee /run/user/1000/gvfs/smb-share\:server\=SERVER\,share\=foo\,user\=bar/folder/test.txt (the file exists because it was created above with "gio save")
$ echo $?
0
Actual results:
$ date | gio save /run/user/1000/gvfs/smb-share:server=SERVER\,share=foo\,user=bar/folder/test.txt (OK)
$ date | tee /run/user/1000/gvfs/smb-share\:server\=SERVER\,share\=foo\,user\=bar/folder/another-test.txt (Fail: Permission denied)
Expected results:
$ date | tee /run/user/1000/gvfs/smb-share\:server\=SERVER\,share\=foo\,user\=bar/folder/another-test.txt (OK)
Additional info:
Log messages in GVFS_SMB_DEBUG=10 GVFS_DEBUG=1 /usr/libexec/gvfsd --replace
:
With gio save
:
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b100068f0 (GVfsJobQueryInfo)
smbc_stat(smb://SERVER/foo/folder)
SMBC_getatr: sending qpathinfo
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10006d50 (GVfsJobQueryInfo)
smb: send_reply(0x7f0b100068f0), failed=0 ()
smbc_stat(smb://SERVER/foo/folder)
SMBC_getatr: sending qpathinfo
smb: send_reply(0x7f0b10006d50), failed=0 ()
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10006df0 (GVfsJobQueryInfo)
smbc_stat(smb://SERVER/foo)
SMBC_getatr: sending qpathinfo
smb: send_reply(0x7f0b10006df0), failed=0 ()
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10006c10 (GVfsJobQueryInfo)
smbc_stat(smb://SERVER/foo/folder)
SMBC_getatr: sending qpathinfo
smb: send_reply(0x7f0b10006c10), failed=0 ()
smb: backend_dbus_handler org.gtk.vfs.Mount:OpenForWriteFlags (pid=5003)
smb: Queued new job 0x7f0b08022190 (GVfsJobOpenForWrite)
map_open_params_to_ntcreate: fname = \folder\test.txt, deny_mode = 0x42, open_func = 0x10
map_open_params_to_ntcreate: file \folder\test.txt, access_mask = 0x12019f, share_mode = 0x3, create_disposition = 0x2, create_options = 0x40 private_flags = 0x0
smb: send_reply(0x7f0b08022190), failed=0 ()
smb: Added new job source 0x7f0b08044570 (GVfsWriteChannel)
smb: Queued new job 0x55aefce02eb0 (GVfsJobWrite)
smb: send_reply(0x55aefce02eb0), bytes=32, failed=0 ()
smb: Queued new job 0x55aefcdf5950 (GVfsJobCloseWrite)
smb: send_reply(0x55aefcdf5950), failed=0 ()
With date | tee
:
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10006cb0 (GVfsJobQueryInfo)
smbc_stat(smb://SERVER/foo/folder)
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10006b70 (GVfsJobQueryInfo)
SMBC_getatr: sending qpathinfo
smb: send_reply(0x7f0b10006cb0), failed=0 ()
smbc_stat(smb://SERVER/foo/folder)
SMBC_getatr: sending qpathinfo
smb: send_reply(0x7f0b10006b70), failed=0 ()
smb: backend_dbus_handler org.gtk.vfs.Mount:QueryInfo (pid=4762)
smb: Queued new job 0x7f0b10002400 (GVfsJobQueryInfo)
smbc_stat(smb://SERVER/foo/folder/another-test.txt)
SMBC_getatr: sending qpathinfo
map_errno_from_nt_status: 32 bit codes: code=c0000022
cli_status_to_errno: 0xc0000022 -> 13
smb: send_reply(0x7f0b10002400), failed=1 (Permission denied)
Red Hat Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2127301