1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-25 06:04:04 +03:00

870 Commits

Author SHA1 Message Date
Andrew Tridgell
09355fcd50 - added some error checking
- removed the VTP hook in smbd
-
Andrew Tridgell
0bab030074 fixed dptr_wcard handling (need to use strdup) -
Andrew Tridgell
4a15924ffe removed more cruft from our old wildcard matching code -
Andrew Tridgell
85d634974f go back to ascii in SMB_FIND_FILE_BOTH_DIRECTORY_INFO
NT gives out unicode, but NT clients can't handle a unicode response!
-
Andrew Tridgell
38f5e13367 fixed our smbsearch code. We now store the mask with the dptr, this
turns out to be essential for a correct implementation (there ins't
enough room to store all possible masks in the status return
structure!)
-
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
-
Jeremy Allison
858eb53dc5 Moved deletion of vfs handle into smbd/conn.c as it was being done too
soon in smbd/service.c (file operations were being done after the
handle was closed).

It looks cleaner in smbd/conn.c as it is part of the closing of a conn
struct anyway.

Jeremy.
-
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.
-
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.
-
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.
-
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.
-
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.
-
Jeremy Allison
9cde198108 Fixed range check on writeX.
Jeremy.
-
Jeremy Allison
4a4b7a994b Tidyup of smbecho.
Jeremy.
-
Andrew Tridgell
d7cd7c88fd moved trans2.h and nterr.h into includes.h with all our other includes -
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.
-
Jeremy Allison
389b700a26 Now that fsp's are created on successful file open, the structure member
fsp->open is no longer needed (if an fsp pointer is valid, then it's open :-).

NB for Luke, this patch also did not apply to TNG. TNG is not yet
identical w.r.t file serving with HEAD. This makes it impossible for
me to help maintain TNG. Please fix asap.

lib/substitute.c: Removed unused variable (pidstr).

Jeremy.
-
Andrew Tridgell
2fba24ef0e moved INSURE hook into util.c -
Andrew Tridgell
e4ddd1a4a9 fixed two uninitialised memory references -
Andrew Tridgell
bb9b3e03de trick to get full stack trace when using the free version of insure -
Andrew Tridgell
53077295b7 insure caught an uninitialised memory reference - ensure it starts as
zero
-
Andrew Tridgell
062d79bf8b avoided a memory leak in the ubi code by deleting a mangled cache
entry before adding to ensure that we don't ever add a duplicate entry

this code can be removed when ubi gets fixed
-
Andrew Tridgell
d0fc1675df don't copy a null groups list -
Andrew Tridgell
1106fa7f24 fixed overlapping strcpy() found by insure -
Andrew Tridgell
14251aab2e fixed uninitialised snum -
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.
-
Andrew Tridgell
e2eacdd74c split fsusage() into a separate module (to fix linking problems with
spoolssd in tng)
-
Andrew Tridgell
95246a8432 patch from luke to split out lanman code from ipc.c into lanman.c -
Andrew Tridgell
2c2d95d77d - got rid of the "passive" option
- cleaned up the standard_sub_*() calls a lot
-
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
-
Luke Leighton
a0afe0d5f8 ReadDirName calls vfs->readdirname calls dos_readdirname.
replaced with readdirname.  ditto for OpenDir and CloseDir.
-
Andrew Tridgell
384ecd9d66 converted a couple more functions to use a fd instead of a FILE*
added a new utility fn file_lines_slashcont() which is used to handle
files that treat a \ followed by a newline as a blank
-
Andrew Tridgell
a09470817c converted a bunch more functions to use a fd instead of a FILE*
to support some of this I added the following functions in util_file.c

file_lines_pload : load lines from a pipe
file_pload : load a pipe into memory
-
Andrew Tridgell
9f49d17d4c removed old comments -
Andrew Tridgell
e8418ab736 use some symbolic names for print queue status -
Andrew Tridgell
8af879b3f5 added helper fns to change from internal status codes to nt spoolss codes -
Andrew Tridgell
d870542c28 the changes to the main smb code
------------
The following series of commits are for the new tdb based printing
backend. This completely replaces our old printing backend.

Major changes include:

- all print ops are now done in printing/*.c rather than scattered all
  over the place
- system job ids are decoupled from SMB job ids
- the lpq parsers don't need to be nearly so smart, they only need to
  parse the filename, the status and system job id
- we can store lots more info about a job, including the full job name
- the queue cache control is much better

I also added a new utility routine file_lines_load() that loads a text
file and parses it into lines. This is used in out lpq parsing and I
also want to use it to replace all of our fgets() based code in other
places.
-
Jeremy Allison
c3794fd29f Log file check patch from Mattias Gronlund <Mattias.Gronlund@sa.erisoft.se>.
Modified to do checks in timeout processing not in main loop. This (IMHO)
is the correct place as (a) we are already root, and (b) it is guarenteed
to be called every 200 smb requests.
Jeremy.
-
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.
-
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.
-
Jeremy Allison
fbfe94a799 Roll back to using static MACHINE.SID after consultation with Andrew. This
code will be removed soon and a SID auto-generated from (probably) primary
hostname and never stored in a file will replace it.
Jeremy.
-
Jeremy Allison
df4302f391 The latest open() code changes broke the NT directory opens. Detect if a
read-only open on a directory was done and return an EISDIR from open_file().
Changed interface to fd_close to return error.
Jeremy.
-
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.
-
Andrew Tridgell
5937ab14d2 finally got sick of the "extern int Client" code and the stupid
assumption that we have one socket everywhere

while doing so I discovered a few bugs!

1) the clientgen session retarget code if used from smbd or nmbd would
cause a crash as it called close_sockets() which closed our main
socket! fixed by removing close_sockets() completely - it is unnecessary

2) the caching in client_addr() and client_name() was bogus - it could
easily get fooled and give the wrong result. fixed.

3) the retarget could could recurse, allowing an easy denial of
service attack on nmbd. fixed.
-
Jeremy Allison
5480ecf24b Fix for soft quotas not being set from
Norbert Pschel <Pueschel.Norbert@Walzbarren-VAW.ne.uunet.de>
Jeremy.
-
Andrew Tridgell
5257ff5d67 initialise fsp->fd to -1 -
Andrew Tridgell
d1827a3648 the bulk of the changes to get rid of fd_ptr and move print open
handling to printing/printing.c

most of this was just replacing things like fsp->fd_ptr->fd with fsp->fd

the changes in open.c are quite dramatic. Most of it is removing all
the functions that handled the fd multiplexing
-
Andrew Tridgell
c0562a02c3 utmp compile fix from peter@cadcamlab.org -
Jeremy Allison
6c442d68af Change to vfs API. POSIX states fsync should return an int, not a void.
Jeremy.
-
Jeremy Allison
7325059a09 Removed strange optimisation (paranoia fix maybe ?) that stopped smbd
from returning '.' and '..' in a top level listing of a trans2 directory
scan. NT does return these entries.
Jeremy.
-