summaryrefslogtreecommitdiffstats
path: root/source3/smbd/dir.c
Commit message (Collapse)AuthorAgeFilesLines
* smbd: Simplify ReadDirNameVolker Lendecke2015-02-261-4/+6
| | | | | | | In the if-branches we return, so no "else" necessary Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: ZERO_STRUCT -> struct assignmentVolker Lendecke2015-02-261-3/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: ZERO_STRUCT -> struct assignmentVolker Lendecke2015-02-261-2/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: ZERO_STRUCTP -> talloc_zero()Volker Lendecke2015-02-261-3/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smbd: Don't rename a dir with files open underneathVolker Lendecke2014-10-311-1/+120
| | | | | | | | This is an EXPENSIVE check. We'll have to guard this with an option Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3: smbd: Fix a couple of tricky slow-path cases - don't return a mangled ↵Jeremy Allison2014-09-161-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | name for a name that cannot be converted. For a name that contains an illegal Windows character, the directory listing code returns the mangled 8.3 name as the primary name for the file. If the original (non-mangled) filename cannot be converted to UCS2 on the wire via iconv due to conversion error, we should skip that name when returning a directory listing, as we can't map back from a returned 8.3 name to a usable non-mangled filename if the client sends it back to us. As this is only done in a very slow path (name must be mangled) or in the old DOS protocol listing code I don't feel too bad about using a talloc/free pair here. Bug 10775 - smbd crashes when accessing garbage filenames https://bugzilla.samba.org/show_bug.cgi?id=10775 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* smbd: Move make_dir_struct() to reply.cVolker Lendecke2014-09-091-46/+0
| | | | | | | | This routine has nothing to do with dptr handling, it is SMB1 marshalling called only from reply_search(). Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* lib/util: move memcache.[ch] to the toplevel 'samba-util' libraryStefan Metzmacher2014-07-181-1/+1
| | | | | | | | | | This is generic enough that it could be used in all code. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Fri Jul 18 15:43:33 CEST 2014 on sn-devel-104
* s3:smbd: initialize stat_ex buffer in smbd_dirptr_get_entry()Michael Adam2014-07-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This prevents random garbage in the vfs_private member. Usually it should not be a problem to leave initialization of the vfs_private to the vfs module who wants to use it, but further down in the directory listing code, in vfswrap_readdir, there is in optimization introduced with 2a65e8befef004fd18d17853a1b72155752346c8, to call fstatat if possible to already fill stat info in the readdir call. The problem is that this calls fstatat directly, not going through VFS, but still making the stat buffer valid, leaving vfs_private with random garbage. Hence a vfs module using vfs_private, like vfs_gpfs does for offline info (and winAttrs in general) does not have a chance to tell whether the vfs_private is valid if the stat buffer is marked valid. This is a reason for the "flapping offline flag" problem of the vfs_gpfs module. Initializing the vfs_private to 0 here will for the vfs_gpfs module result in files being marked online always in a directory listing. So this is not a real fix but it does at least make the problem less random. A real general fix might be to implement SMB_VFS_FSTATAT() and use it here. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Christof Schmitt <cs@samba.org> Autobuild-Date(master): Sun Jul 13 11:26:58 CEST 2014 on sn-devel-104
* s3:smbd: make dptr_ReadDirName() static.Michael Adam2014-07-101-4/+4
| | | | | Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* param: rename lp function and variable from "hideunwriteable_files" to ↵Garming Sam2014-02-071-1/+1
| | | | | | | | "hide_unwriteable_files" Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* param: rename lp function and variable from "hideunreadable" to ↵Garming Sam2014-02-071-1/+1
| | | | | | | | "hide_unreadable" Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:dir - Introduce a 64-bit directory offset <-> 32 bit wire offset map ↵Jeremy Allison2014-01-151-2/+87
| | | | | | | | | | | using memcache. Should fix the DOS clients against 64-bit smbd's bug. https://bugzilla.samba.org/show_bug.cgi?id=2662 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3:dir - Map wire offsets to native directory cookies.Jeremy Allison2014-01-151-5/+17
| | | | | | | | | Take care of the special offsets. https://bugzilla.samba.org/show_bug.cgi?id=2662 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3:dir - Cope with fixed mapping of 'special' values.Jeremy Allison2014-01-151-0/+7
| | | | | | | https://bugzilla.samba.org/show_bug.cgi?id=2662 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3: dir - Introduce 32-bit wire versions of the 'special' values.Jeremy Allison2014-01-151-0/+5
| | | | | | | https://bugzilla.samba.org/show_bug.cgi?id=2662 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3:dir - Introduce a function to map a directory cookie to a 32-bit wire cookie.Jeremy Allison2014-01-151-1/+10
| | | | | | | | | Make this an identity for now. https://bugzilla.samba.org/show_bug.cgi?id=2662 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3:dir - In the old SMB1 search code, rename offset to wire_offset to ↵Jeremy Allison2014-01-151-8/+8
| | | | | | | | | | | distinguish between wire and native offsets. Rename uint32 type to correct uint32_t. https://bugzilla.samba.org/show_bug.cgi?id=2662 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3-lib: smbclient shows no error if deleting a directory with del failedJeremy Allison2013-11-141-26/+0
| | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=10260 Move dir_check_ftype() to util.c Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* s3-smbd: smbclient shows no error if deleting a directory with del failedJeremy Allison2013-11-141-3/+3
| | | | | | | | | | BUG: https://bugzilla.samba.org/show_bug.cgi?id=10260 Remove unneeded conn argument to dir_check_ftype(). Move to correct uint32_t types. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* smbd: Remove an unused variableVolker Lendecke2013-06-121-2/+0
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Jun 12 01:00:44 CEST 2013 on sn-devel-104
* Fix bug #9822 - Samba crashing during Win8 sync.Jeremy Allison2013-04-271-0/+1
| | | | | | | | | | | | | | | | | | | | | | When refactoring the dptr desctructor in the fix for bug: 9778 (Samba directory code uses dirfd() without vectoring through a VFS call) I removed the code to NULL out the struct smb_Dir * pointer inside the fsp struct by mistake. Re-add the NULLing out of that pointer when closing a directory pointer associated with an open file. Reporter confirms it fixes the crash. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Sat Apr 27 20:44:55 CEST 2013 on sn-devel-104
* smbd: Convert is_visible_file to synthetic_smb_fnameVolker Lendecke2013-04-171-4/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Convert dptr_create to synthetic_smb_fnameVolker Lendecke2013-04-171-8/+7
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Convert open_dir_with_privilege to synthetic_smb_fnameVolker Lendecke2013-04-171-5/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Convert smbd_dirptr_get_entry to cp_smb_filenameVolker Lendecke2013-04-171-3/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Cleanup. Remove unused function dptr_DirCacheAdd(). Make DirCacheAdd() static.Jeremy Allison2013-04-161-10/+3
| | | | | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Disseldorp <ddiss@suse.de> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Tue Apr 16 12:05:13 CEST 2013 on sn-devel-104
* Remove the "Ugly hack" that was the second use of dirfd().Jeremy Allison2013-04-121-13/+5
| | | | | | | The destructor does all the resource deallocation needed. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* In the struct smb_Dir destructor, use the fsp back pointer to release resources.Jeremy Allison2013-04-121-10/+13
| | | | | | | Removes one use of dirfd(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* Maintain a back-pointer to the fsp in struct smb_Dir when opening with ↵Jeremy Allison2013-04-121-1/+5
| | | | | | | FDOPENDIR. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
* smbd: Tune "dir" a bit.Volker Lendecke2013-03-221-6/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | for i in $(seq 1 20000) ; do echo dir ; done | smbclient //127.0.0.1/tmp -U% without and with this patch: $ time bin/smbd -d0 -i smbd version 4.1.0pre1-GIT-1f139ae started. Copyright Andrew Tridgell and the Samba Team 1992-2013 Beendet real 0m28.342s user 0m10.249s sys 0m10.513s $ time bin/smbd -d0 -i smbd version 4.1.0pre1-GIT-1f139ae started. Copyright Andrew Tridgell and the Samba Team 1992-2013 Beendet real 0m27.348s user 0m9.089s sys 0m10.853s The "real" timestamp is irrelevant, this also contains the time between starting smbd and the smbclient job. It's the "user" time. The result that this patch improves the time spent in user space by 10% is consistent. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri Mar 22 22:10:57 CET 2013 on sn-devel-104
* More for #9374 - Allow smb2.acls torture test to pass against smbd with a ↵Jeremy Allison2012-11-201-5/+9
| | | | | | | | | | | | | | | | | | | | POSIX ACLs backend. Change can_delete_directory() to can_delete_directory_fsp(), as we only ever call this from an open directory file handle. This allows us to use OpenDir_fsp() instead of OpenDir(). OpenDir() re-checks the ACL on the directory, which may refuse DIR_LIST permissions. OpenDir_fsp() does not. As this is a file-server internal check to see if the directory actually contains any files before setting delete on close, we can ignore the ACL here (Windows does). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Tue Nov 20 01:46:28 CET 2012 on sn-devel-104
* Add bool use_privs parameter to smbd_check_access_rights()Jeremy Allison2012-09-141-0/+2
| | | | | If this is set we should use it in preference to blindly assuming root can do anything. Currently set to 'false' in (most) callers.
* Add "backup_intent" bool.Jeremy Allison2012-09-141-1/+2
|
* build: Remove SMB_OFF_T, replace with off_tAndrew Bartlett2012-04-061-2/+2
| | | | | | | | | Now that we always require a 64 bit off_t, we no longer need SMB_OFF_T. Andrew Bartlett Autobuild-User: Andrew Bartlett <abartlet@samba.org> Autobuild-Date: Fri Apr 6 01:47:43 CEST 2012 on sn-devel-104
* build: Remove SMB_STRUCT_DIR defineAndrew Bartlett2012-04-051-1/+1
|
* Add open_dir_with_privilege() to ensure we're opening the correct directory ↵Jeremy Allison2012-03-011-2/+66
| | | | | | | when doing backup requests. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Thu Mar 1 03:50:40 CET 2012 on sn-devel-104
* Add accessor functions to set a bool "priv" on a directory handle. Not yet ↵Jeremy Allison2012-02-291-0/+11
| | | | used, but will be part of FLAG_TRANS2_FIND_BACKUP_INTENT code.
* Move dptr code over to TALLOC.Jeremy Allison2012-02-251-18/+9
| | | | | Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Sat Feb 25 03:50:24 CET 2012 on sn-devel-104
* Make dptr_path() and dptr_wcard() const.Jeremy Allison2012-02-241-2/+2
|
* s3: Fix some False/NULL hickupsVolker Lendecke2011-12-201-1/+1
| | | | | Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Tue Dec 20 13:13:17 CET 2011 on sn-devel-104
* s3: Move can_delete_directory to smbd/, remove shimVolker Lendecke2011-12-131-2/+2
| | | | | Autobuild-User: Volker Lendecke <vlendec@samba.org> Autobuild-Date: Tue Dec 13 19:00:37 CET 2011 on sn-devel-104
* s3:smbd: don't limit the number of open dptrs for smb2 (bug #8592)Stefan Metzmacher2011-11-101-3/+12
| | | | | | | | | | This fixes a crash bug that is triggered, when a client has more than 256 directory handles with searches. metze Autobuild-User: Stefan Metzmacher <metze@samba.org> Autobuild-Date: Thu Nov 10 14:08:14 CET 2011 on sn-devel-104
* s3:smbd: fully construct the dptr before allocating a dnum in the bitmapStefan Metzmacher2011-11-101-27/+29
| | | | metze
* s3:smbd: avoid string_set() in dir.cStefan Metzmacher2011-11-101-2/+9
| | | | | | And do some more error checks. metze
* Add the SEC_DIR_LIST check to dptr_create().Jeremy Allison2011-11-071-0/+27
| | | | | Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Mon Nov 7 21:11:03 CET 2011 on sn-devel-104
* Move the SEC_DIR_LIST check into dptr_create for SMB2 and now for SMB1.Jeremy Allison2011-11-051-0/+6
| | | | | | | The pathname check still needs fixing. Autobuild-User: Jeremy Allison <jra@samba.org> Autobuild-Date: Sat Nov 5 01:38:00 CET 2011 on sn-devel-104
* Remove can_access_file_acl(). We no longer need this duplicate code (hurrah!).Jeremy Allison2011-11-041-1/+3
|
* Revert "Call check_parent_access() on readdir."Jeremy Allison2011-11-041-13/+0
| | | | | | This reverts commit a763edaf9c76afe2546c035fc090370301dd347b. Checking the wrong thing..
* Call check_parent_access() on readdir.Jeremy Allison2011-11-011-0/+13
|