summaryrefslogtreecommitdiff
path: root/source3/smbd/open.c
Commit message (Collapse)AuthorAgeFilesLines
* smbd: Use leases_db in try_lease_upgrade()Volker Lendecke2019-04-141-22/+38
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Split up grant_fsp_lease()Volker Lendecke2019-04-141-76/+100
| | | | | | | Simple refactoring into simpler routines. View best with "git show -b" Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Add update_share_mode_lease_from_db()Volker Lendecke2019-04-141-0/+55
| | | | | | | | | | This is an interim function supposed to be around for just a few patches as long as we have both the leases.tdb entries and the leases[] in share_mode_entries around. It makes it easier to transition to just use leases.tdb while keeping the code running. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Don't pass up lease_idx from grant_fsp_leaseVolker Lendecke2019-04-141-8/+1
| | | | | | | | The only reason for grant_fsp_lease to return the lease_idx was to pass it down to set_share_mode. That does not need it anymore. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Don't pass lease_idx down to set_share_mode()Volker Lendecke2019-04-141-7/+22
| | | | | | | | | Temporary patch to keep the code running. The new code in set_share_mode() will leave again once the patchset to remove share_mode_lease and thus the lease_idx in share_mode_entry goes away. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use leases_db in delay_for_oplock()Volker Lendecke2019-04-141-1/+13
| | | | | | | Remove a reference to share_mode_data->leases[] Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use share_mode_entry's lease data in lease_match()Volker Lendecke2019-04-141-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use share_mode_entry's lease data in is_same_lease()Volker Lendecke2019-04-141-2/+2
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use share_mode_entry's lease data in delay_for_oplock()Volker Lendecke2019-04-141-5/+3
| | | | | | | | This was the last "share_mode_lease" reference in this function, remove variable "l". Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Use leases_db_set()Volker Lendecke2019-04-141-0/+20
| | | | | | | | Whenever we update the share_mode_lease struct, also update the leases.tdb entry. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* leases_db: Add share_mode_lease info to leases.tdbVolker Lendecke2019-04-141-0/+3
| | | | | | | | | This is the data stored in share_mode_lease inside the leases[] array in locking.tdb. This and all the following patches move all leases array to looking at the leases.tdb. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Pass lease parameters explicitly to find_fsp_leaseVolker Lendecke2019-04-141-5/+12
| | | | | | | This avoids a use of "struct share_mode_lease" Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Introduce a helper variable in delay_for_oplock()Volker Lendecke2019-04-141-2/+4
| | | | | | | This removes a few explicit share_mode_lease dereferences Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Introduce a helper variable in delay_for_oplock()Volker Lendecke2019-04-141-5/+6
| | | | | | | | | Why? I am preparing a patchset that will remove "share_mode_lease". This patch is a micro-step towards that, removing a set of references to this struct. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Christof Schmitt <cs@samba.org>
* smbd: Factor out map_lease_type_to_oplockVolker Lendecke2019-04-091-15/+21
| | | | | | | grant_fsp_oplock_type has enough complex logic, make this a bit shorter Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: fix check_parent_access() talloc stackframe leaksDavid Disseldorp2019-03-151-13/+18
| | | | | | | | | | | check_parent_access() currently leaks a number of allocations onto the talloc_tos() context in both success and error paths. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Fri Mar 15 11:32:04 UTC 2019 on sn-devel-144
* Revert "smbd: add an effective {smb,smbd_smb2}_request->ev_ctx that holds ↵Ralph Boehme2019-01-111-4/+4
| | | | | | | | | | | | | | | | the event context used for the request processing" This reverts commit 894e5001c747ce765dad5517778dda55d7d1f4d9. See the discussion in https://lists.samba.org/archive/samba-technical/2018-December/131731.html for the reasoning behind this revert. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* Fix spelling mistakesOlly Betts2018-11-301-2/+2
| | | | | | Signed-off-by: Olly Betts <olly@survex.com> Reviewed-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
* s3:smbd: add twrp args to filename_convert()Ralph Boehme2018-11-271-0/+1
| | | | | | | | | All existing callers pass NULL, no change in behaviour. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13455 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Fix DELETE_ON_CLOSE behaviour on files with READ_ONLY attributeChristof Schmitt2018-11-031-8/+22
| | | | | | | | | | | | | | MS-FSA states that a CREATE with FILE_DELETE_ON_CLOSE on an existing file with READ_ONLY attribute has to return STATUS_CANNOT_DELETE. This was missing in smbd as the check used the DOS attributes from the CREATE instead of the DOS attributes on the existing file. We need to handle the new file and existing file cases separately. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13673 Signed-off-by: Christof Schmitt <cs@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smbd: remove "0x" string prefix from dev/inoRalph Boehme2018-10-311-9/+9
| | | | | | | | | | We used %llu as conversion specifier which results in a decimal number being printed, so remove the misleading "0x" prefix. While at it, I'll change %llu to the terse %ju. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3:smbd: Move a variable declaration closer to its useVolker Lendecke2018-10-251-1/+1
| | | | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Oct 25 21:44:17 CEST 2018 on sn-devel-144
* smbd: Simplify lease_match() a bitVolker Lendecke2018-09-071-2/+0
| | | | | | | | This has been implicitly initialized to 0 with the explicit struct initializer above. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* smbd: Fix a typoVolker Lendecke2018-08-171-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: add an effective {smb,smbd_smb2}_request->ev_ctx that holds the event ↵Stefan Metzmacher2018-06-181-4/+4
| | | | | | | | | | context used for the request processing In future this will an impersonation wrapper tevent_context based on the user session. Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3:smbd: add private option NTCREATEX_OPTIONS_PRIVATE_STREAM_BASEOPENRalph Boehme2018-05-301-1/+6
| | | | | | | | | | | This will be used to mark basefile opens of streams opens. This is needed to later implement a function that can determine if a file has stream opens. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13451 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: smbd: Use FCHMOD call, not FCHMOD_ACL call if mode bits reset needed.Jeremy Allison2018-05-251-6/+6
| | | | | | | | | | | | | | | | | | | | This is a behavior change, it will modify the POSIX ACL mask from a value of rwx instead of modifying the existing ACE entries to be ANDed with the passed in mode. However it will have no effect on the underlying permissions, and better reflects the proper use of POSIX ACLs (i.e. I didn't understand the use of the mask entry in the ACL when I first wrote the POSIX ACL code). In addition, the vfs_acl_common.c module already filters these calls for all but POSIX opens, which means the only place this change is exposed to the client would be a cifsfs unix extensions client doing posix acl calls (and they would expect the mask to be set like this on chmod). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: smbd: Optimization. Only do the FCHMOD_ACL call if mode bits not equal.Jeremy Allison2018-05-251-6/+7
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: smbd: optimization. Only do the FCHMOD call if needed.Jeremy Allison2018-05-251-3/+5
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: smbd: Remove use of SMB_VFS_FCHMOD_ACL() in overwrite case.Jeremy Allison2018-05-251-24/+5
| | | | | | | | | | | We have potentially called SMB_VFS_FCHMOD() here in the file_set_dosmode() call associated with the comment /* Overwritten files should be initially set as archive */ at line 3755 above, so there is no need to do any POSIX ACL mask protection. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: smbd: Add clarifying comment on mode change on overwritten files.Jeremy Allison2018-05-251-0/+19
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* s3: smbd: Remove existing_unx_mode, an unused parameter to ↵Jeremy Allison2018-05-251-4/+1
| | | | | | | open_match_attributes(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
* Convert affected by previous commit lines from DEBUG(10,..) to DBG_DEBUG().Timur I. Bakeyev2018-05-161-4/+4
| | | | | | | | | Signed-off-by: Timur I. Bakeyev <timur@iXsystems.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Wed May 16 21:29:24 CEST 2018 on sn-devel-144
* Remove extra 0x prefix for the "%p" format specifiers, avoiding 0x0x0 ↵Timur I. Bakeyev2018-05-161-2/+2
| | | | | | | | strings in the output. Signed-off-by: Timur I. Bakeyev <timur@iXsystems.com> Reviewed-by: Ralph Boehme <slow@samba.org> Reviewed-by: Martin Schwenke <martin@meltin.net>
* Fix spelling s/missmatch/mismatch/Mathieu Parent2018-05-121-1/+1
| | | | | | Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* Fix spelling s/desriptor/descriptor/Mathieu Parent2018-05-121-1/+1
| | | | | | Signed-off-by: Mathieu Parent <math.parent@gmail.com> Reviewed-by: Andrew Bartlett <abartlet@samba.org> Reviewed-by: Garming Sam <garming@catalyst.net.nz>
* smbd: Fix CID 240676 Dereference after null checkVolker Lendecke2018-04-041-0/+7
| | | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
* s3: smbd: Files or directories can't be opened DELETE_ON_CLOSE without ↵Jeremy Allison2018-03-291-0/+12
| | | | | | | | | delete access. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13358 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <Volker.Lendecke@SerNet.DE>
* smbd: Pass "file_id" explicitly to send_break_message()Volker Lendecke2018-02-131-6/+7
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Pass "file_id" explicitly into share_mode_entry_to_message()Volker Lendecke2018-02-131-1/+1
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Pass in "file_id" into validate_my_share_entriesVolker Lendecke2018-02-131-5/+5
| | | | | Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* smbd: Pass in "file_id" into share_mode_str()Volker Lendecke2018-02-131-4/+6
| | | | | | | This used to directly access share_entry->id, which will go Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3/smbd: fix handling of delete-on-close on directoriesRalph Boehme2018-02-031-1/+44
| | | | | | | | | | | | | | | | | | This implements a check to test the delete-on-close flag of a directory for requests to create files in this directory. Windows server implement this check, Samba doesn't as it has performance implications. This commit implements the check and a new option to control it. By default the check is skipped, setting "check parent directory delete on close = yes" enables it. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Ralph Böhme <slow@samba.org> Autobuild-Date(master): Sat Feb 3 23:42:16 CET 2018 on sn-devel-144
* dbwrap_watch: Remove the "prec" parameter from watch_recvVolker Lendecke2017-11-291-2/+1
| | | | | | | | | | | The initial idea was to have some "atomicity" in this API. Every caller interested in a record would have to do something with it once it changes. However, only one caller really used this feature, and that is easily changed to not use it. So remove the complexity. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* s3: smbd: kernel oplocks. Replace retry_open() with ↵Jeremy Allison2017-11-111-28/+68
| | | | | | | | | | | | | | | | | | | setup_kernel_oplock_poll_open(). If a O_NONBLOCK open fails with EWOULDBLOCK, this code changes smbd to do a retry open every second, until either the timeout or we get a successful open. If we're opening a file that has a kernel lease set by a non-smbd process, this is the best we can do. Prior to this, smbd would block on the second open on such a leased file (not using O_NONBLOCK) which freezes active clients. Regression test to follow. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13121 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
* Revert "s3/smbd: fix deferred open with streams and kernel oplocks"Jeremy Allison2017-11-101-104/+11
| | | | | | | | | | | | | | | | | | | | | | This reverts commit b35a296a27a0807c780f2a9e7af2f2e93feefaa8. This was the cause of BUG: https://bugzilla.samba.org/show_bug.cgi?id=13058 1. client of smbd-1 opens the file and sets the oplock. 2. client of smbd-2 tries to open the file. open() fails(EAGAIN) and open is deferred. 3. client of smbd-1 sends oplock break request to the client. 4. client of smbd-1 closes the file. 5. client of smbd-1 opens the file and sets the oplock. 6. client of smbd-2 calls defer_open_done(), sees that the file lease was not changed and does not reschedule open. and is no longer needed now vfs_streams_xattr.c no longer opens the base file internally. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Böhme <slow@samba.org>
* s3/smbd: let non_widelink_open() chdir() to directories directlyRalph Boehme2017-07-071-5/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the caller passes O_DIRECTORY we just try to chdir() to smb_fname directly, not to the parent directory. The security check in check_reduced_name() will continue to work, but this fixes the case of an open() for a previous version of a subdirectory that contains snapshopt. Eg: [share] path = /shares/test vfs objects = shadow_copy2 shadow:snapdir = .snapshots shadow:snapdirseverywhere = yes Directory tree with fake snapshots: $ tree -a /shares/test/ /shares/test/ ├── dir │   ├── file │   └── .snapshots │   └── @GMT-2017.07.04-04.30.12 │   └── file ├── dir2 │   └── file ├── file ├── .snapshots │   └── @GMT-2001.01.01-00.00.00 │   ├── dir2 │   │   └── file │   └── file └── testfsctl.dat ./bin/smbclient -U slow%x //localhost/share -c 'ls @GMT-2017.07.04-04.30.12/dir/*' NT_STATUS_OBJECT_NAME_NOT_FOUND listing \@GMT-2017.07.04-04.30.12\dir\* Bug: https://bugzilla.samba.org/show_bug.cgi?id=12885 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
* s3: VFS: Change SMB_VFS_CONNECTPATH to take const struct smb_filename * ↵Jeremy Allison2017-07-011-1/+1
| | | | | | | | | | | | | instead of const char *. We need to migrate all pathname based VFS calls to use a struct to finish modernising the VFS with extra timestamp and flags parameters. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Sat Jul 1 07:20:28 CEST 2017 on sn-devel-144
* S3: smbd: Finish plumbing struct smb_filename * through the check_name() stack.Jeremy Allison2017-07-011-7/+7
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
* s3: smbd: Add missing out of memory check.Jeremy Allison2017-07-011-0/+4
| | | | | Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>