1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-09 09:57:48 +03:00

1976 Commits

Author SHA1 Message Date
Jelmer Vernooij
4668384717 r2683: Fix a couple of compile warnings, depend on gtk+-2.4 2007-10-10 12:59:21 -05:00
Stefan Metzmacher
740347255b r2682: as sambdb holds all search data, don't double free the data
metze
2007-10-10 12:59:21 -05:00
Stefan Metzmacher
67bb491725 r2681: commit the first semi working search implementation
which exports data from a ldb.

I commit this code, so that someone can help me to find a strange
bug

metze
2007-10-10 12:59:21 -05:00
Andrew Tridgell
c82a9cf750 r2680: switched the libcli/raw/ code over to use talloc_reference(), which simplifies things quite a bit 2007-10-10 12:59:21 -05:00
Andrew Tridgell
9087fab0ad r2679: fixed an uninitialised variable found with valgrind 2007-10-10 12:59:21 -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
a87d3d1134 r2677: - fixed a bug in the recursive logic talloc_free() when there are
circular references (circular references are allowed, they just need
  to be handled carefully inside talloc)

- mark talloc_reference() pointers nicely in the --leak-report-full
  code, so you see what has a reference to what in a useful manner
2007-10-10 12:59:21 -05:00
Andrew Tridgell
f31e5d56e3 r2676: add a test of the reference counting logic in the SAMR server into the
RPC-SAMR torture test. This closes the samr connection before working
on a open domain handle. The server is supposed to know that the open
domain handle still holds a reference to the connection, so the
connection remains valid even though it has been closed.
2007-10-10 12:59:20 -05:00
Andrew Tridgell
dc53150861 r2675: added a convenience function
void *talloc_reference(const void *context, const void *ptr);

this function makes a secondary reference to ptr, and hangs it off the
given context. This greatly simplifies some of the current reference
counting code in the samr server and I suspect it will be widely used
in other places too.

the way you use it is like this:

	domain_state->connect_state = talloc_reference(domain_state, connect_state);

that makes the element connect_state of domain_state a secondary
reference to connect_state. The connect_state structure will then only
be freed when both domain_state and the original connect_state go
away, allowing you to free them independently and in any order.

you could do this alrady using a talloc destructor, and that is what
the samr server did previously, but that meant this construct was
being reinvented in several places. So this convenience function sets
up the destructor for you, giving a much more convenient and less
error prone API.
2007-10-10 12:59:20 -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
c51ca7c0e7 r2673: in the rpc server, free up the old call when we decide to extend an
existing call rather than creating a new one. This prevents call
structures hanging around on the rpc connection context until it is
closed
2007-10-10 12:59:20 -05:00
Andrew Tridgell
015db2ed8c r2672: don't call a variable "dup" as that conflicts with a standard system call name 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
d78eea9eb8 r2670: use a destructor to auto-close the samr ldb when the last user
disconnects. Previously the ldb was always kept open.
2007-10-10 12:59:20 -05:00
Andrew Tridgell
278cef77f0 r2669: convert make_user_info() and associated functions from malloc to talloc 2007-10-10 12:59:19 -05:00
Andrew Tridgell
417d0c0ba1 r2668: steal the cli pointer into the pipe context so a single free destroys the cli context too 2007-10-10 12:59:19 -05:00
Jelmer Vernooij
8768168aad r2667: Remove forward declaration of static function from function. GCC 3.5 and 4.0 don't accept declarations of static functions inside other
functions, see http://gcc.gnu.org/ml/gcc-patches/2004-08/msg02514.html
2007-10-10 12:59:19 -05:00
Andrew Tridgell
1ff41bbcae r2664: fixed the final server leak for normal operation. We now get a clean report from --leak-check 2007-10-10 12:59:19 -05:00
Andrew Tridgell
2662be3a2b r2663: fix an epmapper server leak - another talloc_realloc(NULL, ) leak 2007-10-10 12:59:19 -05:00
Andrew Tridgell
0051820175 r2662: make --leak-check completely silent if not blocks are allocated 2007-10-10 12:59:19 -05:00
Andrew Tridgell
bd813dfb1b r2661: fixed a client side memory leak in the clilist code.
This sort of bug happens quite easily with the new talloc_realloc()
interface. talloc_realloc() now looks like this:

  void *talloc_realloc(void *ptr, size_t size);

and if ptr is not NULL then everything is fine. If ptr is NULL then
talloc_realloc() presumes you want to allocate in the NULL context,
which is probably not what is wanted.

For now the solution is to initialise ptr like this:
  ptr = talloc(mem_ctx, 0);
so when the realloc happens it has a context to get hold of.

I might change the interface of talloc_realloc() later to prevent this
problem in a more robust manner
2007-10-10 12:59:18 -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
770aa7e01e r2659: removed some extraneous debug msgs 2007-10-10 12:59:17 -05:00
Andrew Tridgell
18632ec565 r2658: fixed a couple of error codes found with RAW-CONTEXT 2007-10-10 12:59:17 -05:00
Andrew Tridgell
50d5c638a3 r2657: if we are already fully authenticated in session setup then the vuid is ignored 2007-10-10 12:59:17 -05:00
Andrew Tridgell
46b790c19d r2656: moved the seteuid configure tests into the posix backend (these tests
don't actually work yet, that will come later)
2007-10-10 12:59:17 -05:00
Andrew Tridgell
d5fd638875 r2655: fixed an error in the shutdown of the sock->transport->session->tree
smbcli raw context handling
2007-10-10 12:59:17 -05:00
Andrew Tridgell
2f1b788e09 r2654: fixed some more server memory leaks. We are now down to a single leak
of 16 bytes, caused by the 16 byte data_blob in the smb_signing
code.
2007-10-10 12:59:17 -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
4aba6e7101 r2650: fixed a memory leak in make_server_info() 2007-10-10 12:59:16 -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
230e1cd777 r2648: - use a destructor on struct server_connection to simplify the
connection termination cleanup, and to ensure that the event
  contexts are properly removed for every process model

- gave auth_context the new talloc treatment, which removes another
  source of memory leaks.
2007-10-10 12:59:16 -05:00
Andrew Tridgell
2dc334a328 r2646: - use a talloc destructor to ensure that sockets from the new socket
library are closed on abnormal termination

- convert the service.h structures to the new talloc methods
2007-10-10 12:59:16 -05:00
Andrew Tridgell
b378aae95d r2645: converted the NTLMSSP code to the new style of talloc 2007-10-10 12:59:16 -05:00
Andrew Tridgell
bc779cb2ce r2644: removed an unused function 2007-10-10 12:59:16 -05:00
Andrew Tridgell
f19201ea27 r2643: convert more of the auth subsyystem to the new talloc methods. This
also fixes a memory leak found with --leak-check.
2007-10-10 12:59:15 -05:00
Andrew Tridgell
28dcd22029 r2642: smb_iconv_t is a pointer, so checks against -1 errors should use a cast 2007-10-10 12:59:15 -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
96d33d36a5 r2640: valgrind does a great job on some types of memory leaks, but is slow
and can't properly handle leaks of doubly linked lists which we use a
lot (as the memory is always reachable). Even with --show-reachable
its hard to track leaks down sometimes.

I realised that talloc does have the necessary information to track
these, and by using the cascading property of the new talloc it can
report on leaks in a much more succinct fashion than valgrind can.

I have added a new samba option --leak-check that applies to all Samba
tools. When enabled it prints a leak report summarising all top level
contexts that are present when the program exits. A typical report
looks like this:

talloc report on 'null_context' (total 1071 bytes in 52 blocks)
        iconv(CP850,UTF8)              contains     43 bytes in   3 blocks
        UNNAMED                        contains     24 bytes in   1 blocks
        UNNAMED                        contains     24 bytes in   1 blocks
        dcesrv_init                    contains    604 bytes in  26 blocks
        server_service                 contains    120 bytes in   6 blocks
        UNNAMED                        contains     24 bytes in   1 blocks
        UNNAMED                        contains     24 bytes in   1 blocks
        server_service                 contains    104 bytes in   4 blocks
        server_context                 contains     12 bytes in   2 blocks
        iconv(UTF8,UTF-16LE)           contains     46 bytes in   3 blocks
        iconv(UTF-16LE,UTF8)           contains     46 bytes in   3 blocks

the numbers are recursive summaries for all the memory hanging off each context.

this option is not thread safe when used, but the code is thread safe
if the option is not given, so I don't think thats a problem.
2007-10-10 12:59:15 -05:00
Andrew Tridgell
480636ebbc r2639: we doon't need the valid_table code, so get rid of it 2007-10-10 12:59:15 -05:00
Andrew Tridgell
60e8d154fd r2638: do lazy initialisation of iconv handles, so we don't initialise a
handle unless we use it. This saves quite a bit of memory (libc chews
a lot loading a handle). Typically smbd now loads 3 handles, instead
of 36.
2007-10-10 12:59:15 -05:00
Andrew Tridgell
1ee5ed4197 r2635: mem_ctx cleanups on the lsa and netlogon pipes in the rpc server 2007-10-10 12:59:15 -05:00
Andrew Tridgell
56ecda2178 r2634: use discard_const_p() in a few places 2007-10-10 12:59:14 -05:00
Andrew Tridgell
e9803058ec r2633: fixed some function types in the (unused) print backend 2007-10-10 12:59:14 -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
2a7e5f0708 r2631: the strchr family of functions should not return const strings. 2007-10-10 12:59:14 -05:00
Andrew Tridgell
7124949140 r2630: I missed a couple of places in the gensec talloc conversion 2007-10-10 12:59:14 -05:00
Andrew Tridgell
f12ee2f241 r2629: convert gensec to the new talloc model
by making our gensec structures a talloc child of the open connection
we can be sure that it will be destroyed when the connection is
dropped.
2007-10-10 12:59:14 -05:00
Andrew Tridgell
26da45a801 r2628: got rid of some warnings and converted a few more places to use hierarchical memory allocation 2007-10-10 12:59:14 -05:00
Andrew Tridgell
76d0b8206c r2627: use the new talloc capabilities in a bunch more places in the rpc
server code. This fixes a number of memory leaks I found when testing
with valgrind and smbtorture, as the cascading effect of a
talloc_free() ensures that anything derived from the top level object
is destroyed on disconnect.
2007-10-10 12:59:13 -05:00