summaryrefslogtreecommitdiffstats
path: root/source3/smbd/open.c
Commit message (Collapse)AuthorAgeFilesLines
* s3: smbd: leases - new torture test shows stat opens can get leases.Jeremy Allison2015-02-191-7/+4
| | | | | | | | | Can also issue breaks on these leases. https://bugzilla.samba.org/show_bug.cgi?id=11102 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
* s3:locking: Change the data model for leases_db to cope with dynamic path ↵Jeremy Allison2014-12-091-29/+115
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | renames. interface leases_db { typedef [public] struct { GUID client_guid; smb2_lease_key lease_key; } leases_db_key; typedef [public] struct { file_id id; [string,charset(UTF8)] char *servicepath; [string,charset(UTF8)] char *base_name; [string,charset(UTF8)] char *stream_name; } leases_db_file; typedef [public] struct { uint32 num_files; [size_is(num_files)] leases_db_file files[]; } leases_db_value; } As designed by metze. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue Dec 9 03:44:04 CET 2014 on sn-devel-104
* s3:locking: pass down servicepath to leases_db_add()Jeremy Allison2014-12-091-2/+5
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3: leases: send_break_message() public.Jeremy Allison2014-12-051-1/+1
| | | | | | | | | We're going to need this to allow async SMB2 setinfo renames to send lease break messages as well as the open code. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:vfs: add create tags to SMB_VFS_CREATEFILERalph Boehme2014-12-041-3/+7
| | | | | Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smbd: Implementation of SMB2.1 and SMB3.0 leases.Volker Lendecke2014-12-041-135/+218
| | | | | | | | | Pair-Programmed-With: Jeremy Allison <jra@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:smbd: add lease key validation functions to open.cVolker Lendecke2014-12-041-0/+192
| | | | | | | | | | | | | This makes sure a lease key can only be used for one specific file. This also handles the dynamic share file case [homes]. Pair-Programmed-With: Jeremy Allison <jra@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:smbd: add lease related helper functions to open.cVolker Lendecke2014-12-041-0/+208
| | | | | | | | | Pair-Programmed-With: Jeremy Allison <jra@samba.org> Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:open_files.idl: add data structures for SMB2.1 and SMB3.0 leases.Stefan Metzmacher2014-12-041-3/+7
| | | | | | | Pair-Programmed-With: Volker Lendecke <vl@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org>
* s3:locking: convert brl_have_read field to brl_num_read.Volker Lendecke2014-11-111-11/+4
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:smbd: Don't set fsp->oplock_type before we've granted any oplocks.Jeremy Allison2014-11-111-3/+0
| | | | | | | | | It's not needed, and may lead to unexpected side effects. grant_fsp_oplock_type() is the only place to touch this. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:smbd: move all oplock granting code to grant_fsp_oplock_type()Volker Lendecke2014-11-111-29/+44
| | | | | | | | | Pair-Programmed-With: Stefan Metzmacher <metze@samba.org> Pair-Programmed-With: Jeremy Allison <jra@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org> Signed-off-by: Stefan Metzmacher <metze@samba.org> Signed-off-by: Jeremy Allison <jra@samba.org>
* s3:smbd: break oplocks to none with FILE_OVERWRITEVolker Lendecke2014-11-111-0/+1
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3:smbd: pass smbXsrv_connection to schedule_deferred_open_message_smb()Stefan Metzmacher2014-09-191-3/+3
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3:smbd: pass smbXsrv_connection to remove_deferred_open_message_smb()Stefan Metzmacher2014-09-191-1/+1
| | | | | Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
* s3: smbd: streams - Ensure share mode validation ignores internal opens ↵Volker Lendecke2014-09-121-1/+6
| | | | | | | | | | | (op_mid == 0). Fixes bug 10797 - smbd panic at find_oplock_types https://bugzilla.samba.org/show_bug.cgi?id=10797 Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: smbd - open logic fix.Jeremy Allison2014-09-111-0/+11
| | | | | | | | | | | | | | | | | | | | | | | As we atomically create using O_CREAT|O_EXCL, then if new_file_created is true, then file_existed *MUST* have been false (even if the file was previously detected as being there. We use the variable file_existed again in logic below this statement, so we must set file_existed = false, if new_file_created returns are true from open_file(). Based on a fix from Michael Adam. BUG: https://bugzilla.samba.org/show_bug.cgi?id=10809 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Reviewed-by: Michael Adam <obnox@samba.org> Autobuild-User(master): Michael Adam <obnox@samba.org> Autobuild-Date(master): Thu Sep 11 22:29:22 CEST 2014 on sn-devel-104
* s3:smbd:open_file: use a more natural check.Michael Adam2014-09-111-1/+3
| | | | | | | As suggested by Jeremy Allison <jra@samba.org>. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smbd: fix a race in open codeMichael Adam2014-09-101-17/+42
| | | | | | | | | | | | | The race is when a file vanishes between existence check and acl check. In this case, open_file_ncreate() returns OBJECT_NAME_NOT_FOUND even if the create was called with disposition OPEN_IF. But in this case, the file should be created. Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Fix a typoVolker Lendecke2014-09-101-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Pass down "lease" to open_file_ntcreateVolker Lendecke2014-08-111-0/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Pass down "lease" to create_file_unixpathVolker Lendecke2014-08-111-2/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* vfs3: Pass "lease" through SMB_VFS_CREATE_FILEVolker Lendecke2014-08-111-0/+3
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Remove 2 indentation levelsVolker Lendecke2014-06-251-11/+11
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* s3: smbd - Prevent file truncation on an open that fails with share mode ↵Jeremy Allison2014-06-251-2/+20
| | | | | | | | | | | | | | | | | violation. Fix from Volker, really - just tidied up a little. The S_ISFIFO check may not be strictly neccessary, but doesn't hurt (might make the code a bit more complex than it needs to be). Fixes bug #10671 - Samba file corruption as a result of failed lock check. https://bugzilla.samba.org/show_bug.cgi?id=10671 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* smbd: Fix bug 10593Volker Lendecke2014-06-211-1/+1
| | | | | | | | | | | | | Bug 10593 is a panic that happens if we get an oplock break reply via dbwrap_watch for which we can't find the SMB request anymore. This error condition can legally happen when a client cancels the create request before the oplock break response comes in. This patch drops the dbwrap_watch_send request waiting for the oplock break when the request is cancelled. Yet another talloc hierarchy problem, but if done right, talloc hierarchies can make rundown of state easy :-) Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: First watch, then deferVolker Lendecke2014-06-211-5/+6
| | | | | | | | We exit if any of these if-statement fails, so a simple swap should not make a difference. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Store "struct deferred_open_record" instead of anonymous data on pmlVolker Lendecke2014-06-211-8/+16
| | | | | | | | The main point is to get a talloc parent that will go away when the request is cancelled Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Fix a typoVolker Lendecke2014-05-271-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
* s3: smbd: Remove open_file_fchmod().Jeremy Allison2014-05-021-33/+0
| | | | | | | | | | | | | | No longer used (hurrah!). Bug 10564 - Lock order violation and file lost https://bugzilla.samba.org/show_bug.cgi?id=10564 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Fri May 2 23:47:38 CEST 2014 on sn-devel-104
* s3: smbd : Ensure file_new doesn't call into smbXsrv_open_create() for ↵Jeremy Allison2014-05-021-3/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | INTERNAL_OPEN_ONLY. This causes deadlocks which cause smbd to crash if the locking database has already been locked for a compound operation we need to be atomic (as in the file rename case). Ensure INTERNAL_OPEN_ONLY opens are synonymous with req==NULL. INTERNAL_OPEN_ONLY opens leave a NO_OPLOCK record in the share mode database, so they can be detected by other processes for share mode violation purposes (because they're doing an operation on the file that may include reads or writes they need to have real state inside the locking database) but have an fnum of FNUM_FIELD_INVALID and a local share_file_id of zero, as they will never be seen on the wire. Ensure validate_my_share_entries() ignores INTERNAL_OPEN_ONLY records (share_file_id == 0). Bug 10564 - Lock order violation and file lost https://bugzilla.samba.org/show_bug.cgi?id=10564 Signed-off-by: Jeremy Allison <jra@samba.org> Signed-off-by: Volker Lendecke <vl@samba.org>
* smbd: Use fsp->file_id in open_file_ntcreateVolker Lendecke2014-03-211-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Explicitly pass "file_id" to schedule_defer_openVolker Lendecke2014-03-211-3/+4
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* param: rename lp function and variable from "inherit_perms" to ↵Garming Sam2014-02-071-2/+2
| | | | | | | | "inherit_permissions" 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 "symlinks" to "follow_symlinks"Garming Sam2014-02-071-1/+1
| | | | | | Signed-off-by: Garming Sam <garming@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: Don't open the dir for stat/attr/acl related maskAbhidnya Joshi2014-01-231-10/+21
| | | | | | | | | Signed-off-by: Abhidnya Joshi <achirmul@in.ibm.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Thu Jan 23 03:56:35 CET 2014 on sn-devel-104
* smbd - allow updates on directory write times on open handles.Jeremy Allison2013-12-051-1/+8
| | | | | | | | | | | | | | | | | | | If we set a non-null 'old timestamp' in the share mode database when creating a directory handle, this prevents mtime (write time) updates from being seen by clients, as we will always return the timestamp stored in the database whilst the handle is open. For files this is ok, as we update the stored timestamp ourselves when we write to the handle. For directories we should just rely on the mtime value from the underlying filesystem. Torture test to follow. BUG: https://bugzilla.samba.org/show_bug.cgi?id=9870 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* smbd: Pull mtime handling into open_file_ntcreateVolker Lendecke2013-11-231-0/+23
| | | | | | | | | | | | | | This is a performance improvement for heavily contended files, in particular in a cluster. The separate call to get_file_infos makes us pull the locking.tdb record twice per open. For a contended file this can be a performance penalty, this gets the # of record accesses for the open/close cycle down from 3 to 2. 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): Sat Nov 23 00:40:49 CET 2013 on sn-devel-104
* smbd/open: disable compression with FILE_NO_COMPRESSIONDavid Disseldorp2013-11-221-0/+12
| | | | | | | | Files and directories created with FILE_NO_COMPRESSION should not inherit the compression attribute from their parent directory. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* Fix bug #10229 - No access check verification on stream files.Jeremy Allison2013-11-041-0/+59
| | | | | | | | | | | | | https://bugzilla.samba.org/show_bug.cgi?id=10229 We need to check if the requested access mask could be used to open the underlying file (if it existed), as we're passing in zero for the access mask to the base filename. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: David Disseldorp <ddiss@suse.de>
* Revert "smbd: Move oplock/sharemode ops into one place"Volker Lendecke2013-10-251-3/+10
| | | | | | | | | | | | | This reverts commit 7b70fa18734d9ceb020fe3e5d4cc0c26cd27a484. This is a change in behaviour which needs much further investigation and testing. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Fri Oct 25 14:22:20 CEST 2013 on sn-devel-104
* Revert "smbd: Move oplock handling together"Volker Lendecke2013-10-251-7/+7
| | | | | | | | | | This reverts commit e689b7d51e6ffd848ab10e160dca2c3a03fc750b. This is a change in behaviour which needs much further investigation and testing. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* smbd: Move oplock handling togetherVolker Lendecke2013-10-241-7/+7
| | | | | | | Later on we will have all the oplock/sharemode operations in one routine. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* smbd: Move oplock/sharemode ops into one placeVolker Lendecke2013-10-241-10/+3
| | | | | | | | | This makes the is_stat_open special case in grant_fsp_oplock_type redundant because in open_file_ntcreate further up we have already set oplock_request to NO_OPLOCK for stat opens. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* smbd: Remove separate oplock_type parameter from set_file_oplockVolker Lendecke2013-10-241-1/+1
| | | | | | | | This avoids the question where it could happen that something else but fsp->oplock_type might be useful as an argument here. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org>
* smbd: Fix breaking level2 on OVERWRITE create_dispositionVolker Lendecke2013-10-231-0/+11
| | | | | | | This is shown by the new raw.oplock.level_ii_1 test Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Fix raw.batch.exclusive[59]Volker Lendecke2013-10-231-6/+23
| | | | | | | | | | | | | | | The level we have to break to depend on the breakers create_disposition: If we overwrite, we have to break to none. This patch overloads the "op_type" field in the break message we send across to the smbd holding the oplock with the oplock level we want to break to. Because it depends on the create_disposition in the breaking open, only the breaker can make that decision. We might want to use a different mechanism for this in the future, but for now using the op_type field seems acceptable to me. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Remove unused "mid" from delay_for_oplockVolker Lendecke2013-10-231-3/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Don't send op_mid in a BREAK messageVolker Lendecke2013-10-231-5/+3
| | | | | | | The callee doesn't use this anyway Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* smbd: Simplify send_break_messageVolker Lendecke2013-10-231-4/+4
| | | | | | | We don't need an fsp here Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>