1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

802 Commits

Author SHA1 Message Date
Volker Lendecke
837e29035c s3:locking: convert brl_have_read field to brl_num_read.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-11-11 21:41:05 +01:00
Jeremy Allison
1020c5942a s3:smbd: Don't set fsp->oplock_type before we've granted any oplocks.
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>
2014-11-11 21:41:05 +01:00
Volker Lendecke
a08b0e7822 s3:smbd: move all oplock granting code to grant_fsp_oplock_type()
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>
2014-11-11 21:41:05 +01:00
Volker Lendecke
87a102189b s3:smbd: break oplocks to none with FILE_OVERWRITE
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2014-11-11 21:41:04 +01:00
Stefan Metzmacher
56d454b4ae s3:smbd: pass smbXsrv_connection to schedule_deferred_open_message_smb()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Stefan Metzmacher
b05ae37da6 s3:smbd: pass smbXsrv_connection to remove_deferred_open_message_smb()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2014-09-19 09:15:12 +02:00
Volker Lendecke
c6e726f719 s3: smbd: streams - Ensure share mode validation ignores internal opens (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>
2014-09-12 12:16:10 +02:00
Jeremy Allison
518247bf80 s3: smbd - open logic fix.
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
2014-09-11 22:29:22 +02:00
Michael Adam
9da09b52e8 s3:smbd:open_file: use a more natural check.
As suggested by Jeremy Allison <jra@samba.org>.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-09-11 01:27:15 +02:00
Michael Adam
8ae8c63da1 s3:smbd: fix a race in open code
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>
2014-09-10 19:24:13 +02:00
Volker Lendecke
551ae16ab3 smbd: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-09-10 19:24:13 +02:00
Volker Lendecke
174275e069 smbd: Pass down "lease" to open_file_ntcreate
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-11 21:11:16 +02:00
Volker Lendecke
1230954806 smbd: Pass down "lease" to create_file_unixpath
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-11 21:11:16 +02:00
Volker Lendecke
446de4f680 vfs3: Pass "lease" through SMB_VFS_CREATE_FILE
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-08-11 21:11:16 +02:00
Volker Lendecke
1dc5c20c8f smbd: Remove 2 indentation levels
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
2014-06-25 11:22:12 +02:00
Jeremy Allison
31b3427a41 s3: smbd - Prevent file truncation on an open that fails with share mode 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>
2014-06-25 11:22:12 +02:00
Volker Lendecke
713518a4c8 smbd: Fix bug 10593
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>
2014-06-21 20:38:11 +02:00
Volker Lendecke
0c2e763aaa smbd: First watch, then defer
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>
2014-06-21 20:38:11 +02:00
Volker Lendecke
0ead434b84 smbd: Store "struct deferred_open_record" instead of anonymous data on pml
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>
2014-06-21 20:38:11 +02:00
Volker Lendecke
e3ca29f3a1 smbd: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Martin Schwenke <martin@meltin.net>
2014-05-27 02:15:10 +02:00
Jeremy Allison
ffaa2849e5 s3: smbd: Remove open_file_fchmod().
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
2014-05-02 23:47:38 +02:00
Jeremy Allison
580eb9424c s3: smbd : Ensure file_new doesn't call into smbXsrv_open_create() for 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>
2014-05-02 21:27:07 +02:00
Volker Lendecke
b27c5caae3 smbd: Use fsp->file_id in open_file_ntcreate
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-21 19:20:17 +01:00
Volker Lendecke
a5cd8a513f smbd: Explicitly pass "file_id" to schedule_defer_open
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-03-21 19:20:17 +01:00
Garming Sam
51f8a24d26 param: rename lp function and variable from "inherit_perms" to "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>
2014-02-07 16:19:15 -08:00
Garming Sam
5f4159b25b param: rename lp function and variable from "symlinks" to "follow_symlinks"
Signed-off-by: Garming Sam <garming@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2014-02-07 16:19:13 -08:00
Abhidnya Joshi
7638f52145 s3: Don't open the dir for stat/attr/acl related mask
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
2014-01-23 03:56:35 +01:00
Jeremy Allison
a926d0f461 smbd - allow updates on directory write times on open handles.
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>
2013-12-05 08:12:09 +01:00
Volker Lendecke
a793ac016d smbd: Pull mtime handling into open_file_ntcreate
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
2013-11-23 00:40:49 +01:00
David Disseldorp
9a3d4d484e smbd/open: disable compression with FILE_NO_COMPRESSION
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>
2013-11-22 08:56:45 -08:00
Jeremy Allison
60f922bf1b Fix bug #10229 - No access check verification on stream files.
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>
2013-11-04 12:10:18 -08:00
Volker Lendecke
ef4054eb88 Revert "smbd: Move oplock/sharemode ops into one place"
This reverts commit 7b70fa1873.

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
2013-10-25 14:22:20 +02:00
Volker Lendecke
4378db9819 Revert "smbd: Move oplock handling together"
This reverts commit e689b7d51e.

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>
2013-10-25 12:33:30 +02:00
Volker Lendecke
e689b7d51e smbd: Move oplock handling together
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>
2013-10-24 14:22:08 +02:00
Volker Lendecke
7b70fa1873 smbd: Move oplock/sharemode ops into one place
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>
2013-10-24 14:22:05 +02:00
Volker Lendecke
184cc138b6 smbd: Remove separate oplock_type parameter from set_file_oplock
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>
2013-10-24 14:22:03 +02:00
Volker Lendecke
6c3b41cfc2 smbd: Fix breaking level2 on OVERWRITE create_disposition
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>
2013-10-23 12:05:43 +02:00
Volker Lendecke
20669d4a75 smbd: Fix raw.batch.exclusive[59]
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>
2013-10-23 11:58:56 +02:00
Volker Lendecke
ccc808e0d7 smbd: Remove unused "mid" from delay_for_oplock
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-10-23 11:57:05 +02:00
Volker Lendecke
4c8bdf7878 smbd: Don't send op_mid in a BREAK message
The callee doesn't use this anyway

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-10-23 11:56:21 +02:00
Volker Lendecke
de95b9d11d smbd: Simplify send_break_message
We don't need an fsp here

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-10-23 11:55:33 +02:00
Volker Lendecke
cb27921274 smbd: Remove unused "oplock_request" arg from send_break_message
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-10-23 11:51:43 +02:00
Volker Lendecke
9890a6a36d smbd: validate oplock types even for internal and stat opens
There's no reason why we should not do this. This has turned into a pure
internal consistency check that should apply fine every time.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-10-23 11:47:19 +02:00
Volker Lendecke
f892bdb204 smbd: Fix bug 10216
While refactoring find_oplock_types to validate_oplock_types I forgot
that stat opens will end up in locking.tdb. So even with a batch oplock
around we can have more than one entry. This means the consistency check
in validate_oplock_types was wrong and too strict.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-10-23 11:44:37 +02:00
Volker Lendecke
a1fcd71f9a smbd: Simplify open_file_ntcreate
Only one call to delay_for_oplocks left. Metze showed me the new logic:
BATCH is broken if we have a sharing violation. Exclusive is broken
otherwise. That's it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>

Autobuild-User(master): Michael Adam <obnox@samba.org>
Autobuild-Date(master): Wed Oct 16 02:51:53 CEST 2013 on sn-devel-104
2013-10-16 02:51:53 +02:00
Volker Lendecke
4c0cf9fade smbd: Remove "file_existed" handling from open_mode_check
No clue what this does. In open_directory, "dir_existed" is not used after
open_mode_check. In open_file_ntcreate it's used, but I can't think of a case
right now where we would find a formerly nonexisting file to exist suddenly.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-10-16 00:50:13 +02:00
Volker Lendecke
4263d16f13 smbd: Decouple grant_fsp_oplock_type from oplock validation
This makes grant_fsp_oplock_type independent from the values computed
in validate_oplock_types. It *might* make oplock calculation a bit
slower for heavily shared files, as we are walking the share mode array
twice. But we are doing so much stuff in open that I doubt the difference
is measurable. It clears up the code for me however, and I think that's
worth it.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-10-16 00:45:43 +02:00
Volker Lendecke
00d84ad192 smbd: Reduce the complexity of open_file_ntcreate
This removes two variables in open_file_ntcreate based on the observation
that for exclusive and batch oplocks there can only be one entry. So
in these cases we don't need to keep pointers from find_oplock_types to
delay_for_oplocks. We can just reference the only share mode entry around.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-10-16 00:33:47 +02:00
Volker Lendecke
4d85f91a5b smbd: Make find_oplock_types return bool
smb_panic() does not take a printf style argument. This improves debug
output by easily printing the index that we fell over. Also, doing
smb_panic deep down is bad style IMHO.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-10-15 23:44:37 +02:00
Volker Lendecke
0f71730d1b smbd: Make loop index type match loop limit
share_mode_data.num_share_modes is a uint32.

48 bytes less in .o text size for -O3 :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-10-15 23:43:30 +02:00
Volker Lendecke
388bf3643d smbd: Unify delay_for_*_oplocks
This is the same code in both routines

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-10-15 23:42:41 +02:00
Volker Lendecke
c33015c069 smbd: Simplify find_oplock_types a bit
Define a variable to dereference lck->data just once. Believe it or not,
this saves a few bytes .o with -O3 :-)

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-10-15 23:38:27 +02:00
Volker Lendecke
fcafaf6022 smbd: Remove FAKE_LEVEL_II_OPLOCK
FAKE_LEVEL_II_OPLOCK was an indicator to break level2 oplock holders
on write.  This information is now being held in brlock.tdb, which makes
the FAKE_LEVEL_II_OPLOCK type unnecessary.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-10-15 01:52:29 +02:00
Volker Lendecke
dd0e4c47e5 smbd: Remove unused create_options from open_mode_check
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>

Autobuild-User(master): Stefan Metzmacher <metze@samba.org>
Autobuild-Date(master): Sun Oct 13 14:35:26 CEST 2013 on sn-devel-104
2013-10-13 14:35:26 +02:00
Volker Lendecke
4c82e8358a smbd: Remove name_hash param from open_mode_check
This came from delete_on_close handling which was factored out.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-10-13 12:43:32 +02:00
Volker Lendecke
7a6d240b7f smbd: Fix the extended *.oplock.doc1 tests
We need to check for DELETE_PENDING before the first oplock break

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 Oct 12 01:56:18 CEST 2013 on sn-devel-104
2013-10-12 01:56:18 +02:00
Volker Lendecke
02393156de smbd: Fix an error path in open_directory
In open_file_ntcreate we do the del_share_mode on error. We should do
it here as well.

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 Oct  9 01:58:55 CEST 2013 on sn-devel-104
2013-10-09 01:58:55 +02:00
Volker Lendecke
e0e5f67da5 smbd: Convert set_share_mode to return bool for success
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-10-08 14:42:25 -07:00
Volker Lendecke
41857bd0f7 smbd: Fix confusing comments
The brlock-check is done in grant_fsp_oplock_type

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-10-06 13:54:33 +02:00
Volker Lendecke
6bcfc1a9da smbd: Add brl_num_locks access function 2013-09-11 08:27:11 +02:00
Michael Adam
1e29d73066 s3:smbd: ease file server upgrades from 3.6 and earlier with "acl allow execute aways"
3.6 and earlier allowed open for execution when execute permissions are
not present on a file. This has been fixed in Samba 4.0.

This patch changes smbd to skip the execute bit from the ACL check
in the open code if "acl allow execute always = yes", hence
re-establishing the old behaviour in this case.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Reviewed-by: David Disseldorp <ddiss@samba.org>
2013-09-10 23:33:12 +02:00
Volker Lendecke
392889c8bc smbd: Slightly simplify send_break_message
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-09-06 13:41:59 +02:00
Volker Lendecke
4ecf8b4db6 smbd: Remove a silly "? true : false"
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-09-06 13:40:58 +02:00
Volker Lendecke
1bf10ad806 smbd: Remove two confusing TALLOC_FREE calls
We don't have lck allocated yet at these points. Remove the TALLOC_FREE
calls that triggered me looking for the get_share_mode_lock calls.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-09-06 13:39:16 +02:00
Volker Lendecke
196da5925b smbd: Remove FORCE_OPLOCK_BREAK_TO_NONE
This flag existed to break an exclusive or batch oplock in just one
instead of two steps down to "no oplock" when we did an allocation or file
size change.  Running raw.oplock against W2k12 differs in this respect
from W2k3: W2k12 takes two steps (via level2) to break to none. This
removes the special flag that we only had for compatibility with systems
older than W2k12...

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 Sep  6 00:47:07 CEST 2013 on sn-devel-104
2013-09-06 00:47:07 +02:00
Volker Lendecke
94b320527e smbd: Simplify find_oplock_types
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2013-09-03 17:13:52 +02:00
Jeremy Allison
4111fcfd4f Only do the 1 second delay for sharing violations for SMB1, not SMB2.
Match Windows behavior.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>
2013-05-07 17:58:45 +02:00
Volker Lendecke
8283fd0e00 smbd: Do not fetch the record in defer_open_done
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 Apr 27 02:06:10 CEST 2013 on sn-devel-104
2013-04-27 02:06:10 +02:00
Volker Lendecke
a7e803485d smbd: We don't use DEFERRED_OPEN_ENTRY anymore
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-26 15:17:22 -07:00
Volker Lendecke
afe9446985 smbd: Use dbwrap_record_watch_send for defer_open
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-26 15:17:21 -07:00
Volker Lendecke
cc0b8351a4 smbd: Convert create_file_unixpath to synthetic_smb_fname
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-17 14:50:03 -07:00
Volker Lendecke
421eeef732 smbd: Convert open_streams_for_delete to synthetic_smb_fname
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-17 14:50:02 -07:00
Volker Lendecke
66beff7dd0 smbd: Convert msg_file_was_renamed to synthetic_smb_fname
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-17 14:50:02 -07:00
Volker Lendecke
39c5a77b0a smbd: Convert change_dir_owner_to_parent to synthetic_smb_fname
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-17 14:50:01 -07:00
Volker Lendecke
d003f2ff80 smbd: Convert change_dir_owner_to_parent to synthetic_smb_fname
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-17 14:50:01 -07:00
Volker Lendecke
c9a220bdaf smbd: Convert change_file_owner_to_parent to synthetic_smb_fname
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2013-04-17 14:50:01 -07:00
Volker Lendecke
0f9eb25183 smbd: Fix an error return in change_dir_owner_to_parent
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Richard Sharpe <realrichardsharpe@gmail.com>

Autobuild-User(master): Richard Sharpe <sharpe@samba.org>
Autobuild-Date(master): Mon Apr 15 18:05:06 CEST 2013 on sn-devel-104
2013-04-15 18:05:06 +02:00
Stefan Metzmacher
8fbe39d513 s3:smbd/open: fall back to Builtin_Administrators if SYSTEM doesn't map to a group
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2012-12-02 18:32:36 +01:00
Stefan Metzmacher
139232656a s3:smbd/open: try the primary sid (user) as group_sid if the token has just one sid
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2012-12-02 18:32:04 +01:00
Stefan Metzmacher
0a3396b536 s3:smbd/open: use Builtin_Administrators as owner of files (if possible)
We do this if the idmap layer resolves Builtin_Administrators
as ID_TYPE_BOTH and if the current token has the
Builtin_Administrators SID or it's SYSTEM.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2012-12-02 18:31:00 +01:00
Stefan Metzmacher
b3eb78c4f7 s4:smbd/open: add missing TALLOC_FREE(frame) to inherit_new_acl()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2012-11-28 12:21:42 +01:00
Jeremy Allison
4985332b95 Add comments explaining exactly *why* we don't check FILE_READ_ATTRIBUTES when evaluating file/directory ACE's.
If we can access the path to this file, by
default we have FILE_READ_ATTRIBUTES from the
containing directory. See the section.
"Algorithm to Check Access to an Existing File"
in MS-FSA.pdf.

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
2012-11-19 13:16:09 +01:00
Michael Adam
b557f34c80 s3:smbd: fix brace placements in validate_my_share_entries() for readability
according to coding guidelines

Signed-off-by: Michael Adam <obnox@samba.org>
Signed-off-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Oct 17 14:37:58 CEST 2012 on sn-devel-104
2012-10-17 14:37:58 +02:00
Andrew Bartlett
c8ade07760 smbd: Add mem_ctx to {f,}get_nt_acl VFS call
This makes it clear which context the returned SD is allocated on, as
a number of callers do not want it on talloc_tos().

As the ACL transformation allocates and then no longer needs a great
deal of memory, a talloc_stackframe() call is used to contain the
memory that is not returned further up the stack.

Andrew Bartlett
2012-10-11 12:25:11 +11:00
Jeremy Allison
3f5a3b60e2 Revert "When creating a new file/directory, we need to obey the create mask/directory mask parameters."
This reverts commit c251a6b044.

Remove this as we're planning to remove the security mask,
directory security mask parameters and only use create mask/directory mask.
2012-10-04 09:52:38 -07:00
Jeremy Allison
c251a6b044 When creating a new file/directory, we need to obey the create mask/directory mask parameters.
Currently we call FSET_NT_ACL to inherit any ACLs on create. However
FSET_NT_ACL uses the security mask/directory security mask parameters
instead of the create mask/directory mask parameters.

Swap them temporarily when creating to ensure the correct masks
are applied.

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Tue Oct  2 22:27:17 CEST 2012 on sn-devel-104
2012-10-02 22:27:17 +02:00
Volker Lendecke
e576bf5310 s3: Fix opening a file under kernel oplocks
With the prior code we assumed that we do not have kernel oplocks around
when we open a file because we handled samba-internal oplock breaks
before the open attempt.

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Sat Sep 29 19:29:36 CEST 2012 on sn-devel-104
2012-09-29 19:29:36 +02:00
Volker Lendecke
e00df42a37 s3: Remove a SMB_ASSERT
With the simplified logic this became unnecessary
2012-09-29 08:42:50 -07:00
Volker Lendecke
8b7e75b358 s3: Close the now opened file descriptor in error paths 2012-09-29 08:42:50 -07:00
Volker Lendecke
64c4940039 s3: No code change, just re-indent
Look at this with "git diff -b" if you don't believe me :-)
2012-09-29 08:42:50 -07:00
Volker Lendecke
173e808ed4 s3: Remove share mode handling before we open the file
This is a significant behaviour change: We do not open the file under
the share mode lock anymore. This might lead to more open calls in case
of oplock breaks or sharing violations, but those are slow error paths
and as such might be not too performance sensitive. The benefit of this
patch is a significant reduction of complexity of open_file_ntcreate()
2012-09-29 08:42:49 -07:00
Volker Lendecke
590d3138be s3: Fix fcb_or_dos_open after logic change
With the new behaviour, we call fcb_or_dos_open after open_file(). It
is open_file() that sets up the fsp so that fcb_or_dos_open can find it
in the list of fsps. Avoid finding the fsp we are just setting up.
2012-09-29 08:42:49 -07:00
Volker Lendecke
8be0f4d30f s3: Copy share mode handling from before to after open_file
This is a 1:1 copy&paste of the oplock/sharemode code that we do before
an existing file is opened. It is a prerequiste for a patch that removes
all of that handling before we open the file.
2012-09-29 08:42:49 -07:00
Volker Lendecke
4666dec416 s3: Fix rejecting mkdir on read-only shares
Signed-off-by: Jeremy Allison <jra@samba.org>
2012-09-27 01:07:08 +02:00
Volker Lendecke
36ec31336f s3: Slightly simplify open_file()
The "else" is not necessary. In the if-branch we just returned.

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Sep 26 18:08:03 CEST 2012 on sn-devel-104
2012-09-26 18:08:03 +02:00
Volker Lendecke
1fa730deba s3: Slightly simplify calculate_open_access_flags 2012-09-26 16:29:28 +02:00
Volker Lendecke
cc58a19565 s3: Slightly simplify calculate_open_access_flags 2012-09-26 16:29:28 +02:00
Volker Lendecke
7600fd8b0c s3: Factor out calculate_open_access_flags
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Sep 26 00:22:56 CEST 2012 on sn-devel-104
2012-09-26 00:22:56 +02:00
Volker Lendecke
11af163df8 s3: Fix a typo 2012-09-25 22:41:51 +02:00
Volker Lendecke
c034ff7b15 s3: Slightly simplify is_stat_open
The "access_bits" clause is redundant. is_stat_open says that exactly
at least one of the stat_open_bits must be set and none else.

Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Sep 25 20:05:06 CEST 2012 on sn-devel-104
2012-09-25 20:05:06 +02:00