1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00
Commit Graph

161 Commits

Author SHA1 Message Date
Tim Potter
aee52c7acf tdb_unlockchain() no longer returns a value 0001-01-01 00:00:00 +00:00
Jeremy Allison
9dea7b7c25 Changed to sourceforge tdb code. This includes spinlocks (so we now have
a --with-spinlocks option to configure, this does mean the on-disk tdb
format has changed, so 2.2alphaX sites will need to re-create their
tdb's. The upside is no more tdb fragmentation and a +5% on netbench.
Swings and roundabouts....
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
b456274a7b Fix from John Reilly for equivalence tests.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
dfe77c7046 Herb's warning fixes. Also the POSIX locking fix.
We now use our own vfs layer to do get/set acl calls (hurrah!).
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
b07611f815 Restructuring of vfs layer to include a "this" pointer - can be an fsp or
a conn struct depending on the call.
We need this to have a clean NT ACL call interface.
This will break any existing VFS libraries (that's why this is pre-release
code).
Andrew gets credit for this one :-) :-).

In addition - added Herb's WITH_PROFILE changes - Herb - please examine
the changes I've made to the smbd/reply.c code you added. The original
code was very ugly and I have replaced it with a
START_PROFILE(x)/END_PROFILE(x) pair using the preprocessor.
Please check this compiles ok with the --with-profile switch.
Jeremy.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
2a34ee95f3 the first cut of the internal messaging system.
The motivation for this system is to replace the UDP message for
oplocks, but this commit only does the "set debug level" message.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
b9d78738bb allow posix locking database to be opened read-only (for smbstatus) 0001-01-01 00:00:00 +00:00
Andrew Tridgell
bf67721ef5 add some brackets 0001-01-01 00:00:00 +00:00
Jeremy Allison
07872298e3 Fixed misunderstanding found during CIFS conference. Overlapping lock
ranges (not just included lock ranges) should be handled correctly.
UNIT test still needed.
Jeremy.
0001-01-01 00:00:00 +00:00
Herb Lewis
f2a5ba3f09 Using a structure for a tdb key can lead to insideous, hard
to find bugs. On 64 bit IRIX, structure packing means that
a
struct {
SMB_DEV_T dev /* 4 bytes */
SMB_INO_T ino /* 8 bytes */
}

has 4 bytes of padding between the two members. If you
don't null the memory before using it as a tdb key,
you randomly can't find keys depending on what is in
the padding. This caused me immense pain and was hard
to track down.... :-)

Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
df87259a35 Fix for uninitialized memory read in brlock code. brl_locktest now needs
to correctly set the fnum, as the brl_conflict code looks at it.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
82681edda1 Two fixes. Added missong logic & case in lock split code.
Fixed range split into two, as DLIST_ADD has the wrong semantics...
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
9bdfe0f502 Updated to fix overlapping problem.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
57bf92d901 Fix for debug statement crash.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
09e92a61a9 Fix based on Elrond's code to reduce the store size on removing dead records.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
65150c408a Fixed the bug locktest.c found, it was an off-by-one error in the non-overlap
case.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
d4dcefd12d Fixed silly bug where I wasn't checking for matching fd's in closing a file.
This caused smbd crashes on SIGKILL.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
91f038356b Added range info to the panic message to track down the bug with
locktest.
Jeremy.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
51624a3a2f - clear dead locks at startup
- fixed a bug which caused lock records to not decrease in size
0001-01-01 00:00:00 +00:00
Jeremy Allison
74d42644e6 Fix for stacking locks in brlock and POSIX. Windows only allows a read lock
to overlay a write lock on the same fnum. When overlaying read locks onto
a write lock, the number of locks is counted, and the first unlock removes
the write lock and downgrades this to a read lock. Do the same when mapping
to POSIX.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
6eb4fb6eef Implemented the last (I hope:-) part of the locking puzzle, the reference
counting when Windows downgrades a write lock to a read lock, then reference
counts the unlocks to match the locks.
With this code the POSIX unlock isn't done until the final Windows unlock.
Jeremy.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
ee8546342d split the username in the vuser structure into a separate
userdom_struct. As the name implies this also contains a domain
(unused at the moment).

This will be important shortly, as operation in appliance mode needs
the domain to be always carried with the username.
0001-01-01 00:00:00 +00:00
Jeremy Allison
46092ee141 Moved uglyness needed in fcntl locking (64->32 bit mapping, NFS
errors etc.) into locking/posix.c, where it is needed. fcntl_lock in lib/util.c
is now very small and clean.
Added (*lock) op to vfs layer.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
148628b616 Added sys_fork() and sys_getpid() functions to stop the overhead
of doing a system call every time we want to just get our pid.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
3b25f7368b locking/posix.c: Fixed double-free nasty crash bug found by insure.
utils/make_smbcodepage.c:
utils/make_unicodemap.c: Insure 'make install' fixes.
Jeremy.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
8ec815920d added TDB_INTERNAL, TDB_NOLOCK and TDB_NOMMAP flags.
TDB_INTERNAL replaces the old method of passing a null filename
0001-01-01 00:00:00 +00:00
Andrew Tridgell
03e9cea004 - removed all our old wildcard matching code and replaced it with a
call to ms_fnmatch(). This also removes all the Win9X semantics stuff
and a bunch of other associated cruft.

- moved the stat cache code into statcache.c

- fixed the uint16 alignment requirements of ascii_to_unistr() and
  unistr_to_ascii()

- trans2 SMB_FIND_FILE_BOTH_DIRECTORY_INFO returns the short name as
  unicode always (at least thats what NT4 does)

- fixed some errors in the in-memory tdb code. Still ugly, but doesn't
  crash as much
0001-01-01 00:00:00 +00:00
Jeremy Allison
6bded3b74e Removed tdb locking calls (picky Andrew...:-) 0001-01-01 00:00:00 +00:00
Jeremy Allison
3f655de1c7 Ok - this is the *third* implementation of this (third time's the charm :-).
This implementation keeps all POSIX lock records in a separate in memory
tdb database only known about in locking/posix.c. In addition, the pending
close fd's are also held in a tdb which has an array of fd's indexed by
device and inode.

The walk-split code uglyness has been moved to posix.c from brlock.c,
which is the only place that needs to know about it, and the extra
functions hacked into brlock to expose internal state have been removed.

This implementation passes smbtorture locktest4, the only thing I need
to check now for completeness is what to do about lock upgrade/downgrades
which Win32 allows under some *very* strange circumstances.

Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
31a57be658 Split off of POSIX locking into separate unit as Andrew requested.
Done so I don't lose my edits... :-).
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
b812f09ba8 Forgot to close when "posix locking" is set to False.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
a2deb91128 Added optimization where we are single opener (don't free POSIX locks).
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
239abd48f0 Made changes suggested by Andrew review.
fd_close now calls fd_close_posix() directly.
set_posix_lock/release_posix_lock() now handle the reference counting.
More changes due when this gets moved to the file locking/posix.c
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
6baa96bb46 Ok - this is more subtle than it looks :-).
When a file is being closed, once it passes the fnum and tid tests then
the locking context should be ignored when removing all locks. This is
what is done in the brl close case, but when you have outstanding
POSIX locks, then you cannot remove all the brl locks in one go, you
have to get the lock list and call do_unlock individually. As this
uses global_smbpid as the locking context, you need to make sure
that this is set correctly for the specific lock being removed. I
now do this by storing the smbpid in each entry in the unlock list returned from
the query call. I removed the smbpid from fsp (not needed) and
things seem ok (even with the stupid smbpid tricks that smbtorture plays :-).

Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
2746e5602e Fixed subtle unlocking bug when a file is closed. We need to store the
smbpid used when a file was opened in the files_struct. Else we use
the wrong global_smbpid when we are closing the file and trying to
remove the brl locks - this causes the brl locks to be left when the
file is closed as the samba_context check fails.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
0487841120 Did the rewrite Andrew wanted where all knowledge of POSIX locking is
removed from the smbd/open.c code.
We now use a dlink list of structures indexed by dev/inode to store
all pending fd's for close. This could be rewritten to use lib/hash.c
if this is discovered to be too slow in use.
Andrew, please take a look and let me know if this is what you
had in mind.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
5278ec016c Fixed crash bugs Andrew pointed out with LOCK4 smbtorture
test. Was miscounting posix locks, plus was not taking into account
the case where other_fsp == fsp in the 'move locks' case. DOH ! This
code will be re-written anyway :-).
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
135855dbd3 Added the hard code :-).
HEAD should now map brl locks correctly into POSIX locks, including the
really nasty case of large range unlock.

There is a lot of pretty ASCII art in locking/brlock.c explaining
exactly how this code works. If it is unclear, please ask me.

Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
1df48ed55e Added the code that keeps fd's open across a close if there are other fsp's
open on the same dev/inode pair with existing POSIX locks.

This is done at the smbd/open layer, so smbd just calls fd_close() and
the transfer of any open fd's is done under the covers of fd_close().
When an fsp is closed and no other fsp's open on the same dev/inode
pair have existing POSIX locks then all fd's associated with this fsp
are closed.

Now only the hard part of doing the POSIX range unlock code when read
locks overlap remains for full POSIX/SMB lock integration....

Jeremy.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
990b16fcf7 fixed a locking database bug - it was actually harmless except that
smbstatus could display the wrong filename when files change dev/inum
after a rename
0001-01-01 00:00:00 +00:00
Jeremy Allison
ab0ecc39d6 This is a *big* checkin that may break some things, but implements the
new open mechanism Andrew & I discussed.

config.sub:
configure: Included the QNX patch.

include/vfs.h:
smbd/vfs-wrap.c:
smbd/vfs.c: Added ftruncate vfs call (needed).

Note that we will also need locking calls in the vfs (to be added).

lib/util_unistr.c:
nmbd/nmbd_processlogon.c: Fix for NT domain logons causing nmbd to core dump.
                          Also fix for sidsize DOS bug.

locking/locking.c: Check value of ret before using it for memdup.

printing/printing.c: Convert print_fsp_open to return an allocated fsp.

rpc_server/srv_lsa.c: Fix for NT domain logons.

I have removed all use of lp_share_modes() from the code (although I
left the parameter in the table for backwards compatibility). It no longer makes
sense for this to exist.

smbd/close.c: Removed lp_share_modes().
smbd/fileio.c: Fixed parameters to unlock_share_entry call in panic code.
smbd/files.c: Correctly set the unix_ERR_code to ERRnofids on fsp allocation fail.

smbd/nttrans.c:
smbd/reply.c:
smbd/trans2.c: Changed all occurrences of open_file_shared/open_directory/
               open_file_stat to return an fsp from the call.

smbd/open.c: Changed all occurrences of open_file_shared/open_directory/
             open_file_stat to return an fsp from the call.

In addition I have fixed a long standing race condition in the deny mode
processing w.r.t. two smbd's creating a file. Andrew, please note that
your original idea of using open with O_EXCL in this case would not work
(I went over the races very carefully) and so we must re-check deny modes
*after* the open() call returns. This is because there is a race between
the open with O_EXCL and the lock of the share mode entry. Imagine the
case where the first smbd does the open with O_EXCL and a deny mode of DENY_ALL,
but is pre-empted before it locks the share modes and creates the deny
mode entry for DENY_ALL. A second smbd could then come in with O_RDONLY
and a deny mode of DENY_NONE and the two opens would be allowed.

The *only* way to fix this race is to lock the share modes after the
open and then do the deny mode checks *after* this lock in the case
where the file did not originally exist.

This code will need extensive testing but seems to initially work.

Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
204ca1195c locking/locking.c: Fixed placeholder code for POSIX locking.
printing/printing.c: Cast tdb_delete to (tdb_traverse_func) to stop warning.
                     tmpfile gives mirror warning.
smbd/groupname.c: Remember to file_lines_free() on exit.
tdb/tdb.h: Add tdb_traverse_func typedef.
Jeremy
0001-01-01 00:00:00 +00:00
Jeremy Allison
0216d81f06 Typo - missing '}'.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
3de058bd43 Removed "ole locking compat" parameter (no longer used).
We now get/set/check POSIX locks, but I still need to code up the
close fd braindamage...
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
9c3b9146a3 Implmented mapping of lock offset/count from 64 bit MS ranges
to either 63 or 31 bit POSIX ranges. Code to get these locks
not yet added.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
db96f83e34 Code to map tdb locks onto POSIX. Mainly placeholder code at the moment,
but the structure is done enough so that Andrew can look it over and give
a yea/nay decision.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
491eea8a20 include/byteorder.h: ALIGN4/ALIGN2 macros.
include/includes.h: Added SMB_BIG_UINT_BITS.
lib/util.c: Removed align2/align4 - use macros.
libsmb/namequery.c: Use ALIGN2.
locking/locking.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T.
                   Needed to move to hiding POSIX locks at a lower layer.
nmbd/nmbd_processlogon.c: Use ALIGN2/ALIGN4 macros.
smbd/blocking.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T.
smbd/reply.c: Replace do_lock, do_unlock, args with SMB_BIG_UINT, not SMB_OFF_T.
Jeremy.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
368b0bc1b1 the first of a bunch of changes to code with getting rid of the fd_ptr
element in the fsp

pretty mechanical stuff, but it affects lots of files.
0001-01-01 00:00:00 +00:00
Tim Potter
eefc897221 Fixed compile warning in locking.c:traverse_fn() 0001-01-01 00:00:00 +00:00
Luke Leighton
49d7f0afbc 1) added void* state argument to tdb_traverse. guess what! there were
two places i found where it was appropriate to _use_ that third argument,
in locking.c and brlock.c!  there was a static traverse_function and
i removed the static variable, typecast it to a void*, passed it to
tdb_traverse and re-cast it back to the traverse_function inside the
tdb_traverse function.  this makes the use of tdb_traverse() reentrant,
which is never going to happen, i know, i just don't like to see
statics lying about when there's no need for them.

as i had to do in samba-tng, all uses of tdb_traverse modified to take
the new void* state argument.

2) disabled rpcclient: referring people to use SAMBA_TNG rpcclient.
i don't know how the other samba team members would react if i deleted
rpcclient from cvs main.  damn, that code's so old, it's unreal.
20 rpcclient commands, instead of about 70 in SAMBA_TNG.
0001-01-01 00:00:00 +00:00