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

627 Commits

Author SHA1 Message Date
Volker Lendecke
50db5cb0df s3: Remove procid_self() from fill_share_mode_entry() 2010-07-05 11:06:26 +02:00
Volker Lendecke
b903297878 s3: Remove procid_self() from init_strict_lock_struct() 2010-07-05 11:06:26 +02:00
Jeremy Allison
adf4833792 This patch looks bigger than it is. It does 2 things. 1). Renames smbpid -> smblctx in our locking code. 2). Widens smblctx to 64-bits internally. Preparing to use the SMB2 handle as the locking context.
Jeremy.
2010-05-07 06:20:50 -07:00
Jeremy Allison
4ad1943d29 Make us pass all SMB2 lock tests except MULTIPLE-UNLOCK and CONTEXT. Them next :-).
Jeremy.
2010-05-07 01:20:26 -07:00
Jeremy Allison
516f7c571e Fix SMB2 lock tests up to cancel-by-close.
Jeremy.
2010-05-06 09:07:49 -07:00
Jeremy Allison
d58b795587 Move to MS-FSA algorithm when checking for invalid lock range.
Satisfies SMB and SMB2.

Jeremy.
2010-05-05 15:57:57 -07:00
Günther Deschner
c6ebab846d s3: only include gen_ndr headers where needed.
This shrinks include/includes.h.gch by the size of 7 MB and reduces build time
as follows:

ccache build w/o patch
real    4m21.529s
ccache build with patch
real    3m6.402s

pch build w/o patch
real    4m26.318s
pch build with patch
real    3m6.932s

Guenther
2010-05-06 00:22:59 +02:00
Simo Sorce
dffeb12f3d smbd: move printfile_offset() within write_file() 2010-04-30 11:52:39 -07:00
Jeremy Allison
7984243768 Move to using 64-bit mid values in our internal open file database.
This will allow us to share logic much easier between SMB1 and SMB2
servers.

Jeremy
2010-04-12 21:40:28 -07:00
Jeremy Allison
1332ce52b7 We don't need to treat the token differently in the conn->admin_user case, it should already be pointing to a token with uid == 0.
Jeremy.
2010-03-15 14:49:00 -07:00
Jeremy Allison
4b85a0ea7f Rever e80ceb1d73 "Remove more uses of "extern struct current_user current_user;"."
As requested by Volker, split this into smaller commits.

Jeremy.
2010-03-15 14:48:54 -07:00
Jeremy Allison
e80ceb1d73 Remove more uses of "extern struct current_user current_user;".
Use accessor functions to get to this value. Tidies up much of
the user context code. Volker, please look at the changes in smbd/uid.c
to familiarize yourself with these changes as I think they make the
logic in there cleaner.

Cause smbd/posix_acls.c code to look at current user context, not
stored context on the conn struct - allows correct use of these
function calls under a become_root()/unbecome_root() pair.

Jeremy.
2010-03-12 13:56:51 -08:00
Volker Lendecke
89c785c47a s3: Fix a long-standing problem with recycled PIDs
When a samba server process dies hard, it has no chance to clean up its entries
in locking.tdb, brlock.tdb, connections.tdb and sessionid.tdb.

For locking.tdb and brlock.tdb Samba is robust by checking every time we read
an entry from the database if the corresponding process still exists. If it
does not exist anymore, the entry is deleted. This is not 100% failsafe though:
On systems with a limited PID space there is a non-zero chance that between the
smbd's death and the fresh access, the PID is recycled by another long-running
process. This renders all files that had been locked by the killed smbd
potentially unusable until the new process also dies.

This patch is supposed to fix the problem the following way: Every process ID
in every database is augmented by a random 64-bit number that is stored in a
serverid.tdb. Whenever we need to check if a process still exists we know its
PID and the 64-bit number. We look up the PID in serverid.tdb and compare the
64-bit number. If it's the same, the process still is a valid smbd holding the
lock. If it is different, a new smbd has taken over.

I believe this is safe against an smbd that has died hard and the PID has been
taken over by a non-samba process. This process would not have registered
itself with a fresh 64-bit number in serverid.tdb, so the old one still exists
in serverid.tdb. We protect against this case by the parent smbd taking care of
deregistering PIDs from serverid.tdb and the fact that serverid.tdb is
CLEAR_IF_FIRST.

CLEAR_IF_FIRST does not work in a cluster, so the automatic cleanup does not
work when all smbds are restarted. For this, "net serverid wipe" has to be run
before smbd starts up. As a convenience, "net serverid wipedbs" also cleans up
sessionid.tdb and connections.tdb.

While there, this also cleans up overloading connections.tdb with all the
process entries just for messaging_send_all().

Volker
2010-03-10 16:07:10 +01:00
Andrew Tridgell
93a3359729 s3-locking: convert brlock to TYPESAFE_QSORT() 2010-02-14 18:44:21 +11:00
Andrew Tridgell
4689826e39 s3-locking: update to use DLIST_ADD_AFTER()
(cherry picked from commit 6c6df527e14514027cbcaa6deac25adf04363926)
2010-02-10 15:40:44 -08:00
Jeremy Allison
47c1d9b39f Fix bug #6876 - Delete of an object whose parent folder does not have delete rights fails even if the delete right is set on the object.
Final fix for the vfs_acl_xattr and vfs_acl_tdb code.
Ensure we can delete a file even if the underlying POSIX
permissions don't allow it, if the Windows permissions do.

Jeremy.
2010-01-12 16:04:44 -08:00
Jeremy Allison
32915ceefc Make Samba3 pass the RAW-LOCK test as Windows.
Implement the win7 NT_STATUS_INVALID_LOCK_RANGE.
Make smbd behave as Windows does in canceling locks.

Jeremy.
2009-12-04 14:04:08 -08:00
Jeremy Allison
dfcc4115dd Remove unneeded argument from can_set_delete_on_close(). Ensure
can_set_delete_on_close() is correctly called before any setting
of the disposition bit (clean up the do_unlink() call).
Jeremy.
2009-12-02 18:06:40 -08:00
Volker Lendecke
91ccaa87da s3: Remove a pointless memset
We are assigning the complete structure now (we used to assign individual
fields), so this is obsolete.
2009-11-21 11:57:07 +01:00
Volker Lendecke
f0a933d140 s3: Cache brlock.tdb entries for the fast read&write strict locking code path
For a netbench run this gains around 2% user-space CPU, fetching a 100MB file
takes around 4% less.
2009-11-21 11:40:13 +01:00
Volker Lendecke
b067a5e4e8 s3: Remove debug_ctx()
smbd just crashed on me: In a debug message I called a routine preparing a
string that itself used debug_ctx. The outer routine also used it after the
inner routine had returned. It was still referencing the talloc context
that the outer debug_ctx() had given us, which the inner DEBUG had already
freed.
2009-11-03 11:30:00 +01:00
Jeremy Allison
3fa1d7332c Fix bug 6776 - Running overlapping Byte Lock test will core dump Samba daemon.
Re-write core of POSIX locking logic.
Jeremy.
2009-10-05 10:27:48 -07:00
Volker Lendecke
99f8dcab0c s3:smbd: Add the ntstatus to the smb_panic in share_mode_lock_destructor
This might help finding why bug 6518 happens
2009-09-07 01:28:32 +02:00
Volker Lendecke
033185e2a1 Make the smbd VFS typesafe 2009-07-24 11:42:05 -04:00
Tim Prouty
5a8d70d465 s3: Change fsp->fsp_name to be an smb_filename struct! 2009-07-20 17:26:56 -07:00
Tim Prouty
3a7d372e2e s3: Change the share_mode_lock struct to store a base_name and stream_name 2009-07-08 21:36:04 -07:00
Tim Prouty
83e5ac5695 s3: Make some arguments to (parse|unparse)_share_modes() const 2009-07-08 21:36:04 -07:00
Tim Prouty
0d9b204882 s3: Remove unnecessary const qualifiers 2009-07-07 18:02:53 -07:00
Tim Prouty
18a27a8df2 s3 sticky write time: Removed unused args and tighten up a function by making an arg const 2009-07-06 15:38:41 -07:00
Volker Lendecke
ed88ff18dd Fix Coverity ID 897: REVERSE_INULL 2009-05-06 12:01:30 +02:00
Volker Lendecke
b63cd72ae4 Use procid_str in debug messages for better cluster-debuggability 2009-04-03 12:19:20 +02:00
Volker Lendecke
c164c0c20a Fix a scary "fill_share_mode_lock failed" message
To me "fill_share_mode_lock failed" is a "can't happen" alert. There is
however a perfectly valid case in get_file_infos() when the file is not open.

Change the corresponding debug message to level 10 and explain more.
2009-03-26 12:30:44 +01:00
Dave Richards
1fcc11ff25 s3: Add strict lock/unlock calls to the vfs layer to replace is_locked 2009-03-13 14:16:55 -07:00
Jeremy Allison
0d9f4a2886 Last part of fix for #6154 - zfs does not honor admin users.
Jeremy.
2009-03-05 15:18:18 -08:00
Zack Kirsch
a04bb5f9a2 s3 BRL: Add more clarifying comments and add implied logic to make conditional more clear 2009-02-20 16:42:50 -08:00
Tim Prouty
e4675ce8db s3: Add extid to the dev/inode pair
This extends the file_id struct to add an additional generic uint64_t
field: extid.  For backwards compatibility with dev/inodes stored in
xattr_tdbs and acl_tdbs, the ext id is ignored for these databases.
This patch should cause no functional change on systems that don't use
SMB_VFS_FILE_ID_CREATE to set the extid.

Existing code that uses the smb_share_mode library will need to be
updated to be compatibile with the new extid.
2009-02-19 20:58:26 -08:00
Zack Kirsch
ca87726f81 s3: Fix uninitialized variable warning (and bug). 2009-02-13 15:59:39 -08:00
Zack Kirsch
813273c87e Add VFS ops for Windows BRL: Lock, Unlock and Cancel:
This patch adds 3 new VFS OPs for Windows byte range locking: BRL_LOCK_WINDOWS,
BRL_UNLOCK_WINDOWS and BRL_CANCEL_WINDOWS. Specifically:

* I renamed brl_lock_windows, brl_unlock_windows and brl_lock_cancel to
  *_default as the default implementations of the VFS ops.
* The blocking_lock_record (BLR) is now passed into the brl_lock_windows and
  brl_cancel_windows paths. The Onefs implementation uses it - future
  implementations may find it useful too.
* Created brl_lock_cancel to do what brl_lock/brl_unlock do: set up a
  lock_struct and call either the Posix or Windows lock function. These happen
  to be the same for the default implementation.
* Added helper functions: increment_current_lock_count() and
  decrement_current_lock_count().
* Minor spelling correction in brl_timeout_fn: brl -> blr.
* Changed blocking_lock_cancel() to return the BLR that it has cancelled. This
  allows us to assert its the lock that we wanted to cancel. If this assert ever
  fires, this path will need to take in the BLR to cancel, rather than choosing
  on its own.
* Adds a small helper function: find_blocking_lock_record_by_id(). Used by the
  OneFS implementation, but could be useful for others.
2009-02-13 10:08:40 -08:00
Volker Lendecke
77e3272092 Fix an uninitialized variable. Tim, please check! 2009-02-10 18:29:34 +01:00
Tim Prouty
c6f1f055fd s3 oplocks: Make the level2 oplock contention API more granular
This replaces release_level2_oplocks_on_change with
contend_level2_oplock_begin/end in order to contend level2 oplocks
throughout an operation rather than just at the begining.  This is
necessary for some kernel oplock implementations, and also lays the
groundwork for better correctness in Samba's standard level2 oplock
handling.  The next step for non-kernel oplocks is to add additional
state to the share mode lock struct that prevents any new opens from
granting oplocks while a contending operation is in progress.

All operations that contend level 2 oplocks are now correctly spanned
except for aio and synchronous writes.  The two write paths both have
non-trivial error paths that need extra care to get right.

RAW-OPLOCK and the rest of 'make test' are still passing with this
change.
2009-02-09 23:47:45 -08:00
Jeremy Allison
d0eeb9aa8d Fix more asprintf warnings and some error path errors.
Jeremy.
2008-12-23 12:11:12 -08:00
Jeremy Allison
1a5fc6d4bc Fix bug #5979 - Level 2 oplocks being granted improperly,
Jeremy.
2008-12-17 17:23:13 -08:00
Tim Prouty
7b9f6dda13 s3: [3/3]: Fix a delete on close divergence from windows and the associated torture test
This third patch cleans up by removing all of the code that is made
obsolete by the first patch.  It should cause no functional changes.
2008-12-09 18:06:49 -08:00
Jelmer Vernooij
4746f79d50 Use {u,}int64_t instead of SMB_BIG_{U,}INT. 2008-10-14 01:59:36 +02:00
Jeremy Allison
e76cb70444 Fix debug message to show correct function name.
Jeremy.
(This used to be commit 079c75ef3c)
2008-09-05 20:37:00 -07:00
Jeremy Allison
405b072431 Write times code update.
Ok, here's the fix for the write times breakage
with the new tests in S4 smbtorture.

The key is keeping in the share mode struct
the "old_file_time" as the real write time,
set by all the write and allocation calls,
and the "changed_write_time" as the "sticky"
write time - set by the SET_FILE_TIME calls.

We can set them independently (although I
kept the optimization of not setting the
"old_file_time" is a "changed_write_time"
was already set, as we'll never see it.

This allows us to update the write time
immediately on the SMBwrite truncate case,
SET_END_OF_FILE and SET_ALLOCATION_SIZE calls,
whilst still have the 2 second delay on the
"normal" SMBwrite, SMBwriteX calls.

I think in a subsequent patch I'd like to
change the name of these from "old_file_time"
to "write_time" and "changed_write_time" to
"sticky_write_time" to make this clearer.

I think I also fixed a bug in Metze's original
code in that once a write timestamp had been
set from a "normal" SMBwriteX call the fsp->update_write_time_triggered
variable was set and then never reset - thus
meaning the write timestamp would never get
updated again on subsequent SMBwriteX's.

The new code checks the update_write_time_event
event instead, and doesn't update is there's
an event already scheduled.

Metze especially, please check this over for
your understanding.

Jeremy.
(This used to be commit 6f20585419)
2008-09-05 19:00:48 -07:00
Volker Lendecke
ae923dbd4e Fix alignment problems on sparc, bug 5512
Patch successfully tested by Christoph Kaegi <kaph@zhaw.ch>, thanks.
(cherry picked from commit 9f8df16f47)
(This used to be commit 82ed19ff64)
2008-07-09 20:47:31 +02:00
Jeremy Allison
6811dc3fc2 Allow server manager to close open files selected by id.
Jeremy.
(This used to be commit 7eeed8bb41)
2008-05-27 11:25:46 -07:00
Jeremy Allison
b430b38220 Remove the "stat_open()" function, flag, and all associated code. It was only
being (correctly) used in the can_read/can_write checks for hide unreadable/unwritable
and this is more properly done using the functions in smbd/file_access.c.
Preparing to do NT access checks on all file access.
Jeremy.
(This used to be commit 6bfb06ad95)
2008-05-02 17:22:10 -07:00
Michael Adam
8c9060240e Slight reformatting of fd_close_posix(), while I'm at it.
Wrap lines and remove trailing space.

Michael
(This used to be commit 74ed53a115)
2008-04-21 00:21:24 +02:00
Michael Adam
2f8dde9ec8 Change fd_close_posix() to return int instead of NTSTATUS.
The errno is handed up through the VFS layer to the callers.

Michael
(This used to be commit d928e6648d)
2008-04-21 00:21:24 +02:00
Michael Adam
96e9e83ee0 Don't modify the fsp in fd_close_posix() anymore.
Now that it is inside the vfs layer, this function should
not alter the fsp (i.e. set fsp->fh->fd = -1) anymore.
That belongs above the vfs layer.

Michael
(This used to be commit df264bf3e0)
2008-04-21 00:21:24 +02:00
Michael Adam
3756467db6 Move the posix pending close functionality down into the VFS layer.
This hides the pending close fds from the outside. Call order
of SMB_VFS_CLOSE is reversed. Originally, it was:

fd_close -> fd_close_posix -> SMB_VFS_CLOSE -> close

And now it is:

fd_close -> SMB_VFS_CLOSE -> fd_close_posix -> close

This is in preparation of removing the fd parameter
from the SMB_VFS_CLOSE function. But it is also the right
place for the pending close calls anyways.

Michael
(This used to be commit 3cf56b124a)
2008-04-21 00:21:23 +02:00
Jeremy Allison
e76ec752be Quieten valgrind message on make valgrindtest. This doesn't
seem to be valid (vl - feel free to confirm).
Jeremy.
(This used to be commit 43b0254d93)
2008-04-11 17:23:48 -07:00
Stefan Metzmacher
851cadba51 locking: combine get_delete_on_close_flag() and get_write_time() into get_file_infos()
This means we need to fetch the record only once.

metze
(This used to be commit 4130b87329)
2008-04-07 12:29:29 +02:00
Stefan Metzmacher
2ccf50256e locking: store the write time in the locking.tdb
This is needed to implement the strange write time update
logic later. We need to store 2 time timestamps to
distinguish between the time the file system had before
the first client opened the file and a forced timestamp update.

metze
(This used to be commit 6aaa2ce0ee)
2008-04-07 12:29:25 +02:00
Volker Lendecke
1709954933 Merge leftovers of 0e1a86bc845 in 3-0-ctdb
(This used to be commit 64b1625f8e)
2008-03-17 14:56:45 +01:00
Volker Lendecke
33f3eeaa00 Fix some "set but never used" warnings
(This used to be commit 4a6dadc517)
2008-01-20 17:44:40 +01:00
Alexander Bokovoy
68694369fc Merge CTDB-related fixes from samba-ctdb 3.0 branch (http://samba.org/~tridge/3_0-ctdb)
Signed-off-by: Alexander Bokovoy <ab@samba.org>(This used to be commit 0c8e23afbb)
2008-01-16 12:09:48 +03:00
Volker Lendecke
8d464d470a Don't early delete the share mode tdb data
We now refer directly to the file name in the tdb data, so don't delete it.
(This used to be commit 71de4946cf)
2008-01-12 23:57:12 +01:00
Volker Lendecke
5a8bbc64cc Trivial simplification
(This used to be commit 616bc34744)
2008-01-12 23:57:11 +01:00
Volker Lendecke
5ddb2abf76 Some more talloc_tos()
(This used to be commit 444e35e7df)
2008-01-10 13:19:58 +01:00
Volker Lendecke
3cc3b9e187 use talloc_tos in a few more places
(This used to be commit 65dd869bea)
2008-01-10 13:19:58 +01:00
Michael Adam
f7bf4cb3f1 Remove redundant parameter fd from SMB_VFS_GETLOCK().
Michael
(This used to be commit ee5a20becd)
2008-01-07 22:18:50 +01:00
Volker Lendecke
fa6d7b42f1 Do not talloc_strdup filename and servicepath
(This used to be commit 66be770993)
2008-01-07 21:18:20 +01:00
Michael Adam
edd30e716f Remove redundant parameter fd from SMB_VFS_LOCK().
Michael
(This used to be commit 4f3ab2c406)
2008-01-07 16:38:23 +01:00
Volker Lendecke
a8d2664fec allocate share_mode_str only when needed
(This used to be commit a98693bfa7)
2008-01-04 23:32:24 +01:00
Michael Adam
4773973300 Remove redundant connection_struct from fd_close_posix() parameter list.
Michael
(This used to be commit f3365b74ac)
2007-12-22 02:01:32 +01:00
Volker Lendecke
a347ff84bc Convert the posix_pending_close_db to dbwrap_rbt
(This used to be commit 841f4ccbfb)
2007-12-11 16:16:54 +01:00
Volker Lendecke
d60fac2a5a Tiny simplifications
locking.c:open_read_only was unused

don't export the silly boolean flag locking_init(bool read_only)
(This used to be commit 2f3c865707)
2007-12-10 12:22:01 +01:00
Volker Lendecke
0527d3758a Remove a static
(This used to be commit 1f317f471a)
2007-12-10 12:22:01 +01:00
Volker Lendecke
f4fe725ff1 Remove two statics
(This used to be commit 8ee502e1e5)
2007-12-10 12:22:01 +01:00
Volker Lendecke
815aec8241 Add a comment
(This used to be commit 144014096a)
2007-11-18 15:08:54 -08:00
Volker Lendecke
3546d5c099 Fix a valgrind error
(This used to be commit b82120f9b7)
2007-11-18 15:08:52 -08:00
Jeremy Allison
acb829ecc3 Add MAX_DNS_NAME_LENGTH, remove more pstrings.
Jeremy.
(This used to be commit a1725f4ff7)
2007-11-15 18:27:26 -08:00
Jeremy Allison
30191d1a57 RIP BOOL. Convert BOOL -> bool. I found a few interesting
bugs in various places whilst doing this (places that assumed
BOOL == int). I also need to fix the Samba4 pidl generation
(next checkin).
Jeremy.
(This used to be commit f35a266b3c)
2007-10-18 17:40:25 -07:00
Volker Lendecke
4ee8b2937d r25055: Add file_id_string_tos
This removes file_id_string_static and file_id_string_static2
(This used to be commit 638c848c9a)
2007-10-10 12:30:36 -05:00
Volker Lendecke
8bab4bdc5d r24571: Only look at errno if the close call actually failed
Patch from Ofir Azoulay <Ofir.Azoulay@expand.com> -- thanks
(This used to be commit 888e657d75)
2007-10-10 12:30:06 -05:00
Volker Lendecke
28210588ed r24266: Remove the "open files database hash size" parameter
This has been superseded by the "tdb_hashsize:<tdbname>" parameter
(This used to be commit df40d336af)
2007-10-10 12:29:22 -05:00
Stefan Metzmacher
b352a4532a r24117: use locking_key() instead of forming the TDB_DATA key
by hand

metze
(This used to be commit a7449e4ab3)
2007-10-10 12:29:08 -05:00
Volker Lendecke
63fcb7a2fd r24034: Print the full cluster pid in print_lock_struct
(This used to be commit ff1996ce4b)
2007-10-10 12:28:58 -05:00
Stefan Metzmacher
070215ef13 r23956: merge from 3_2-ctdb-tridge:
fixed a bug with dead share mode entries

jra: please tell me if it's ok to merge this to 3_2_0.

metze
(This used to be commit 044ac6afa7)
2007-10-10 12:28:49 -05:00
Jeremy Allison
44b9493418 r23908: Fix bug with interaction of optimization with
POSIX locking. We can't do lock counts with POSIX,
so stop counting if we get a POSIX lock request.
Jeremy.
(This used to be commit a48e4a29e6)
2007-10-10 12:28:40 -05:00
Volker Lendecke
476c30b9ce r23885: Fix make test on opi.
(This used to be commit b2adb28808)
2007-10-10 12:28:38 -05:00
Volker Lendecke
c9da49790e r23882: Fix Coverity id 389 -- finally (I hope)
(This used to be commit 9b8f2d8bd1)
2007-10-10 12:28:38 -05:00
Andrew Tridgell
5e54558c6d r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
(This used to be commit b0132e94fc)
2007-10-10 12:28:22 -05:00
Jeremy Allison
d824b98f80 r23779: Change from v2 or later to v3 or later.
Jeremy.
(This used to be commit 407e6e695b)
2007-10-10 12:28:20 -05:00
Volker Lendecke
014a596f42 r23759: Fix make test -- sorry
(This used to be commit cbbc70604e)
2007-10-10 12:23:53 -05:00
Volker Lendecke
4ff7e6dbc9 r23755: Fix Coverity id 384
(This used to be commit ebb410ca1e)
2007-10-10 12:23:52 -05:00
Jeremy Allison
9dee722b09 r23516: Fix bug found & fixed by Doug Rudoff (doug_rudoff@isilon.com)
- when cleaning up invalid locks make sure we mark the lck
struct as modified so it'll get saved back correctly (that
was the original intent).
Jeremy.
(This used to be commit cbf0829abc)
2007-10-10 12:23:24 -05:00
James Peach
b1ce226af8 r23510: Tidy calls to smb_panic by removing trailing newlines. Print the
failed expression in SMB_ASSERT.
(This used to be commit 171dc060e2)
2007-10-10 12:23:23 -05:00
Volker Lendecke
184eb775ff r23486: Ok, this time with a hopefully successful make test in the right place:
Remove two local variables
(This used to be commit 575e594e93)
2007-10-10 12:23:21 -05:00
Volker Lendecke
86f0e0b3de r23316: Ouch... This would not have run in production without cluster code
anyway.
(This used to be commit ca1d0ff03d)
2007-10-10 12:23:06 -05:00
Volker Lendecke
48e0c62053 r23222: share_mode_forall() is only for counting and status display stuff, so
traverse_read is enough here
(This used to be commit 40991badef)
2007-10-10 12:22:56 -05:00
Volker Lendecke
3f5742e20b r23204: Add MSG_SMB_BRL_VALIDATE. Tridge, this is a bit different from your bzr
branch, please check if it fulfils your needs.

Two changes: The validation is not done inside the brlock.c traverse_fn,
it's done as a separate routine.

Secondly, this patch does not call the checker routines in smbcontrol
directly but depends on a running smbd.
(This used to be commit 7e39d77c1f)
2007-10-10 12:22:53 -05:00
Volker Lendecke
d3ed91d9e1 r23195: Add void *private_data to brl_forall
(This used to be commit c91b2bdc16)
2007-10-10 12:22:53 -05:00
Volker Lendecke
e8156439f2 r23183: Check in a change made by Tridge:
This replaces the internal explicit dev/ino file id representation by a
"struct file_id". This is necessary as cluster file systems and NFS
don't necessarily assign the same device number to the shared file
system. With this structure in place we can now easily add different
schemes to map a file to a unique 64-bit device node.

Jeremy, you might note that I did not change the external interface of
smb_share_modes.c.

Volker
(This used to be commit 9b10dbbd5d)
2007-10-10 12:22:52 -05:00
Volker Lendecke
8c57860cc7 r23169: Merge 535 of Tridge's bzr tree:
store the right data after cleaning lock records. This fixes
  RAW-BENCH-LOCK after a recovery on a cluster
(This used to be commit 3da3086dbf)
2007-10-10 12:22:51 -05:00
Volker Lendecke
40a3b796ce r23165: Convert brlock.tdb to dbwrap
(This used to be commit 84f9885cf8)
2007-10-10 12:22:50 -05:00
Volker Lendecke
1e6af7084b r23164: Minor cosmetic checkin
(This used to be commit 8de1ac9fad)
2007-10-10 12:22:50 -05:00
Volker Lendecke
6e5c23728c r23163: Convert locking.tdb to dbwrap
(This used to be commit afe90224bf)
2007-10-10 12:22:50 -05:00
Volker Lendecke
4db33293ab r23162: Make use of messaging_send_buf
(This used to be commit 3f8186fe85)
2007-10-10 12:22:50 -05:00
Jeremy Allison
dbfd6bf8c8 r23100: Implement the delete on close semantics I've just tested for
in Samba4 smbtorture. Fix rename on an open file handle.
Needed for 3.0.25a.
Jeremy.
(This used to be commit a301467d5f)
2007-10-10 12:22:46 -05:00
James Peach
38daf36d12 r23096: Make the lock failure message prettier.
(This used to be commit 853f41edb8)
2007-10-10 12:22:45 -05:00
Jeremy Allison
01a7017d7b r23014: For all branches, ensure that if we're blocked on a POSIX
lock we know nothing about that we retry the lock every
10 seconds instead of waiting for the standard select
timeout. This is how we used to (and are supposed to)
work.
Jeremy.
(This used to be commit fa18fc25a5)
2007-10-10 12:22:15 -05:00
Volker Lendecke
b92064fcfd r22846: Chunk one to replace message_send_pid with messaging_send: Deep inside
locking/locking.c we have to send retry messages to timed lock holders.
The majority of this patch passes a "struct messaging_context" down
there. No functional change, survives make test.
(This used to be commit bbb5084146)
2007-10-10 12:22:02 -05:00
Volker Lendecke
e6383f4762 r22736: Start to merge the low-hanging fruit from the now 7000-line cluster patch.
This changes "struct process_id" to "struct server_id", keeping both is
just too much hassle. No functional change (I hope ;-))

Volker
(This used to be commit 0ad4b1226c)
2007-10-10 12:21:52 -05:00
Volker Lendecke
1bcee2679d r22688: Change lock_data in struct byte_range_lock from void * to struct lock_struct *
(This used to be commit 8e0e278961)
2007-10-10 12:21:46 -05:00
Jeremy Allison
79de0ad946 r22588: Make all uses of TALLOC_MEMDUP consistent.
Jeremy.
(This used to be commit 8ad13718af)
2007-10-10 12:19:48 -05:00
Jeremy Allison
12ba88574b r22542: Move over to using the _strict varients of the talloc
calls. No functional changes. Looks bigger than it is :-).
Jeremy.
(This used to be commit f6fa3080fe)
2007-10-10 12:19:44 -05:00
Stefan Metzmacher
bc2b6436d0 r22009: change TDB_DATA from char * to unsigned char *
and fix all compiler warnings in the users

metze
(This used to be commit 3a28443079)
2007-10-10 12:19:00 -05:00
Jeremy Allison
cda247e9d4 r21726: Fix stupid cut-n-paste typo. Thanks to volker for
being on the ball..... :-).
Jeremy.
(This used to be commit 84ed7bcbe6)
2007-10-10 12:18:26 -05:00
Jeremy Allison
640ab28d78 r21724: Optimization pointed out by Volker. If we don't
have any outstanding locks or blocking locks then
we don't need to read the lock db. on close.
Jeremy.
(This used to be commit 1b063496f9)
2007-10-10 12:18:26 -05:00
Volker Lendecke
94a1b230f3 r21723: Make use of the per-hashchain "freelists"
(This used to be commit f3421ae4cf)
2007-10-10 12:18:25 -05:00
Volker Lendecke
242927bd5c r21706: get_delete_on_close_flag() is the perfect candidate for tdb_parse_record()
(This used to be commit b73685d207)
2007-10-10 12:18:24 -05:00
Jeremy Allison
86e5659aba r21257: Better fix for bug #4188 :
Windows Vista RC1 and RC2 can't delete directory on Samba share
based on work by Joe Meadows <jmeadows@webopolis.com>.
Jeremy.
(This used to be commit 2dab892876)
2007-10-10 12:17:51 -05:00
Jeremy Allison
7a5fa7f12e r21191: Add in the POSIX open/mkdir/unlink calls.
Move more error code returns to NTSTATUS.
Client test code to follow... See if this
passes the build-farm before I add it into
3.0.25.
Jeremy.
(This used to be commit 83dbbdff34)
2007-10-10 12:17:47 -05:00
Jeremy Allison
aacd16e7c4 r20916: Add in the delete on close final fix - but only enabled
with -DDEVELOPER.
Jeremy.
(This used to be commit 7f817067a7)
2007-10-10 12:17:19 -05:00
Jeremy Allison
c9a14ea19f r20883: W00t! I now understand how "delete on close" really
works - even with the strange "initial delete on close"
semantics. The "initial delete on close" flag isn't
committed to the share mode db until the handle is
closed, and is discarded if any real "delete on close"
was set. This allows me to remove the "initial_delete_on_close"
flag from the share db, and move it into a BOOL in files_struct.
Warning ! You must do a make clean after this. Cope with
the wrinkle in directory delete on close which is done
differently from files. We now pass all Samba4 smbtortute
BASE-DELETE tests except for the one checking that files
can't be created in a directory which has the delete on
close set (possibly expensive to fix).
Jeremy.
(This used to be commit f2df77a149)
2007-10-10 12:17:18 -05:00
Jeremy Allison
fd37f98158 r20873: Some correctness fixes w.r.t. Samba4 torture BASE-DELETE.
Allow us to correctly refuse to set delete on close on a
non-empty directory. There are still some delete-on-close
wrinkles to be fixed, but I understand how to do that better
now. I'll fix this tomorrow.
Jeremy.
(This used to be commit 0296358858)
2007-10-10 12:17:16 -05:00
Volker Lendecke
b6b84f98c0 r19668: Convert the locking params to use struct share_param instead of snum
(This used to be commit 609dbec600)
2007-10-10 12:15:46 -05:00
Volker Lendecke
8f553d8d3c r19078: talloc_strdup can fail
(This used to be commit 2b3b9ce2a1)
2007-10-10 12:15:09 -05:00
Volker Lendecke
3bc4fd1bb9 r17924: Get rid of warnings now that talloc is merged.
Destructors now take a pointer to the "real" destroyed object as an argument.

Volker
(This used to be commit 70edd716ef)
2007-10-10 11:38:59 -05:00
Volker Lendecke
70660495b3 r17452: Some C++ warnings
(This used to be commit e4b8c79a9d)
2007-10-10 11:38:34 -05:00
Jeremy Allison
49001a5b1b r17346: Add optimisation vl needs for the cluster code where
we don't get the chainlock when getting the byte range
lock record read-only.
Jeremy.
(This used to be commit fcd798ca0c)
2007-10-10 11:38:27 -05:00
Jeremy Allison
2c6030415e r17314: Optimisation for POSIX locking. If we're downgrading
a POSIX lock (applying a read-lock) and we overlap
pending read locks then send them an unlock message,
we may have allowed them to proceed.
Jeremy.
(This used to be commit a7a0b6ba50)
2007-10-10 11:38:25 -05:00
Jeremy Allison
a093a76dc1 r17293: After the results from the cluster tests in Germany,
fix the messaging code to call the efficient calls :

save_re_uid()
set_effective_uid(0);

messaging_op

restore_re_uid();

instead of using heavyweight become_root()/unbecome_root()
pairs around all messaging code. Fixup the messaging
code to ensure sec_init() is called (only once) so that non-root
processes still work when sending messages.

This is a lighter weight solution to become_root()/unbecome_root()
(which swaps all the supplemental groups) and should be more
efficient. I will migrate all server code over to using this
(a similar technique should be used in the passdb backend
where needed).

Jeremy.
(This used to be commit 4ace291278)
2007-10-10 11:38:24 -05:00
Volker Lendecke
d30bcf9c48 r17279: conn->cnum is the tid we've given to the client. This has nothing to do with
our internal share number.

Funny that it worked at all :-)

Volker
(This used to be commit afa6e90946)
2007-10-10 11:38:23 -05:00
Jeremy Allison
54cdd1dfe2 r17276: Don't change the POSIX lock ref count if posix locking = no.
Jeremy.
(This used to be commit 42dec2192c)
2007-10-10 11:38:23 -05:00
Jeremy Allison
7f5f781fe9 r17181: Fix the build farm RAW-READ bug. When making a copy
of the lock array in order to delete them individually
it's also important to make a copy of the *size* of
this array. Otherwise the unlock decrements the termination
index of your for loop :-). Doh ! Big thanks to Volker
for showing me how to set up the build farm to track
this one down. This is not a 3.0.23a issue.
Jeremy.
(This used to be commit 2c82a159ae)
2007-10-10 11:38:18 -05:00
Volker Lendecke
e0c68d0a1d r17177: Get rid of a global variable by adding a private data pointer to
share_mode_forall().

Volker
(This used to be commit f97f6cedff)
2007-10-10 11:38:17 -05:00
Jeremy Allison
b737f26764 r17105: Fix the race Volker found - we had a non-locked
region between detecting a pending lock was needed
and when we added the blocking lock record. Make
sure that we hold the lock over all this period.
Removed the old code for doing blocking locks on
SMB requests that never block (the old SMBlock
and friends).
Discovered something interesting about the strange
NT_STATUS_FILE_LOCK_CONFLICT return. If we asked
for a lock with zero timeout, and we got an error
of NT_STATUS_FILE_LOCK_CONFLICT, treat it as though
it was a blocking lock with a timeout of 150 - 300ms.
This only happens when timeout is sent as zero and
can be seen quite clearly in ethereal. This is the
real replacement for old do_lock_spin() code.
Re-worked the blocking lock select timeout to correctly
use milliseconds instead of the old second level
resolution (far too coarse for this work).
Jeremy.
(This used to be commit b81d6d1ae9)
2007-10-10 11:38:12 -05:00
Jeremy Allison
e1da1fcf12 r17098: Samba3 now cleanly passes Samba4 RAW-LOCK torture
test. Phew - that was painful :-). But what it means
is that we now implement lock cancels and I can add
lock cancels into POSIX lock handling which will fix
the fast/slow system call issue with cifsfs !
Jeremy.
(This used to be commit f1a9cf075b)
2007-10-10 11:38:11 -05:00
Jeremy Allison
354e444ee3 r17046: Ensure we're using the right pointers ...
Jeremy.
(This used to be commit a8df1863bf)
2007-10-10 11:19:22 -05:00
Jeremy Allison
ad673ea988 r17043: Fix memleak when processing CIFS POSIX lock/unlock
requests. Maybe the Linux kernel OOM killer will
be kinder to smbd now :-). Back to tdbtorture
tests on cifsfs.
Jeremy.
(This used to be commit 1201383e7a)
2007-10-10 11:19:21 -05:00
Jeremy Allison
d22d540c32 r17041: Trying to track down a *big* memory leak in the new lock code.
Fix a small one first.... (easy to valgrind).
Jeremy
(This used to be commit 43d24fbd41)
2007-10-10 11:19:21 -05:00
Jeremy Allison
75a2f4dbc8 r17000: Allow CIFS POSIX locks to coexist with Windows locks.
We shouldn't allow this on the same smbd, but the cifsfs
client negotiates POSIX locks then sends Windows ones.
Doh ! Can't fix shipped client code....
Jeremy.
(This used to be commit 2f8cabe98d)
2007-10-10 11:19:17 -05:00
Jeremy Allison
8dbe2651d3 r16992: Fix bug #3922 reported by jason@ncac.gwu.edu, correctly
look at the return code.
Jeremy.
(This used to be commit f11933b3ac)
2007-10-10 11:19:17 -05:00
Jeremy Allison
1722226189 r16987: Fix the logic errors in ref-counting Windows locks.
Hopefully will fix the build farm. Still a few errors
in RAW-LOCK to look at though...
Jeremy.
(This used to be commit edd72d37de)
2007-10-10 11:19:16 -05:00
Jeremy Allison
297df32751 r16973: Fix subtle logic error in lock ref counting found by
cifsfs client code.
Jeremy.
(This used to be commit 53094435d8)
2007-10-10 11:19:16 -05:00
Jeremy Allison
fbdcf2663b r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
to do the upper layer directories but this is what
everyone is waiting for....

Jeremy.
(This used to be commit 9dafb7f48c)
2007-10-10 11:19:14 -05:00
Jeremy Allison
cc1457beb0 r16661: Fix from jason@ncac.gwu.edu for bug #3875,
bad cast warning.
Jeremy.
(This used to be commit d60e6e0abc)
2007-10-10 11:19:06 -05:00
Jeremy Allison
54ea3c23e3 r16435: Add in the uid info that Jerry needs into the
share_mode struct. Allows us to know the unix
uid of the opener of the file/directory. Needed
for info level queries on open files.
Jeremy.
(This used to be commit d929323d6f)
2007-10-10 11:18:54 -05:00
Jeremy Allison
a90026e7a6 r16307: Make sure we know we must pass a valid pointer here.
Klocwork #1129.
Jeremy.
(This used to be commit e8d86362ba)
2007-10-10 11:17:32 -05:00
Jeremy Allison
c115570b85 r16281: Start fixing up gcc4 -O6 warnings on an x86_64 box. size_t != unsigned
int
in a format string.
Jeremy.
(This used to be commit c49ad9200b)
2007-10-10 11:17:30 -05:00
James Peach
0a1ca7fa3d r15943: Update misleading DEBUG statements and comments that refer to
open_file_shared.
(This used to be commit 784126edff)
2007-10-10 11:17:14 -05:00
Jeremy Allison
6a026d5618 r15670: Fix valgrind-spotted issue in BASE-DELETE test.
We were forgetting to increment after copying
the primary group gid.
Jeremy
(This used to be commit 31d16c434e)
2007-10-10 11:17:06 -05:00
Jeremy Allison
cc9ea93456 r15668: DOS or FCB opens share one share mode entry from different
fsp pointers. Ensure we cope with this to pass Samba4
DENY tests (we used to pass these, there must have been
a regression with newer code). We now pass them.
Jeremy
(This used to be commit fd6fa1d4ea)
2007-10-10 11:17:06 -05:00
Jeremy Allison
fca8766ee1 r15419: Never write the same function twice :-). In a traversal
function we must copy the data before modifying.
Jeremy.
(This used to be commit ef4c70f58e)
2007-10-10 11:16:42 -05:00
Jeremy Allison
6eb1187765 r15402: Fix for bug #3587. Dead entries can be left in the locking
db. Make this db self-cleaning on first read of entry after
open, and also on smbstatus -b call. Needs more testing when
I get back from Boston but passes valgrind at first look.
Jeremy.
(This used to be commit c665310963)
2007-10-10 11:16:40 -05:00
Jeremy Allison
f93da6d684 r15269: Fix incorrect boolean in assert to make POSIX lock tests
pass with CIFSFS.
Jeremy.
(This used to be commit 89b604285e)
2007-10-10 11:16:31 -05:00
Tim Potter
f353704bbf r15255: Add return statement after abort to placate fussy compilers. Closes #3721.
(This used to be commit ab5a55ec8b)
2007-10-10 11:16:30 -05:00
Jeremy Allison
713eaf1d67 r15083: Using talloc with destructors is nice and all, but in this
case it's in a performace critical path and it *hurts* us.
Go back to plain malloc/free with an explicit destructor
call.
Jeremy.
(This used to be commit 1c99aed563)
2007-10-10 11:16:22 -05:00
Jeremy Allison
fdd55885da r15060: The brlock code gets called a lot. Ensure we keep the
key around while we're using it - saves many calls to
locking_key() (now deleted).
Jeremy.
(This used to be commit 2f8b527dcf)
2007-10-10 11:16:00 -05:00
Jeremy Allison
423352b90e r15026: Fix warning until POSIX locking finished.
Jeremy.
(This used to be commit 15f39a4c72)
2007-10-10 11:15:57 -05:00
Jeremy Allison
22dbd67708 r15018: Merge Volker's ipc/trans2/nttrans changes over
into 3.0. Also merge the new POSIX lock code - this
is not enabled unless -DDEVELOPER is defined.
This doesn't yet map onto underlying system POSIX
locks. Updates vfs to allow lock queries.
Jeremy.
(This used to be commit 08e52ead03)
2007-10-10 11:15:57 -05:00
Jeremy Allison
81d4f40bbe r14763: Add a new tuning parameter, open files database hash size,
this allows us to experiment with ensuring the tdb hash
size for our open files and locking db are appropriately
sized. Make the hash size larger by default (10007 instead
of 1049) and make the locking db hash size the same as the
open file db hash size.
Jeremy.
(This used to be commit e7225f7e81)
2007-10-10 11:15:46 -05:00
Jeremy Allison
7f57dc61cb r14703: Clarify the return codes for the POSIX locking case. This
was confusing.
Jeremy.
(This used to be commit bc1a605a39)
2007-10-10 11:15:44 -05:00
James Peach
d6eebce490 r14428: Call fill_share_mode_entry with NO_OPLOCK instead of 0.
(This used to be commit a39cbaa699)
2007-10-10 11:15:30 -05:00
Jeremy Allison
894358a8f3 r13915: Fixed a very interesting class of realloc() bugs found by Coverity.
realloc can return NULL in one of two cases - (1) the realloc failed,
(2) realloc succeeded but the new size requested was zero, in which
case this is identical to a free() call.

The error paths dealing with these two cases should be different,
but mostly weren't. Secondly the standard idiom for dealing with
realloc when you know the new size is non-zero is the following :

 tmp = realloc(p, size);
 if (!tmp) {
    SAFE_FREE(p);
    return error;
 } else {
    p = tmp;
 }

However, there were *many* *many* places in Samba where we were
using the old (broken) idiom of :

 p = realloc(p, size)
 if (!p) {
    return error;
 }

which will leak the memory pointed to by p on realloc fail.

This commit (hopefully) fixes all these cases by moving to
a standard idiom of :

 p = SMB_REALLOC(p, size)
 if (!p) {
    return error;
 }

Where if the realloc returns null due to the realloc failing
or size == 0 we *guarentee* that the storage pointed to by p
has been freed. This allows me to remove a lot of code that
was dealing with the standard (more verbose) method that required
a tmp pointer. This is almost always what you want. When a
realloc fails you never usually want the old memory, you
want to free it and get into your error processing asap.

For the 11 remaining cases where we really do need to keep the
old pointer I have invented the new macro SMB_REALLOC_KEEP_OLD_ON_ERROR,
which can be used as follows :

 tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size);
 if (!tmp) {
    SAFE_FREE(p);
    return error;
 } else {
    p = tmp;
 }

SMB_REALLOC_KEEP_OLD_ON_ERROR guarentees never to free the
pointer p, even on size == 0 or realloc fail. All this is
done by a hidden extra argument to Realloc(), BOOL free_old_on_error
which is set appropriately by the SMB_REALLOC and SMB_REALLOC_KEEP_OLD_ON_ERROR
macros (and their array counterparts).

It remains to be seen what this will do to our Coverity bug count :-).

Jeremy.
(This used to be commit 1d710d06a2)
2007-10-10 11:10:59 -05:00
Gerald Carter
fb5362c069 r13571: Replace all calls to talloc_free() with thye TALLOC_FREE()
macro which sets the freed pointer to NULL.
(This used to be commit b65be8874a)
2007-10-10 11:10:14 -05:00
Jeremy Allison
30e47fdfe2 r13412: Don't use arbitrary uint32 size for uid and gid storage. Use
correct system size. Fixed a bug that was accidentally introduced
by use of uint32 - uid was stored twice, not uid and gid.
Jeremy.
(This used to be commit 89db006997)
2007-10-10 11:10:00 -05:00
Jeremy Allison
40d3c7ebb2 r13329: Fix libsmbsharemodes.so to work with the stored delete token.
Less trouble than I thought plus it didn't need an interface
change (thank goodness !).
Jeremy.
(This used to be commit dbe2572d1c)
2007-10-10 11:06:25 -05:00
Jeremy Allison
466230e5a1 r13294: Fix basic delete on close tests - don't forget to tell
the data struct how big the token is... :-).
Jeremy.
(This used to be commit f259de8b69)
2007-10-10 11:06:21 -05:00
Jeremy Allison
d14af63e6a r13293: Rather a big patch I'm afraid, but this should fix bug #3347
by saving the UNIX token used to set a delete on close flag,
and using it when doing the delete. libsmbsharemodes.so still
needs updating to cope with this change.
Samba4 torture tests to follow.
Jeremy.
(This used to be commit 23f16cbc2e)
2007-10-10 11:06:21 -05:00
Jeremy Allison
86c9bac4c3 r13274: Fix for bug #3467. Not a show stopper.
jason qian <jason@infrant.com> was a *fantastic*
help in tracking this down.
Jeremy.
(This used to be commit 9f4a9c70fa)
2007-10-10 11:06:20 -05:00
Jeremy Allison
bd34c2ac25 r13198: Fix issues exposed by Jerry's testing on 64-bit Solaris
(I hope). Separate 3.0.21b patch sent to Jerry.
Jeremy.
(This used to be commit 837e7ea7e4)
2007-10-10 11:06:17 -05:00
Jeremy Allison
6f08a557ba r13194: Don't do extra memcpy's unless we're asked to.
Jeremy.
(This used to be commit f93e1e7556)
2007-10-10 11:06:17 -05:00
Jeremy Allison
6a097ab20e r13192: Fix up alignment issues when printing share mode
entries. Add paranioa to debug so we know when an
entry is unused.
Jeremy.
(This used to be commit fa5fab313e)
2007-10-10 11:06:16 -05:00
Gerald Carter
6afd823e42 r13110: remove an invalid debug message about call get_share_mode_lock() with a NULL service path and fname (we do it all the time internally)
(This used to be commit e1f75ea637)
2007-10-10 11:06:14 -05:00
Jeremy Allison
3317484799 r12877: Stop passing structs around in smb messages, instead
always linearize into little-endian. Should fix all
Solaris issues with this, plus provide a cleaner base
moving forward for cluster-aware Samba where smbd's
can communicate across different compilers/architectures
(eventually these message will have to go cross-machine).
Jeremy.
(This used to be commit d01824b785)
2007-10-10 11:06:05 -05:00
Jeremy Allison
e7d2e311a2 r12234: Reduce the race condition for renames by holding the lock
longer. Instigated by complaints on the fix for #3303 from
SATOH Fumiyasu <fumiyas@miraclelinux.com>.
Jeremy.
(This used to be commit 855f5f8c32)
2007-10-10 11:05:50 -05:00
Jeremy Allison
762901cfb9 r12221: Fix error code paths that can potentially leave a dangling lock.
Jeremy.
(This used to be commit 123135ed1d)
2007-10-10 11:05:49 -05:00
Jeremy Allison
ab7a4f7e8e r12213: Final fix for #3303 - send rename messages to smbd's
that have open file handles to allow them to correctly
implement delete on close. There is a further correctness
fix I'm intending to add to this to cope with different share
paths, but not right now...
Jeremy.
(This used to be commit 932e337db8)
2007-10-10 11:05:49 -05:00
Jeremy Allison
7d2771e758 r12203: Add the share path into the sharemode db. This involves
revving the minor version number for libsmbsharemodes (we
now have a new _ex interface that takes the share path
as well as the filename). Needed for #3303. Some code written
by SATOH Fumiyasu <fumiya@samba.gr.jp> included in the changes
to locking/locking.c. The smbstatus output is a bit of a mess
and needs overhauling...
Jeremy.
(This used to be commit 9d93af713f)
2007-10-10 11:05:49 -05:00
Jeremy Allison
a00c76d9fb r11435: Allow the hash size of the tdb open (locking) database
to be set in local.h. Change from the default (131) to
another prime (1049). Should this be an smb.conf tunable parameter
based on the number of open file descriptors available ?
If so what scaling factor ? More tests to follow.
Jeremy.
(This used to be commit 6a902ec49f)
2007-10-10 11:05:16 -05:00
Jeremy Allison
533da83852 r11341: Put directory opens into the share mode db so we
can treat them similarly to file opens (delete on
close, share mode violations etc.). This fixes bug
#3216 I will up the default hash size on the locking
db in a later commit as this means more entries.
Jeremy.
(This used to be commit 1134abbbb3)
2007-10-10 11:05:13 -05:00
Gerald Carter
54abd2aa66 r10656: BIG merge from trunk. Features not copied over
* \PIPE\unixinfo
* winbindd's {group,alias}membership new functions
* winbindd's lookupsids() functionality
* swat (trunk changes to be reverted as per discussion with Deryck)
(This used to be commit 939c3cb5d7)
2007-10-10 11:04:48 -05:00
Jeremy Allison
af8a691db1 r8219: Merge the new open code from HEAD to 3.0. Haven't yet run the torture
tests on this as it's very late NY time (just wanted to get this work
into the tree). I'll test this over the weekend....
Jerry - in looking at the difference between the two trees there
seem to be some printing/ntprinting.c and registry changes we might
want to examine to try keep in sync.
Jeremy.
(This used to be commit c7fe18761e)
2007-10-10 10:58:18 -05:00
Jeremy Allison
74563c5806 r7975: One more tidyup to ensure we're using "struct posix_lock".
Jeremy.
(This used to be commit 960a5d37d1)
2007-10-10 10:58:05 -05:00
Jeremy Allison
3d306127aa r7972: Tidy up the posix locking in memory db code whilst I'm waiting for jht
to get back to me with a backtrace.
Jeremy.
(This used to be commit f2bcfdddc7)
2007-10-10 10:58:05 -05:00
Jeremy Allison
114067ced1 r6594: Fix silly typo causing tdb to be freed twice.
Jeremy.
(This used to be commit 4f431dfc6b)
2007-10-10 10:56:46 -05:00
Jeremy Allison
fc396cb220 r6543: Fix EDEADLCK problem with deferred open calls. Problem found by
"Hu, David J" <david.hu@hp.com>
Jeremy.
(This used to be commit ec86ac4b28)
2007-10-10 10:56:44 -05:00
Herb Lewis
ed1f7121a3 r6502: add LOCKING debug class - pull PRINTINGDB class definition from trunk
so our numbers don't get out of sync
(This used to be commit 58e307664e)
2007-10-10 10:56:43 -05:00
Jeremy Allison
8dddd763d8 r5634: Fix 64-bit overflow problems found by BlueArc torture tester.
We still have a few strange bugs with 64-bit locking values. I will
get traces.
Jeremy.
(This used to be commit ff4c201d93)
2007-10-10 10:55:51 -05:00
Jeremy Allison
c4591307aa r5625: Reformat (tidy).
(This used to be commit b94db3a758)
2007-10-10 10:55:51 -05:00
Jeremy Allison
9345663328 r4143: Make strict locking an enum. Auto means use oplock optimization.
Jeremy.
(This used to be commit 0dd4adeae2)
2007-10-10 10:53:36 -05:00
Jeremy Allison
822fcec39d r4121: Optimisation from Nadav Danieli <nadavd@exanet.com>. If we're oplocked,
short circuit some is_locked() tests.
Jeremy.
(This used to be commit f4feed8f90)
2007-10-10 10:53:35 -05:00
Jeremy Allison
695188cc26 r4108: As check_self is *always* False in every invokation, remove the
logic for it. We still pass Samba4 RAW-LOCK test.
Jeremy.
(This used to be commit 596f230513)
2007-10-10 10:53:34 -05:00
Jeremy Allison
acf9d61421 r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation
functions so we can funnel through some well known functions. Should help greatly with
malloc checking.
HEAD patch to follow.
Jeremy.
(This used to be commit 620f2e608f)
2007-10-10 10:53:32 -05:00
Jeremy Allison
5aafdee906 r3120: Fix bug #1955 reported by Love <lha@stacken.kth.se>. Inconsistent error return.
Jeremy.
(This used to be commit c6b144654a)
2007-10-10 10:53:01 -05:00
Jeremy Allison
8c1c918c94 r3050: Steal from Samba4 :-). Make us pass most of the new lock tests (except for
the cancel lock which I have to add).
Jeremy.
(This used to be commit cf7f89999e)
2007-10-10 10:52:59 -05:00
Andrew Tridgell
b0202c7b85 r3008: when checking for the existance of a lock we are only doing a single
tdb call, so there is no need to get the chainlock. This reduces the
number of tdb locking calls made on file IO
(This used to be commit 78e904c27b)
2007-10-10 10:52:59 -05:00
Jeremy Allison
f820b921cd r2413: Arggg. Stupid, stupid, stupid me ! I added a paranoia test
case when I was developing the deferred open case and made it
too tight. It will fire (incorrectly) and panic when a client
does a second open for a file with a different mid (multiplex-id)
request. Doh ! This is a perfectly valid thing for a client to
do (have two pending opens with different mids outstanding on
the same file) and currently when the first pending open expires
with a share violation the paranoia code will panic smbd.

It's a rare condition, but obvious now I've looked at the
code.

Fix for bug #1743.

Jeremy.
(This used to be commit e1bf108ae9)
2007-10-10 10:52:42 -05:00
Jeremy Allison
2fc57c9a2c r1085: Now it's had some proper user testing, merge in the deferred open fix. I'm
still doing more testing, but it fixes a behaviour that we've been wrong
on ever since the start of Samba.
Jeremy.
(This used to be commit 894cc6d162)
2007-10-10 10:51:54 -05:00
Gerald Carter
386a11f49e r1011: fix bad merge (from a few months ago) and ensure that we always use tdb_open_log() instead of tdb_open_ex()
(This used to be commit e65564ab4a)
2007-10-10 10:51:53 -05:00
Jeremy Allison
ac5f0785c8 r984: Ensure memmove & memcpy aren't called with len == 0.
Jeremy.
(This used to be commit 40c77dddc6)
2007-10-10 10:51:52 -05:00
Gerald Carter
df6d2db4ce merge from old APP_HEAD
* remove corrupt tdb and shutdown (only for printing tdbs, connections,
  sessionid & locking)
* decrement smbd counter in connections.tdb in smb_panic()
* various Makefile hack to get things to link

'max smbd processes' looks like it might be broken.  The counter KEY is not
being set.  Will look into that tomorrow.
(This used to be commit 6e22c5da92)
2004-02-12 05:24:02 +00:00
Jeremy Allison
22c0241571 Changes to allow Samba3 to pass the Samba4 RAW-READ tests.
Jeremy.
(This used to be commit e7565dbba6)
2003-10-09 01:46:01 +00:00
Jeremy Allison
07c90e499e Tidy up some formatting. Get ready for allowing bad password lockout. (based
on a patch posted from Richard Renard <rrenard@idealx.com>.
Jeremy.
(This used to be commit abf54b58e9)
2003-09-08 20:42:33 +00:00
Jeremy Allison
ef915c8eaf Final fix for the bug tridge found. Only push locks onto a blocking lock
queue if the posix lock failed with EACCES or EAGAIN (this means another
lock conflicts). Else return an error and don't queue the request.
Jeremy.
(This used to be commit 43fbc18fdc)
2003-08-01 06:10:30 +00:00
Tim Potter
80c1f1d865 Fixup a bunch of printf-style functions and debugs to use unsigned long when
displaying pid_t, uid_t and gid_t values.  This removes a whole lot of warnings
on some of the 64-bit build farm machines as well as help us out when 64-bit
uid/gid/pid values come along.
(This used to be commit f93528ba00)
2003-07-22 04:31:20 +00:00
Jeremy Allison
78a4f6fc4b More fixes for debug log to catch logic error.
Jeremy.
(This used to be commit 84a7714eba)
2003-05-22 18:56:51 +00:00
Alexander Bokovoy
bc2a3748e9 Prefix VFS API macros with SMB_ for consistency and to avoid problems with VFS_ macros at system side. We currently have one clash with AIX and its VFS_LOCK. Compiled and tested -- no new functionality or code, just plain rename of macros for yet-unreleased VFS API version. Needs to be done before a24 is out
(This used to be commit c2689ed118)
2003-05-14 10:59:01 +00:00
Alexander Bokovoy
e7c8c15888 Fix VFS layer:
1. Finally work with cascaded modules with private data storage per module
2. Convert VFS API to macro calls to simplify cascading
3. Add quota support to VFS layer (prepare to NT quota support)

Patch by Stefan (metze) Metzemacher, with review of Jelmer and me
Tested in past few weeks. Documentation to new VFS API for third-party developers to follow
(This used to be commit 91984ef5ca)
2003-05-11 23:34:18 +00:00
Jeremy Allison
34226f1bd4 Fix for very subtle POSIX lock interaction race condition found by
Herb. We need to unlock POSIX locks before notifying pending lock
processes.
Jeremy.
(This used to be commit 6999eef51c)
2003-04-04 20:38:12 +00:00
Jeremy Allison
fb3e4b8797 Fix to allow blocking lock notification to be done rapidly (no wait
for smb -> smb lock release). Adds new PENDING_LOCK type to lockdb
(does not interfere with existing locks).
Jeremy.
(This used to be commit 766928bbba)
2003-02-27 01:04:34 +00:00
Andrew Bartlett
98410be607 Merge off-by-one fix from HEAD (caused crash with --enable-developer)
(This used to be commit d714254130)
2003-02-24 03:03:15 +00:00
Jeremy Allison
285a3b0ef8 When checking is_locked() new WRITE locks conflict with existing READ locks even
if the context is the same. See LOCKTEST7 in smbtorture.
Jeremy.
(This used to be commit 1698092ba5)
2003-02-22 01:09:57 +00:00
Jeremy Allison
7fe6742d04 Fixes for HPUX only having limited POSIX lock range from Michael Steffens <michael.steffens@hp.com>
Jeremy.
(This used to be commit e9b4fb8b9a)
2003-02-12 20:40:29 +00:00
Andrew Bartlett
8a20407442 Cleanups: (merge from HEAD)
- use safe_strcpy() instead of pstrcpy() for malloc()ed strings

 - CUPS: a failure in an attempt to automaticly add a printer is not level 0 stuff.

 - Fix up a possible Realloc() failure segfault

Andrew Bartlett
(This used to be commit c1cfc296c2)
2003-02-10 11:47:21 +00:00
Jeremy Allison
20f1cf6cdc Fix problem with "hide unreadable". stat file opens are baaack :-).
Jeremy.
(This used to be commit 62038a0abf)
2003-01-03 18:50:13 +00:00
Jeremy Allison
ef8bd7c4f7 Forward port the change to talloc_init() to make all talloc contexts
named. Ensure we can query them.
Jeremy.
(This used to be commit 09a218a9f6)
2002-12-20 20:21:31 +00:00
Jeremy Allison
de474974ea Lots of fixes for error paths where tdb_fetch() data need freeing.
Found via a post from Arcady Chernyak <Arcady.Chernyak@efi.com>.
Jeremy.
(This used to be commit 5d5762d178)
2002-11-23 02:52:36 +00:00
Gerald Carter
a834a73e34 sync'ing up for 3.0alpha20 release
(This used to be commit 65e7b5273b)
2002-09-25 15:19:00 +00:00
Andrew Tridgell
e90b652848 updated the 3.0 branch from the head branch - ready for alpha18
(This used to be commit 03ac082dcb)
2002-07-15 10:35:28 +00:00
Jeremy Allison
c90cd26e94 Fix the mp3 rename bug - also tidy up our open code and remove the special
cases for rename and unlink. Had to add desired_access into the share mode record.
Jeremy.
(This used to be commit 3b1b8ac435)
2002-03-23 02:57:44 +00:00
Andrew Tridgell
7d4378cc89 if our lock spin code fails then return the first error code, not the
last one. This is what caused the lock1 and lock2 tests to fail.
(This used to be commit e7ae8003cb)
2002-03-15 09:51:37 +00:00
Jeremy Allison
d6d9e385cc Use sys_usleep not usleep.
Jeremy.
(This used to be commit 8587dd95f8)
2002-03-14 01:05:34 +00:00
Jeremy Allison
f9af25c4ec Ensure we attempt to lock at least once. Only sleep if time param set.
Jeremy.
(This used to be commit 62b80d5c65)
2002-03-13 20:49:57 +00:00
Jeremy Allison
5e3b923124 include/smb_macros.h: Don't round up an allocation if the size is zero.
"One of these locks is not like the others... One of these locks is not
quite the same" :-). When is a zero timeout lock not zero ? When it's
being processed by Windows 2000 of course.. This code change, ugly though
it is - completely fixes the foxpro/access multi-user file system database
problems that people have been having. I used a *wonderful* test program
donated by "Gerald Drouillard" <gerald@drouillard.ca> which allowed me
to completely reproduce this problem, and to finally determine the correct
fix. This also explains why Windows 2000 is *so slow* when responding to
the smbtorture lock tests. I *love* it when all these things come together
and finally make sense :-).
Jeremy.
(This used to be commit 8aa9860ea2)
2002-03-13 20:28:19 +00:00
Andrew Tridgell
be389e25dd this attempts to handle the rather bizarre lock cache semantics in
w2k. It isn't entirely accurate, but its close
(This used to be commit e02d736470)
2002-03-10 23:17:07 +00:00
Andrew Tridgell
d160b35240 accept the 0/0 lock but don't treat it in any sort of special way
(This used to be commit 8f7bf38de1)
2002-03-05 19:54:45 +00:00
Tim Potter
cd68afe312 Removed version number from file header.
Changed "SMB/Netbios" to "SMB/CIFS" in file header.
(This used to be commit 6a58c9bd06)
2002-01-30 06:08:46 +00:00
Jeremy Allison
c1efcac59c Debugs that print out a share mode table in debug level 10. This code
enabled me to track down a *nasty* bug.
Jeremy.
(This used to be commit ed5a9a0ee3)
2002-01-08 00:52:36 +00:00
Jeremy Allison
86b3aeb42a Added DEBUG in set_share_mode to track down logic insanity.
Jeremy.
(This used to be commit 32f4f3a45d)
2002-01-05 02:37:23 +00:00
Tim Potter
95a4903b20 Removed unused function, delete_fn()
(This used to be commit f26e8205cf)
2001-12-18 05:04:09 +00:00
Jeremy Allison
9e88a7ebe9 After conversations with Andrew, improved the robustness of the
sharemode db in the following way.

Originally, on startup and shutdown, smbd would scan the share mode
db to ensure it was correct. This lead to scalability issues as
scans lock the db for quite a long time. Andrew had the brainstorm
that we only care about the record we're about to read.

This new code (small change really, but quite significant) causes
get_share_modes() to do a process_exists() call against each pid
in each record, and to delete any that don't and re-write the
entry if any dead records were detected.

This allowed me to remove the startup/shutdown scans of the
db (they can be added into smbstatus if anyone really cares to
have them back). This will please the vfs author who was worried
about the time taken on open() calls, and will lead to much
greater robustness and scalability in the share mode db.

We need much testing of this, and also netbench tests to
ensure the extra process_exists() calls don't hurt performance
(they shouldn't it's a very simple system call).

Jeremy.
(This used to be commit 4098d44203)
2001-11-30 01:59:03 +00:00
Jeremy Allison
e5c5adb197 Don't scan locking db on closedown.
Jeremy.
(This used to be commit 59cfcd8a6c)
2001-11-21 04:00:35 +00:00
Jeremy Allison
88b55f47b4 Move from timestamp to gen count file id's for finding oplocked files
in a tdb.
Jeremy.
(This used to be commit 058ae6b58f)
2001-10-20 21:59:34 +00:00
Jeremy Allison
07f54cb592 Ensure we mask off deny modes correctly on being set (this shouldn't have
caused problems but is tidier).
Fix debug statement in locking.c
Jeremy.
(This used to be commit eac6bbd24e)
2001-10-19 23:56:21 +00:00
Tim Potter
dc1fc3ee8e Removed 'extern int DEBUGLEVEL' as it is now in the smb.h header.
(This used to be commit 2d0922b0ea)
2001-10-02 04:29:50 +00:00
Jeremy Allison
8c8b9c69e5 Removed test code that got added by accident.
Jeremy.
(This used to be commit fc91ecc236)
2001-09-19 06:49:02 +00:00
Jeremy Allison
5bc82e443b Correct fix for unaligned memcpy - malloc'ed memory incremented by sizeof(struct locking_data)
was not forced to be 8 byte aligned. Use union to force it to be correctly aligned
for memcpy and use void *, to tell compiler not to optimize aligned copy (this last fix
suggested by Trond @ RedHat). The first fix should be sufficient, but this provides a
"belt and braces" fix.
Jeremy.
(This used to be commit 22c5915bb4)
2001-09-18 06:41:29 +00:00
Jeremy Allison
36a6611da2 Use structure copy to fix unaligned accesses on 64bit architectures on
Linux.
Jeremy.
(This used to be commit b4b891279b)
2001-09-18 06:20:28 +00:00
Simo Sorce
81fdc3c3f7 move to SAFE_FREE()
(This used to be commit e61aec84ed)
2001-09-17 04:16:35 +00:00
Jeremy Allison
83ebf2b6b2 Fix the 62bit locking onto 32 bit NFS mounts problem generically for HPUX.
Don. please check this out.
Jeremy.
(This used to be commit ce9f959964)
2001-09-06 22:43:21 +00:00
Andrew Tridgell
9a9ac2739b got rid of USE_TDB_MMAP_FLAG as its not needed any more
(This used to be commit c26e0d3f27)
2001-09-06 22:08:19 +00:00
Andrew Tridgell
9ef7a6c786 use NTSTATUS not BOOL in do_lock()
(This used to be commit b1b2a5fa5d)
2001-09-06 01:19:35 +00:00
Andrew Tridgell
4f0509aeeb 2nd DELETE_ON_CLOSE_FLAG fix ...
we set the DELETE_ON_CLOSE_FLAG on all share modes on the file, which
means the share mode in the fsp will not match the one in the tdb when
we come to close for other file handles, which means we end up with
share modes on files after all handles are closed

fixed by making the comparison function that says if two shares modes
are equal ignore the DELETE_ON_CLOSE_FLAG
(This used to be commit 7b39c4c598)
2001-09-05 21:39:43 +00:00
Jeremy Allison
d3518f1d8a NFS v2 can return ENOLCK when greater than 31 bit offsets are used.
Treat this the same as an EFBIG error.
Jeremy
(This used to be commit 8fad517770)
2001-09-05 00:05:07 +00:00
Andrew Tridgell
19fea3242c the next stage in the NTSTATUS/WERROR change. smbd and nmbd now compile, but the client code still needs some work
(This used to be commit dcd6e735f7)
2001-09-04 07:13:01 +00:00
Andrew Tridgell
b031af348c converted another bunch of stuff to NTSTATUS
(This used to be commit 1d36250e33)
2001-08-27 19:46:22 +00:00
Andrew Tridgell
ee5f7237de started converting NTSTATUS to be a structure on systems with gcc in order to make it type incompatible with BOOL so we catch errors sooner. This has already found a number of bugs
(This used to be commit 1b778bc7d2)
2001-08-27 17:52:23 +00:00
Andrew Tridgell
e8e98c9ea0 converted smbd to use NTSTATUS by default
major changes include:

- added NSTATUS type
- added automatic mapping between dos and nt error codes
- changed all ERROR() calls to ERROR_DOS() and many to ERROR_NT()
  these calls auto-translate to the client error code system
- got rid of the cached error code and the writebmpx code

We eventually will need to also:
- get rid of BOOL, so we don't lose error info
- replace all ERROR_DOS() calls with ERROR_NT() calls

but that is too much for one night
(This used to be commit 83d9896c1e)
2001-08-27 08:19:43 +00:00
Jeremy Allison
4a3f07456d Ignore locks of length zero as they mean different things in Win32
and POSIX.
Jeremy.
(This used to be commit bd9cbf4c68)
2001-08-26 19:39:40 +00:00
Jeremy Allison
10c240ef97 Don't use CLEAR_IF_FIRST if opening read-only.
Jeremy.
(This used to be commit f5ba19c129)
2001-08-26 19:27:18 +00:00
Andrew Tridgell
c1598db18e we now have all but the dreaded 0/0 lock working
(This used to be commit 98b6aef18c)
2001-08-24 21:09:38 +00:00
Andrew Tridgell
7874b0ac17 0 byte lock ranges ARE valid
(This used to be commit 5498da6664)
2001-08-24 04:55:28 +00:00
Jeremy Allison
85e063f5b8 Tidyup fixes for fcntl spin problem.
Jeremy.
(This used to be commit 27d3dd0e7c)
2001-08-22 01:01:37 +00:00