Bug 9633 - smbclient recursive mget stops abruptly on NT_STATUS_ACCESS_DENIED
Summary: smbclient recursive mget stops abruptly on NT_STATUS_ACCESS_DENIED
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.0
Classification: Unclassified
Component: Tools (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Samba QA Contact
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-04 17:29 UTC by David Disseldorp
Modified: 2013-02-13 18:30 UTC (History)
1 user (show)

See Also:


Attachments
Proposed fix for master (1.31 KB, patch)
2013-02-04 18:08 UTC, David Disseldorp
jra: review+
asn: review+
ddiss: review? (metze)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description David Disseldorp 2013-02-04 17:29:05 UTC
When downloading files recursively, smbclient will halt if it encounters a folder to which it does not have permission to traverse.

Note the mix of files with root only and root + group + other permissions on the "media share":
ravel:/media/:[0]# ls -lR
.:
total 16
-rw-r--r-- 1 root root    7 Feb  4 18:12 others_file
drwxr-xr-x 2 root root 4096 Feb  4 18:12 root_and_others
drwx------ 2 root root 4096 Feb  4 14:37 root_only
-rwx------ 1 root root   10 Feb  4 16:57 root_only_file

./root_and_others:
total 4
-rw-r--r-- 1 root root 8 Feb  4 15:52 permissive

./root_only:
total 4
-rw-r--r-- 1 root root 5 Feb  4 14:37 rooted

Recursively downloading the contents of the "media" share using an smbclient master build does not pull down the files readable by the "beensee" user:

ddiss@f163:~/isms/samba-pristine/tmp (bnc786350_eperm_continue)> ../bin/smbclient -s /etc/samba/smb.conf -U 'beensee' -c 'recurse;prompt;mget *' //ravel.arch.suse.de/media
Enter beensee's password: 
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.3-0.28.1-2860-SUSE-CODE11-x86_64]
NT_STATUS_ACCESS_DENIED opening remote file \root_only_file
NT_STATUS_ACCESS_DENIED listing \root_only\*
NT_STATUS_ACCESS_DENIED listing \*

ddiss@f163:~/isms/samba-pristine/tmp (bnc786350_eperm_continue)> ls -lR .
.:
total 4
drwxr-xr-x 2 ddiss users 4096 2013-02-04 18:13 root_only

./root_only:
total 0


smbclient versions prior to Samba 3.6 (3.5 in this example) successfully download all readable files:
ddiss@f163:~/isms/samba-pristine/tmp (bnc786350_eperm_continue)> rm -rf ~/isms/samba-pristine/tmp/*
ddiss@f163:~/isms/samba-pristine/tmp (bnc786350_eperm_continue)> smbclient -s /etc/samba/smb.conf -U 'beensee' -c 'recurse;prompt;mget *' //ravel.arch.suse.de/media
Enter beensee's password: 
Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.3-0.28.1-2860-SUSE-CODE11-x86_64]
NT_STATUS_ACCESS_DENIED opening remote file \root_only_file
NT_STATUS_ACCESS_DENIED listing \root_only\*
getting file \root_and_others\permissive of size 8 as permissive (7.8 KiloBytes/sec) (average 7.8 KiloBytes/sec)
getting file \others_file of size 7 as others_file (6.8 KiloBytes/sec) (average 7.3 KiloBytes/sec)

ddiss@f163:~/isms/samba-pristine/tmp (bnc786350_eperm_continue)> ls -lR
.:
total 12
-rw-r--r-- 1 ddiss users    7 2013-02-04 18:28 others_file
drwxr-xr-x 2 ddiss users 4096 2013-02-04 18:28 root_and_others
drwxr-xr-x 2 ddiss users 4096 2013-02-04 18:28 root_only

./root_and_others:
total 4
-rw-r--r-- 1 ddiss users 8 2013-02-04 18:28 permissive

./root_only:
total 0
Comment 1 David Disseldorp 2013-02-04 17:32:15 UTC
As identified by Bogdano Arendartchuk, this regression was introduced with commit:
14ff2e8de9bd8d0064762234555260f5eea643fe Fix bug #7700 - Improvement of return code of smbclient
Comment 2 David Disseldorp 2013-02-04 18:08:57 UTC
Created attachment 8529 [details]
Proposed fix for master
Comment 3 Andreas Schneider 2013-02-07 09:30:38 UTC
Does smbclient give the user a warning about what file it wasn't able to download? I don't see one in the patch.
Comment 4 David Disseldorp 2013-02-07 10:31:31 UTC
(In reply to comment #3)
> Does smbclient give the user a warning about what file it wasn't able to
> download? I don't see one in the patch.

An error message is printed for each file do_get() cannot open for download, and each directory do_list() is unable to recurse:

Domain=[WORKGROUP] OS=[Unix] Server=[Samba 3.6.3-0.28.1-2860-SUSE-CODE11-x86_64]
NT_STATUS_ACCESS_DENIED opening remote file \root_only_file
NT_STATUS_ACCESS_DENIED listing \root_only\*
getting file \root_and_others\permissive of size 8 as permissive (7.8 KiloBytes/sec) (average 7.8 KiloBytes/sec)
getting file \others_file of size 7 as others_file (6.8 KiloBytes/sec) (average 7.3 KiloBytes/sec)

The error is not currently propagated through to the exit status, this should be addressed in future.
Comment 5 Jeremy Allison 2013-02-08 20:20:49 UTC
Re-assigning to Karolin for inclusion in 4.0.next and 3.6.next (patch applies cliently to both).

Jeremy.
Comment 6 Karolin Seeger 2013-02-12 20:07:00 UTC
Pushed to v3-6-test and autobuild-v4-0-test.
Comment 7 Karolin Seeger 2013-02-13 18:30:09 UTC
Pushed to v4-0-test.
Closing out bug report.

Thanks!