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

205 Commits

Author SHA1 Message Date
Jelmer Vernooij
b15cfbe251 r3162: Add client-side support for the ncalrpc: and ncacn_unix_stream: transports.
ncalrpc uses the new config option "ncalrpc dir" for creating unix sockets.
2007-10-10 13:02:27 -05:00
Andrew Tridgell
c240c6bca5 r3082: added a "cifs:mapgeneric" option, which tells the cifs backend to use
the ntvfs_generic mapping functions rather than sending the exact
function asked for. This allows the generic mapping functions to be
tested by comparing the behaviour of smbtorture against two cifs
backend shares, one using "cifs:mapgeneric = true" and the other
"cifs:mapgeneric = False"
2007-10-10 13:01:57 -05:00
Andrew Tridgell
3457c1836c r3081: several updates to ntvfs and server side async request handling in
preparation for the full share modes and ntcreatex code that I am
working on.

highlights include:

 - changed the way a backend determines if it is allowed to process a
   request asynchronously. The previous method of looking at the
   send_fn caused problems when an intermediate ntvfs module disabled
   it, and the caller then wanted to finished processing using this
   function. The new method is a REQ_CONTROL_MAY_ASYNC flag in
   req->control_flags, which is also a bit easier to read

 - fixed 2 bugs in the readbraw server code. One related to trying to
   answer a readbraw with smb signing (which can't work, and crashed
   our signing code), the second related to error handling, which
   attempted to send a normal SMB error packet, when readbraw must
   send a 0 read reply (as it has no header)

 - added several more ntvfs_generic.c generic mapping functions. This
   means that backends no longer need to implement such esoteric
   functions as SMBwriteunlock() if they don't want to. The backend
   can just request the mapping layer turn it into a write followed by
   an unlock. This makes the backends considerably simpler as they
   only need to implement one style of each function for lock, read,
   write, open etc, rather than the full host of functions that SMB
   provides. A backend can still choose to implement them
   individually, of course, and the CIFS backend does that.

 - simplified the generic structures to make them identical to the
   principal call for several common SMB calls (such as
   RAW_WRITE_GENERIC now being an alias for RAW_WRITE_WRITEX).

 - started rewriting the pvfs_open() code in preparation for the full
   ntcreatex semantics.

 - in pvfs_open and ipc_open, initially allocate the open file
   structure as a child of the request, so on error we don't need to
   clean up. Then when we are going to succeed the open steal the
   pointer into the long term backend context. This makes for much
   simpler error handling (and fixes some bugs)

 - use a destructor in the ipc backend to make sure that everthing is
   cleaned up on receive error conditions.

 - switched the ipc backend to using idtree for fnum allocation

 - in the ntvfs_generic mapping routines, use a allocated secondary
   structure not a stack structure to ensure the request pointer
   remains valid even if the backend replies async.
2007-10-10 13:01:57 -05:00
Andrew Tridgell
834b09929b r3064: - use UINT8_MAX and UINT16_MAX instead of hex values for idr_get_new() limits
- change idr_get_new() to use > instead of >= in the limit check
2007-10-10 13:01:55 -05:00
Andrew Tridgell
65b7316e9b r3052: added talloc_zero_p() and talloc_zero_array_p() calls, for allocating zeroed memory 2007-10-10 13:01:53 -05:00
Andrew Tridgell
4395c0557a r3029: implemented byte range lock timeouts.
This adds a pvfs_wait_message() routine which uses the new messaging
system, event timers and talloc destructors to give a nice generic
async event handling system with a easy to use interface. The
extensions to pvfs_lock.c are based on calls to pvfs_wait_message()
routines.

We now pass all of our smbtorture locking tests, although while
writing this code I have thought of some additonal tests that should
be added, particularly for lock cancel operations. I'll work on that
soon.

This commit also extends the smbtorture lock tests to test the rather
weird 0xEEFFFFFF locking semantics that I have discovered in
win2003. Win2003 treats the 0xEEFFFFFF boundary as special, and will
give different error codes on either side of it. Locks on both sides
are allowed, the only difference is which error code is given when a
lock is denied. Anyone like to hazard a guess as to why? It has
me stumped.
2007-10-10 13:00:00 -05:00
Andrew Tridgell
1cef44505e r3017: nicer memory handling for event_context_merge() 2007-10-10 12:59:58 -05:00
Andrew Tridgell
58a92abd88 r3012: added initial support for byte range locking in the posix vfs. This is
enough for us to pass locktest, but does not yet support lock timeouts
and some of the other esoteric features.
2007-10-10 12:59:57 -05:00
Andrew Tridgell
04e1171996 r3005: added talloc wrappers around tdb_open() and ldb_connect(), so that the
caller doesn't have to worry about the constraint of only opening a
database a single time in a process. These wrappers will ensure that
only a single open is done, and will auto-close when the last instance
is gone.

When you are finished with a database pointer, use talloc_free() to
close it.

note that this code does not take account of the threads process
model, and does not yet take account of symlinks or hard links to tdb
files.
2007-10-10 12:59:56 -05:00
Stefan Metzmacher
757f67c08b r2992: drsuapi uses WERROR not NTSTATUS
metze
2007-10-10 12:59:55 -05:00
Andrew Tridgell
f76a1cf640 r2961: fixed a silly typo 2007-10-10 12:59:52 -05:00
Andrew Tridgell
2a0c427c2b r2960: during a lunchtime discussion I found out that all powerpc processors
can correctly (and quickly!) handle unaligned little endian memory
accesses, just like i386. This should reduce code size and speeds
things up quite a lot on ppc, at the expense of some inline asm code
(whcih means it only works with gcc)
2007-10-10 12:59:51 -05:00
Andrew Tridgell
3318cf2722 r2951: fixed the intptr_t test for discard_const() 2007-10-10 12:59:51 -05:00
Andrew Tridgell
2132d38f9c r2900: rusty pointed out to me that discard_const() can be done via a macro
on systems that have the intptr_t type, and for systems that don't
have it, they also almost certainly won't have -Wcast-qual, so we can use a
void* cast.
2007-10-10 12:59:46 -05:00
Andrew Tridgell
814881f0e5 r2857: this commit gets rid of smb_ucs2_t, wpstring and fpstring, plus lots of associated functions.
The motivation for this change was to avoid having to convert to/from
ucs2 strings for so many operations. Doing that was slow, used many
static buffers, and was also incorrect as it didn't cope properly with
unicode codepoints above 65536 (which could not be represented
correctly as smb_ucs2_t chars)

The two core functions that allowed this change are next_codepoint()
and push_codepoint(). These functions allow you to correctly walk a
arbitrary multi-byte string a character at a time without converting
the whole string to ucs2.

While doing this cleanup I also fixed several ucs2 string handling
bugs. See the commit for details.

The following code (which counts the number of occuraces of 'c' in a
string) shows how to use the new interface:

size_t count_chars(const char *s, char c)
{
	size_t count = 0;

	while (*s) {
		size_t size;
		codepoint_t c2 = next_codepoint(s, &size);
		if (c2 == c) count++;
		s += size;
	}

	return count;
}
2007-10-10 12:59:39 -05:00
Andrew Tridgell
6c563887f1 r2791: got rid of talloc_unreference() and instead created talloc_unlink(),
which is much clearer and simpler to use. It removes a specific parent
from a pointer, no matter whether that parent is a "reference" or a
direct parent. This gives complete control over the free process.
2007-10-10 12:59:34 -05:00
Andrew Tridgell
8d4dc99b82 r2744: ben elliston taught me about gcov today, which allows you to measure
the % coverage in terms of lines of code of a test suite. I thought a
good first place to start with gcov was the talloc test suite. When I
started the test suite covered about 60% of all lines of code in
talloc.c, and now it covers about 99%. The only lines not covered are
talloc corruption errors, as that would cause smb_panic() to fire.

It will be interesting to try gcov on the main Samba test suite for
smbd. We won't achieve 100% coverage, but it would be nice to get to
90% or more.

I also modified the talloc.c sources to be able to be build standalone, using:

  gcc -c -D_STANDALONE_ -Iinlcude lib/talloc.c

that should make it much easier to re-use talloc in other projects
2007-10-10 12:59:29 -05:00
Andrew Tridgell
f3844cc0a5 r2678: from_name and to_name aren't needed in smb_iconv_t 2007-10-10 12:59:21 -05:00
Andrew Tridgell
c60ff99c31 r2674: I have realised that talloc() should have its context marked const, as
a const pointer really means that "the data pointed to by this pointer
won't change", and that is certainly true of talloc(). The fact that
some behind-the-scenes meta-data can change doesn't matter from the
point of view of const.

this fixes a number of const warnings caused by const data structures
being passed as talloc contexts. That will no longer generate a
warning.

also changed the talloc leak reporting option from --leak-check to
--leak-report, as all it does is generate a report on exit. A new
--leak-report-full option has been added that shows the complete tree
of memory allocations, which is is quite useful in tracking things down.

NOTE: I find it quite useful to insert talloc_report_full(ptr, stderr)
calls at strategic points in the code while debugging memory
allocation problems, particularly before freeing a major context (such
as the connection context). This allows you to see if that context has
been accumulating too much data, such as per-request data, which
should have been freed when the request finished.
2007-10-10 12:59:20 -05:00
Andrew Tridgell
8dc23821c9 r2671: we're getting too many errors caused by the talloc_realloc() API not
taking a context (so when you pass a NULL pointer you end up with
memory in a top level context). Fixed it by changing the API to take a
context. The context is only used if the pointer you are reallocing is
NULL.
2007-10-10 12:59:20 -05:00
Andrew Tridgell
c315d6ac1c r2660: - converted the libcli/raw/ library to use talloc_increase_ref_count()
rather than manual reference counts

- properly support SMBexit in the cifs and posix backends

- added a logoff method to all backends

With these changes the RAW-CONTEXT test now passes against the posix backend
2007-10-10 12:59:18 -05:00
Andrew Tridgell
0cf427d14f r2653: - data_blob() and data_blob_talloc() now get automatic names
- talloc_strdup() and related functions get automatic names
2007-10-10 12:59:17 -05:00
Andrew Tridgell
6e721393d0 r2649: - used some cpp tricks to make users of talloc() and talloc_realloc()
to get auto-naming of pointers very cheaply.

- fixed a couple of memory leaks found with the new tricks

A typical exit report for smbd is now:

talloc report on 'null_context' (total 811 bytes in 54 blocks)
        auth/auth_sam.c:334            contains     20 bytes in   1 blocks
        struct auth_serversupplied_info contains    498 bytes in  33 blocks
        UNNAMED                        contains      8 bytes in   1 blocks
        lib/data_blob.c:40             contains     16 bytes in   1 blocks
        iconv(CP850,UTF8)              contains     61 bytes in   4 blocks
        iconv(UTF8,CP850)              contains     61 bytes in   4 blocks
        iconv(UTF8,UTF-16LE)           contains     67 bytes in   4 blocks
        iconv(UTF-16LE,UTF8)           contains     67 bytes in   4 blocks
        UNNAMED                        contains     13 bytes in   1 blocks

which is much better than before
2007-10-10 12:59:16 -05:00
Andrew Tridgell
bd86ebe297 r2641: talloc_p() now produces a named talloc pointer, with the name
auto-derived from the type you are allocating. This is done with
basically zero overhead by relying on the stringify operator in cpp
producing string constants.

the result is that --leak-check nicely names all pointers that come
from talloc_p()
2007-10-10 12:59:15 -05:00
Andrew Tridgell
fec3288ad6 r2632: a new approach to handling const errors. We have had huge numbers of
const warnings for a long time, and no real way to approach a
solution. Some of them are unavoidable due to the way the C standard
works (for example, any function that provides strchr() like
functionality _must_ produce a const warning)

I will be converting a bunch of places that currently produce const
warnings to use the discard_const_p(). Some of these will be
unavoidable const problems, some of them will be ones we will fix up
over time. At least this change means we will no longer be swamped
with const warnings, and we will easily be able to see when new
problems emerge.
2007-10-10 12:59:14 -05:00
Andrew Tridgell
3f7741f178 r2618: before we had refererence counts in talloc I added a hack in the
server side request structure to prevent a structing being freed in
some circumstances. This change replaces this with the much more
robust mechanism of talloc_increase_ref_count().
2007-10-10 12:59:12 -05:00
Tim Potter
daad76207d r2582: Merge checks for xattr and acl libraries from Samba3 so the {get,set}ntacl
programs can build on non-xattr machines.
2007-10-10 12:59:07 -05:00
Andrew Tridgell
4e4859c06b r2520: - finished implementing the server side of the old style search requests 2007-10-10 12:59:01 -05:00
Jelmer Vernooij
2762ed3b9b r2518: Some long overdue changes:
- Samba4-style code in lib/registry (struct registry_key instead of REG_KEY, etc)
 - Use hives (like Windows has drives) instead of one root key (like a Unix FS)
 - usability fixes in the GTK utilities (autodetect the username,
	enable/disable options, etc)
 - fix gwsam compile
 - several bugfixes in the registry rpc code
 - do charset conversion in nt4 registry backend
2007-10-10 12:59:01 -05:00
Jelmer Vernooij
7c31998da1 r2510: Make C++ compilers happy, use ifdef instead of if 2007-10-10 12:59:00 -05:00
Andrew Tridgell
71480271ad r2469: complete overhaul of the old-style RAW_SEARCH_ calls (the OS/2 and
original core level calls). The old code was completely wrong in many respects.

also fixed the EA_SIZE level in the server

extended the RAW-SEARCH test suite to test the new code properly
2007-10-10 12:58:56 -05:00
Andrew Tridgell
3bf55c9e11 r2459: added STATUS_NO_MORE_FILES nt status code 2007-10-10 12:58:55 -05:00
Andrew Tridgell
ea7eac5e3f r2456: got rid of some outdated global macros 2007-10-10 12:58:55 -05:00
Andrew Tridgell
5fcad57128 r2434: separate "attrib" and "ex_attrib" elements for DOS attributes is pointless 2007-10-10 12:58:52 -05:00
Andrew Tridgell
40d5cae5eb r2404: the first large lump of posix vfs stuff.
this is still very much a skeleton (with many limbs missing too!). I
am committing this early to get some feedback on the approach taken.
2007-10-10 12:58:48 -05:00
Andrew Tridgell
1de5aa5b1d r2386: fixed some indentation 2007-10-10 12:58:47 -05:00
Stefan Metzmacher
de4447d7a5 r2328: add the start of a new system and protocol
independent socket library.

this is not used, but compiled currently

there're maybe some api changes later...

metze
2007-10-10 12:58:44 -05:00
Stefan Metzmacher
5387bc423d r2321: add complately untested LDAP server start
based on volker's patch

this is compiled by default but not started by default

metze
2007-10-10 12:58:43 -05:00
Andrew Tridgell
9c7100e3c7 r2242: some older versions of gcc don't properly handle the
PRINTF_ATTRIBUTE() format checking magic, so only enable it for gcc
versions >= 3.0
2007-10-10 12:58:34 -05:00
Andrew Tridgell
756f28ac95 r2159: converted samba4 over to UTF-16.
I had previously thought this was unnecessary, as windows doesn't use
standards compliant UTF-16, and for filesystem operations treats bytes
as UCS-2, but Bjoern Jacke has pointed out to me that this means we
don't correctly store extended UTF-16 characters as UTF-8 on
disk. This can be seen with (for example) the gothic characters with
codepoints above 64k.

This commit also adds a LOCAL-ICONV torture test that tests the first
1 million codepoints against the system iconv library, and tests 5
million random UTF-16LE buffers for identical error handling to the
system iconv library.

the lib/iconv.c changes need backporting to samba3
2007-10-10 12:58:27 -05:00
Andrew Tridgell
957b260621 r2039: got rid of the free() ptr in DATA_BLOB
I plan on replacing the concept by adding a generic destructor in all talloc ptrs, so you can do:

  talloc_set_destructor(ptr, my_destructor);

to setup a function that will be called on free.
2007-10-10 12:58:19 -05:00
Stefan Metzmacher
71992c90cc r2005: fix compiler warnings
metze
2007-10-10 12:58:17 -05:00
Andrew Tridgell
6ffdfd7799 r1985: take advantage of the new talloc in a few more places 2007-10-10 12:58:14 -05:00
Andrew Tridgell
03c341aca7 r1984: this change is what you should read to understand the new talloc()
It simplifies our structure handling a lot, making the code shorter
and easier to understand. Look at the diff carefully and see if you
can understand it. If you're still confused then please ask.
2007-10-10 12:58:14 -05:00
Andrew Tridgell
e35bb094c5 r1983: a completely new implementation of talloc
This version does the following:

  1) talloc_free(), talloc_realloc() and talloc_steal() lose their
     (redundent) first arguments

  2) you can use _any_ talloc pointer as a talloc context to allocate
     more memory. This allows you to create complex data structures
     where the top level structure is the logical parent of the next
     level down, and those are the parents of the level below
     that. Then destroy either the lot with a single talloc_free() or
     destroy any sub-part with a talloc_free() of that part

  3) you can name any pointer. Use talloc_named() which is just like
     talloc() but takes the printf style name argument as well as the
     parent context and the size.

The whole thing ends up being a very simple piece of code, although
some of the pointer walking gets hairy.

So far, I'm just using the new talloc() like the old one. The next
step is to actually take advantage of the new interface
properly. Expect some new commits soon that simplify some common
coding styles in samba4 by using the new talloc().
2007-10-10 12:58:14 -05:00
Stefan Metzmacher
ecf6be894f r1912: move popt_common.h
metze
2007-10-10 12:58:10 -05:00
Stefan Metzmacher
1fc0100e44 r1911: merge a few popt parameters from 3.0 move some to better places
and deal with users DOMAIN and lp_workgroup() of the local workstation

metze
2007-10-10 12:58:10 -05:00
Stefan Metzmacher
64d61ef4a5 r1903: hmm a better solution is to include popt.h where it is needed
metze
2007-10-10 12:58:10 -05:00
Stefan Metzmacher
edde7497e9 r1902: we need to include popt.h before popt_common.h
metze
2007-10-10 12:58:09 -05:00
Andrew Tridgell
e50fc00671 r1895: added a note about OPEN_BY_FILE_ID to the ntcreatex interface definition 2007-10-10 12:58:09 -05:00