Bug 12499 - vfs_dirsort doesn't handle opendir of "."
Summary: vfs_dirsort doesn't handle opendir of "."
Status: RESOLVED FIXED
Alias: None
Product: Samba 4.1 and newer
Classification: Unclassified
Component: VFS Modules (show other bugs)
Version: unspecified
Hardware: All All
: P5 normal (vote)
Target Milestone: ---
Assignee: Karolin Seeger
QA Contact: Jeremy Allison
URL:
Keywords:
Depends on:
Blocks: 12496
  Show dependency treegraph
 
Reported: 2017-01-05 20:37 UTC by Jeremy Allison
Modified: 2017-03-27 17:41 UTC (History)
1 user (show)

See Also:


Attachments
git-am fix for master. (1.01 KB, patch)
2017-01-05 21:20 UTC, Jeremy Allison
uri: review+
Details
git-am fix for 4.5.next, 4.4.next. (1.12 KB, patch)
2017-01-10 01:09 UTC, Jeremy Allison
uri: review+
Details
git-am fix for 4.6.next, 4.5.next (1.12 KB, patch)
2017-01-27 17:16 UTC, Jeremy Allison
uri: review+
Details
git-am fix for 4.4.next. (1.11 KB, patch)
2017-01-27 17:16 UTC, Jeremy Allison
uri: review+
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Allison 2017-01-05 20:37:54 UTC
Needs to store the $cwd in order to correctly do the sort.

Patch to follow.
Comment 1 Jeremy Allison 2017-01-05 21:20:43 UTC
Created attachment 12802 [details]
git-am fix for master.
Comment 2 Uri Simchoni 2017-01-06 22:02:52 UTC
LGTM, for the specific case it fixes.

There can probably be a more generic fix for other cases where the opendir and readdir are off different cwd's, perhaps using realpath(), and the most elegant thing would have been for VFS to support dirfd and fstat that, or some API that returns the stat from DIR *.
Comment 3 Jeremy Allison 2017-01-06 22:20:03 UTC
Yes, it's a little narrow, but right now we only ever call opendir from either the given path relative to the share, or "." when we're walking a path in privilege specific code.

I'll push to master, thanks !
Comment 4 Jeremy Allison 2017-01-10 01:09:58 UTC
Created attachment 12807 [details]
git-am fix for 4.5.next, 4.4.next.

Cherry-picked from master. Applies cleanly to 4.5.next, 4.4.next.
Comment 5 Jeremy Allison 2017-01-24 23:51:51 UTC
Karolin, patch applies cleanly to 4.6.0rc, 4.5.next, 4.4.next.

Thanks !

Jeremy.
Comment 6 Karolin Seeger 2017-01-27 05:35:21 UTC
user@host:/data/git/samba/v4-6-test$ git am 0001-s3-vfs-dirsort-doesn-t-handle-opendir-of-.-correctly.patch
Applying: s3: vfs: dirsort doesn't handle opendir of "." correctly.
error: patch failed: source3/modules/vfs_dirsort.c:137
error: source3/modules/vfs_dirsort.c: patch does not apply
Patch failed at 0001 s3: vfs: dirsort doesn't handle opendir of "." correctly.

Same for v4-5-test.
Comment 7 Jeremy Allison 2017-01-27 16:49:09 UTC
Sorry Karolin, I'll fix this asap.
Comment 8 Jeremy Allison 2017-01-27 17:16:12 UTC
Created attachment 12858 [details]
git-am fix for 4.6.next, 4.5.next

Direct cherry pick from master.
Comment 9 Jeremy Allison 2017-01-27 17:16:41 UTC
Created attachment 12859 [details]
git-am fix for 4.4.next.

Back-port from master.
Comment 10 Uri Simchoni 2017-01-28 19:31:42 UTC
Verified patches apply to v4-4-stable, v4-5-stable, v4-6-stable.
Assigning to Karolin for inclusion in 4.4.next, 4.5.next, 4.6.next.
Thanks,
Uri.
Comment 11 Karolin Seeger 2017-02-02 08:09:03 UTC
Pushed to autobuild-v4-{6,5,4}-test.
Comment 12 Karolin Seeger 2017-02-09 16:56:40 UTC
(In reply to Karolin Seeger from comment #11)
Pushed to all branches.
Closing out bug report.

Thanks!