13 years agor2743: fixed some errors in the description of talloc_reference(). Volker
Andrew Tridgell [Tue, 28 Sep 2004 23:31:52 +0000 (23:31 +0000)]
r2743: fixed some errors in the description of talloc_reference(). Volker
told me he found the description confusing, and given that some of it
was not correct I am not surprised!

added some more docs on the reporting calls
(This used to be commit 43079cfc80317b6d0d2679f9377aac259e0f8fc7)

13 years agor2742: - fixed a bug in talloc_unreference()
Andrew Tridgell [Tue, 28 Sep 2004 23:30:14 +0000 (23:30 +0000)]
r2742: - fixed a bug in talloc_unreference()

- made the LOCAL-TALLOC smbtorture test much stricter, checking that
  block counts for every pointer are correct after every operation
(This used to be commit 18d3e2647f0bedbba699d1ba2649c0cfe4526ef6)

13 years agor2741: Definition for ISystemActivator...
Jelmer Vernooij [Tue, 28 Sep 2004 22:58:56 +0000 (22:58 +0000)]
r2741: Definition for ISystemActivator...
(This used to be commit 0bb42ba898a0d02c98bbefcfe5b9e42409658609)

13 years agor2740: Finish the RemoteActivation interface. Torture tests will follow
Jelmer Vernooij [Tue, 28 Sep 2004 22:04:35 +0000 (22:04 +0000)]
r2740: Finish the RemoteActivation interface. Torture tests will follow
after pidl has been fixed (to be able to use input variables
inside size_is() for output variables)
(This used to be commit ea0b0bfea97067118dab634efefd3115b7a0fd85)

13 years agor2739: Start of torture test for winreg wrappers.
Tim Potter [Tue, 28 Sep 2004 21:44:05 +0000 (21:44 +0000)]
r2739: Start of torture test for winreg wrappers.
(This used to be commit cf9b984b8457843d2b6bb1c4ac90d52c9b802d89)

13 years agor2738: free up the session information as soon as it is invalidated in the
Andrew Tridgell [Tue, 28 Sep 2004 21:42:49 +0000 (21:42 +0000)]
r2738: free up the session information as soon as it is invalidated in the
RAW-CONTEXT test case
(This used to be commit f4a7a3282af6c6ff771547d2efdbba0fe0451b3e)

13 years agor2737: fixed up a corner case where talloc_unreference() and talloc_free()
Andrew Tridgell [Tue, 28 Sep 2004 21:41:33 +0000 (21:41 +0000)]
r2737: fixed up a corner case where talloc_unreference() and talloc_free()
might not place the pointer in the context specified in the docs. The
code was assuming that pointer was at the head of the child list,
which it may not be, depending on what other operations have happened
in between.
(This used to be commit e62bd7ef7ec80365ab00ce5b2051b7dc1726304b)

13 years agor2735: More DCOM updates:
Jelmer Vernooij [Tue, 28 Sep 2004 19:20:00 +0000 (19:20 +0000)]
r2735: More DCOM updates:
 - Several updates to the interface definitions after reading some more of the
  - Add Remote Activation interface
  - Add body extension uuids
 - Add oxidresolve torture test to list
 - Make pidl complain about object interfaces that don't inherit from IUnknown
(This used to be commit 1bb471832830d73f0c7290e2ec12878518598379)

13 years agor2734: the samdb_destructor can be static
Andrew Tridgell [Tue, 28 Sep 2004 14:38:13 +0000 (14:38 +0000)]
r2734: the samdb_destructor can be static
(This used to be commit feb63e74f923f2a50c6836e18a6c2bda39644e71)

13 years agor2733: added a note on performance
Andrew Tridgell [Tue, 28 Sep 2004 14:37:28 +0000 (14:37 +0000)]
r2733: added a note on performance
(This used to be commit 171fe8209794bb1e61283126ccc165b43fbcfa62)

13 years agor2731: use debug level 10 everywhere
Stefan Metzmacher [Tue, 28 Sep 2004 13:50:15 +0000 (13:50 +0000)]
r2731: use debug level 10 everywhere

(This used to be commit a0e4dca3dab1da02edc09fd5f80690ec0b764c17)

13 years agor2728: Break arg parsing stuff out of into a standalone program.
Tim Potter [Tue, 28 Sep 2004 12:49:05 +0000 (12:49 +0000)]
r2728: Break arg parsing stuff out of into a standalone program.
(This used to be commit 799b377badebf9a3f388b7d3fdc36484aa5e3376)

13 years agor2727: mark the password fields as hidden
Stefan Metzmacher [Tue, 28 Sep 2004 12:42:03 +0000 (12:42 +0000)]
r2727: mark the password fields as hidden

(This used to be commit 7ff118ecc90dd9cc9a5d1870e93fc5792bf66903)

13 years agor2726: added a -r option to ldbdel to allow easy delete of a whole
Andrew Tridgell [Tue, 28 Sep 2004 12:39:41 +0000 (12:39 +0000)]
r2726: added a -r option to ldbdel to allow easy delete of a whole
subtree. Useful when cleaning up a mess after testing.
(This used to be commit 476674af5519960300c0a07349c7cdf307af3822)

13 years agor2725: fixed ldbtest to give the basedn to ldb_search()
Andrew Tridgell [Tue, 28 Sep 2004 12:38:59 +0000 (12:38 +0000)]
r2725: fixed ldbtest to give the basedn to ldb_search()
(This used to be commit 19925f5bd8dd24742e5d216b0c491975ceb7d3a6)

13 years agor2724: - use ldapsrv_service and set it up with the rootDSE and default partition
Stefan Metzmacher [Tue, 28 Sep 2004 12:36:20 +0000 (12:36 +0000)]
r2724: - use ldapsrv_service and set it up with the rootDSE and default partition
  (this is not complete yet)

- call asn1_free() after each call

(This used to be commit 0aa622bdc497e4ae1a23bd47ad9d9bf2757c8fd5)

13 years agor2723: fix some debug messages
Stefan Metzmacher [Tue, 28 Sep 2004 12:30:42 +0000 (12:30 +0000)]
r2723: fix some debug messages

(This used to be commit 9600c1a2c7789ebfb0a06cf21772cdacab0fb356)

13 years agor2722: remove tmp debug messages
Stefan Metzmacher [Tue, 28 Sep 2004 12:17:03 +0000 (12:17 +0000)]
r2722: remove tmp debug messages

(This used to be commit 60dcba3e91cedca78d2eb7e01bc04790739a4aad)

13 years agor2721: added a -b option to ldbtest so it can be used with the new smbd ldap server
Andrew Tridgell [Tue, 28 Sep 2004 12:06:22 +0000 (12:06 +0000)]
r2721: added a -b option to ldbtest so it can be used with the new smbd ldap server
without changing realms
(This used to be commit fd2725f5c0a2ea89bbfcb0403d1bc03fa7b7ec25)

13 years agor2720: -implement sldb_Modify() call
Stefan Metzmacher [Tue, 28 Sep 2004 11:57:56 +0000 (11:57 +0000)]
r2720: -implement sldb_Modify() call

(This used to be commit e74d3895f01369606254250f77376ae6ba3682ac)

13 years agor2719: an additional note on talloc_unreference()
Andrew Tridgell [Tue, 28 Sep 2004 11:57:40 +0000 (11:57 +0000)]
r2719: an additional note on talloc_unreference()
(This used to be commit 078d13181313f98c1df50185ebae4629cca98ee0)

13 years agor2718: - added a talloc_unreference() function as requested by metze.
Andrew Tridgell [Tue, 28 Sep 2004 11:54:17 +0000 (11:54 +0000)]
r2718: - added a talloc_unreference() function as requested by metze.

- added documentation for talloc_unreference()

- made the abandoned child logic in talloc_free() clearer and more consistent
(This used to be commit a87584c8e3fb06cd3ff29a918f681b5c6c32b9ff)

13 years agor2717: added talloc_p() docs
Andrew Tridgell [Tue, 28 Sep 2004 11:08:43 +0000 (11:08 +0000)]
r2717: added talloc_p() docs
(This used to be commit 6743ca1b1a24776559aa1c04f0f4a33c67cea8a7)

13 years agor2716: created a separate detailed talloc_guide.txt document, after volker
Andrew Tridgell [Tue, 28 Sep 2004 11:04:55 +0000 (11:04 +0000)]
r2716: created a separate detailed talloc_guide.txt document, after volker
complained it was all too confusing :-)

I recommend that everyone who wants to work on Samba4 have a read of this.
(This used to be commit c4c427576c02b27d829ae4aaee31cbf893b4a2ad)

13 years agor2714: - add sldb_Add() implementation
Stefan Metzmacher [Tue, 28 Sep 2004 10:44:44 +0000 (10:44 +0000)]
r2714: - add sldb_Add() implementation
- fix some errstr settings

(This used to be commit 7419c6dabbe09b4a5628fc36c7636a1763e4876f)

13 years agor2713: better handling of binary values in index key creation
Andrew Tridgell [Tue, 28 Sep 2004 09:34:49 +0000 (09:34 +0000)]
r2713: better handling of binary values in index key creation
(This used to be commit b0c92616fb69d8139f66dc8144cfcc88ea6825dc)

13 years agor2712: fixed a bug in ldbtest to make it cope with an existing index
Andrew Tridgell [Tue, 28 Sep 2004 08:17:20 +0000 (08:17 +0000)]
r2712: fixed a bug in ldbtest to make it cope with an existing index
(This used to be commit 3f776a9b5c240312f161b651201458e43a9dd6a9)

13 years agor2711: added a simple talloc speed tester. I get the following on my laptop:
Andrew Tridgell [Tue, 28 Sep 2004 06:12:07 +0000 (06:12 +0000)]
r2711: added a simple talloc speed tester. I get the following on my laptop:

  talloc: 279154 ops/sec
  malloc: 318758 ops/sec

which I think is an acceptable overhead for the increased functionality
(This used to be commit 91669ea830c16db2730c5e43a7cad26d9db5c585)

13 years agor2710: continue with the new style of providing a parent context whenever
Andrew Tridgell [Tue, 28 Sep 2004 05:44:59 +0000 (05:44 +0000)]
r2710: continue with the new style of providing a parent context whenever
possible to a structure creation routine. This makes for much easier
global cleanup.
(This used to be commit e14ee428ec357fab76a960387a9820a673786e27)

13 years agor2709: finally solved the talloc reference problem.
Andrew Tridgell [Tue, 28 Sep 2004 05:42:02 +0000 (05:42 +0000)]
r2709: finally solved the talloc reference problem.

The problem was that the simple "uint_t ref_count;" in a talloc chunk
did not give enough information. It told us that a pointer was
referenced more than once, but it didn't say who it was referenced
by. This means that when the pointer was freed we had no sane way to
clean up the reference.

I have now replaced ref_count with a "refs" list, which means that
references point to the pointer, and the pointer has a linked list of
references. So now we can cleanup from either direction without losing track of anything.

I've also added a LOCAL-TALLOC smbtorture test that tests talloc
behaviour for some common uses.
(This used to be commit 911a8d590cb184bcb892810729955c2c4cf02550)

13 years agor2705: Don't try RemQueryInterface2 for now (doesn't validate)
Jelmer Vernooij [Tue, 28 Sep 2004 01:12:55 +0000 (01:12 +0000)]
r2705: Don't try RemQueryInterface2 for now (doesn't validate)
(This used to be commit b2f4532e906e1a5bf134812072aad211ba2d01bb)

13 years agor2704: Complain about 'object interfaces' that don't have version 0.0 (the standard
Jelmer Vernooij [Tue, 28 Sep 2004 01:11:40 +0000 (01:11 +0000)]
r2704: Complain about 'object interfaces' that don't have version 0.0 (the standard
doesn't allow them to! I think the idea is that you just create a new
interface that inherits your old interface, thus ensuring backwards-compatibility)
Re-enable to validator
(This used to be commit e364e46a88e5a222c94cdb9cf8e7a124e43f0bcf)

13 years agor2699: Correct handle ServerAlive() and ServerAlive2() + add torture tests
Jelmer Vernooij [Mon, 27 Sep 2004 22:06:27 +0000 (22:06 +0000)]
r2699: Correct handle ServerAlive() and ServerAlive2() + add torture tests
(This used to be commit 9e74144aa8e5f9a8b6e3d5293833c4afeebeddb0)

13 years agor2696: DCOM updates:
Jelmer Vernooij [Mon, 27 Sep 2004 16:37:41 +0000 (16:37 +0000)]
r2696: DCOM updates:
 - Start working on OXIDResolver interface
 - Add torture test for SimplePing()
(This used to be commit b54d14a01a71082251ff926ab57974c6eb3c0a41)

13 years agor2695: revert "Del" renaming
Simo Sorce [Mon, 27 Sep 2004 15:40:12 +0000 (15:40 +0000)]
r2695: revert "Del" renaming
(This used to be commit ddd74dae8efe4e04b5a56ee9ecd9d4f87f99d104)

13 years agor2694: DN -> DC these are domain components ...
Simo Sorce [Mon, 27 Sep 2004 15:37:43 +0000 (15:37 +0000)]
r2694: DN -> DC these are domain components ...
(This used to be commit 35135033ffbae42a3a946ea30ba46f6ed9b12898)

13 years agor2693: - send a reply when no attributes there
Stefan Metzmacher [Mon, 27 Sep 2004 15:11:42 +0000 (15:11 +0000)]
r2693: - send a reply when no attributes there
- add some debug messages

(This used to be commit 1de1beca66da68e5af0869629d2c50016c25e776)

13 years agor2690: deleted by mistake
Simo Sorce [Mon, 27 Sep 2004 14:18:25 +0000 (14:18 +0000)]
r2690: deleted by mistake
(This used to be commit 3d587a7141908362657afc2dfd0c78d73a5fed07)

13 years agor2689: Use consistent naming Del -> Delete
Simo Sorce [Mon, 27 Sep 2004 14:11:11 +0000 (14:11 +0000)]
r2689: Use consistent naming Del -> Delete
Add delete functionality to ldb simple lda server backend
add some const in ldap.h
(This used to be commit 5ed9a6eb184f34eb572dd81202237042518ec7cd)

13 years agor2688: - fix case where listed attributes are asked
Stefan Metzmacher [Mon, 27 Sep 2004 13:20:59 +0000 (13:20 +0000)]
r2688: - fix case where listed attributes are asked
- use the return code of the functions
  and only call ldapsrv_terminate_connection from ldapsrv_recv() or ldapsrv_send()
- the rootdse is now a normal partition

(This used to be commit af1501a28d700f90cd2243fbfdce6527a0f62961)

13 years agor2687: Add ORPC flag (used by DCOM)
Jelmer Vernooij [Mon, 27 Sep 2004 12:57:59 +0000 (12:57 +0000)]
r2687: Add ORPC flag (used by DCOM)
(This used to be commit b7ac0cb692ea373f754d7a40b44a7b0756459287)

13 years agor2686: remove unused gtk+ check
Stefan Metzmacher [Mon, 27 Sep 2004 11:38:36 +0000 (11:38 +0000)]
r2686: remove unused gtk+ check

(This used to be commit d1e8b340a9942553ec7f281affd11ea4315ac448)

13 years agor2685: ALLOC_CHECK() after talloc_steal() isn't needed
Stefan Metzmacher [Mon, 27 Sep 2004 10:14:24 +0000 (10:14 +0000)]
r2685: ALLOC_CHECK() after talloc_steal() isn't needed
(thanks simo:-)

(This used to be commit e62cd75d3786f3d638ac2a27d6e864c826eaa48f)

13 years agor2684: Free the right talloc context (don't panic when encountering illegal multibyte
Jelmer Vernooij [Mon, 27 Sep 2004 10:13:41 +0000 (10:13 +0000)]
r2684: Free the right talloc context (don't panic when encountering illegal multibyte
(This used to be commit b90da2337b83eb261a8072f9d0b13ec28caf3c4d)

13 years agor2683: Fix a couple of compile warnings, depend on gtk+-2.4
Jelmer Vernooij [Mon, 27 Sep 2004 09:26:37 +0000 (09:26 +0000)]
r2683: Fix a couple of compile warnings, depend on gtk+-2.4
(This used to be commit 4668384717eda878583477b8f455809056885120)

13 years agor2682: as sambdb holds all search data, don't double free the data
Stefan Metzmacher [Mon, 27 Sep 2004 09:21:52 +0000 (09:21 +0000)]
r2682: as sambdb holds all search data, don't double free the data

(This used to be commit 740347255b8f1aafda1ebd10d63fdde1c4041af0)

13 years agor2681: commit the first semi working search implementation
Stefan Metzmacher [Mon, 27 Sep 2004 08:52:31 +0000 (08:52 +0000)]
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

(This used to be commit 67bb49172567af9d106ded55c1257b808d2a97ff)

13 years agor2680: switched the libcli/raw/ code over to use talloc_reference(), which simplifies...
Andrew Tridgell [Mon, 27 Sep 2004 08:41:39 +0000 (08:41 +0000)]
r2680: switched the libcli/raw/ code over to use talloc_reference(), which simplifies things quite a bit
(This used to be commit c82a9cf750829c4f6982ca3133295c8599023c4e)

13 years agor2679: fixed an uninitialised variable found with valgrind
Andrew Tridgell [Mon, 27 Sep 2004 08:39:51 +0000 (08:39 +0000)]
r2679: fixed an uninitialised variable found with valgrind
(This used to be commit 9087fab0adcf1791caeb795509ca9f14f5f47e82)

13 years agor2678: from_name and to_name aren't needed in smb_iconv_t
Andrew Tridgell [Mon, 27 Sep 2004 08:39:06 +0000 (08:39 +0000)]
r2678: from_name and to_name aren't needed in smb_iconv_t
(This used to be commit f3844cc0a5ad6b03f166435d44db02763df345d7)

13 years agor2677: - fixed a bug in the recursive logic talloc_free() when there are
Andrew Tridgell [Mon, 27 Sep 2004 08:38:13 +0000 (08:38 +0000)]
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
(This used to be commit a87d3d11344069284604a7294a54cadcc6e1a096)

13 years agor2676: add a test of the reference counting logic in the SAMR server into the
Andrew Tridgell [Mon, 27 Sep 2004 05:15:14 +0000 (05:15 +0000)]
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.
(This used to be commit f31e5d56e364ce8ab76fdb20b30e179b458b2ffa)

13 years agor2675: added a convenience function
Andrew Tridgell [Mon, 27 Sep 2004 05:13:00 +0000 (05:13 +0000)]
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.
(This used to be commit dc5315086156644fad093cbe6b02d999adba8540)

13 years agor2674: I have realised that talloc() should have its context marked const, as
Andrew Tridgell [Mon, 27 Sep 2004 04:20:18 +0000 (04:20 +0000)]
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

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.
(This used to be commit c60ff99c3129c26a9204bac1c6e5fb386114a923)

13 years agor2673: in the rpc server, free up the old call when we decide to extend an
Andrew Tridgell [Mon, 27 Sep 2004 04:11:37 +0000 (04:11 +0000)]
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
(This used to be commit c51ca7c0e73b97435c245cd440a4fb979cf6a4f3)

13 years agor2672: don't call a variable "dup" as that conflicts with a standard system call...
Andrew Tridgell [Mon, 27 Sep 2004 04:00:23 +0000 (04:00 +0000)]
r2672: don't call a variable "dup" as that conflicts with a standard system call name
(This used to be commit 015db2ed8cdde6d6eb79857cb9b6d72185382acc)

13 years agor2671: we're getting too many errors caused by the talloc_realloc() API not
Andrew Tridgell [Mon, 27 Sep 2004 01:36:19 +0000 (01:36 +0000)]
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
(This used to be commit 8dc23821c9f54b2f13049b5e608a0cafb81aa540)

13 years agor2670: use a destructor to auto-close the samr ldb when the last user
Andrew Tridgell [Mon, 27 Sep 2004 00:48:01 +0000 (00:48 +0000)]
r2670: use a destructor to auto-close the samr ldb when the last user
disconnects. Previously the ldb was always kept open.
(This used to be commit d78eea9eb8540f137d30aef5fbb397295312eb1b)

13 years agor2669: convert make_user_info() and associated functions from malloc to talloc
Andrew Tridgell [Sun, 26 Sep 2004 23:39:18 +0000 (23:39 +0000)]
r2669: convert make_user_info() and associated functions from malloc to talloc
(This used to be commit 278cef77f083c002d17ecbbe18c20825a380eda3)

13 years agor2668: steal the cli pointer into the pipe context so a single free destroys the...
Andrew Tridgell [Sun, 26 Sep 2004 23:38:14 +0000 (23:38 +0000)]
r2668: steal the cli pointer into the pipe context so a single free destroys the cli context too
(This used to be commit 417d0c0ba182aab3a3a23db76ff7ac7cbc663cb6)

13 years agor2667: Remove forward declaration of static function from function. GCC 3.5 and 4...
Jelmer Vernooij [Sun, 26 Sep 2004 22:19:48 +0000 (22:19 +0000)]
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
(This used to be commit 8768168aadf51b9559831954e349d9aa94101c41)

13 years agor2664: fixed the final server leak for normal operation. We now get a clean report...
Andrew Tridgell [Sun, 26 Sep 2004 12:51:49 +0000 (12:51 +0000)]
r2664: fixed the final server leak for normal operation. We now get a clean report from --leak-check
(This used to be commit 1ff41bbcae8dc7514a85d69679e44dc7c5b0342f)

13 years agor2663: fix an epmapper server leak - another talloc_realloc(NULL, ) leak
Andrew Tridgell [Sun, 26 Sep 2004 12:50:36 +0000 (12:50 +0000)]
r2663: fix an epmapper server leak - another talloc_realloc(NULL, ) leak
(This used to be commit 2662be3a2be04aa7f4dcfde3453389595bf43496)

13 years agor2662: make --leak-check completely silent if not blocks are allocated
Andrew Tridgell [Sun, 26 Sep 2004 12:48:06 +0000 (12:48 +0000)]
r2662: make --leak-check completely silent if not blocks are allocated
(This used to be commit 00518201754dc2de583267071ebd2adecbadcb59)

13 years agor2661: fixed a client side memory leak in the clilist code.
Andrew Tridgell [Sun, 26 Sep 2004 11:45:14 +0000 (11:45 +0000)]
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
(This used to be commit bd813dfb1b08b586dc71f9cec4eb65b35ea808fe)

13 years agor2660: - converted the libcli/raw/ library to use talloc_increase_ref_count()
Andrew Tridgell [Sun, 26 Sep 2004 11:30:20 +0000 (11:30 +0000)]
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
(This used to be commit c315d6ac1cc40546fde1474702a6d66d07ee13c8)

13 years agor2659: removed some extraneous debug msgs
Andrew Tridgell [Sun, 26 Sep 2004 11:27:01 +0000 (11:27 +0000)]
r2659: removed some extraneous debug msgs
(This used to be commit 770aa7e01e68df1fd8538c5b19b63a8545bb0355)

13 years agor2658: fixed a couple of error codes found with RAW-CONTEXT
Andrew Tridgell [Sun, 26 Sep 2004 11:25:33 +0000 (11:25 +0000)]
r2658: fixed a couple of error codes found with RAW-CONTEXT
(This used to be commit 18632ec56524f294655d881406c10beb659ddee1)

13 years agor2657: if we are already fully authenticated in session setup then the vuid is ignored
Andrew Tridgell [Sun, 26 Sep 2004 11:24:39 +0000 (11:24 +0000)]
r2657: if we are already fully authenticated in session setup then the vuid is ignored
(This used to be commit 50d5c638a3710855be67cd41dccc9658d64b70fd)

13 years agor2656: moved the seteuid configure tests into the posix backend (these tests
Andrew Tridgell [Sun, 26 Sep 2004 07:44:15 +0000 (07:44 +0000)]
r2656: moved the seteuid configure tests into the posix backend (these tests
don't actually work yet, that will come later)
(This used to be commit 46b790c19da25ba88d29f555f828688bb05e531d)

13 years agor2655: fixed an error in the shutdown of the sock->transport->session->tree
Andrew Tridgell [Sun, 26 Sep 2004 07:04:35 +0000 (07:04 +0000)]
r2655: fixed an error in the shutdown of the sock->transport->session->tree
smbcli raw context handling
(This used to be commit d5fd6388751944f11c34e5124d403d57c8670e3b)

13 years agor2654: fixed some more server memory leaks. We are now down to a single leak
Andrew Tridgell [Sun, 26 Sep 2004 06:44:08 +0000 (06:44 +0000)]
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
(This used to be commit 2f1b788e09686e065d22f621f5c0c585192c6740)

13 years agor2653: - data_blob() and data_blob_talloc() now get automatic names
Andrew Tridgell [Sun, 26 Sep 2004 06:41:59 +0000 (06:41 +0000)]
r2653: - data_blob() and data_blob_talloc() now get automatic names

- talloc_strdup() and related functions get automatic names
(This used to be commit 0cf427d14fe0a19cb3e85b6191be220f3d81080a)

13 years agor2650: fixed a memory leak in make_server_info()
Andrew Tridgell [Sun, 26 Sep 2004 05:38:45 +0000 (05:38 +0000)]
r2650: fixed a memory leak in make_server_info()
(This used to be commit 4aba6e7101041100f7d400abd5e7144b95528fc3)

13 years agor2649: - used some cpp tricks to make users of talloc() and talloc_realloc()
Andrew Tridgell [Sun, 26 Sep 2004 04:59:03 +0000 (04:59 +0000)]
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
(This used to be commit 6e721393d03afd3c2f8ced8422533547a9e33342)

13 years agor2648: - use a destructor on struct server_connection to simplify the
Andrew Tridgell [Sun, 26 Sep 2004 03:50:24 +0000 (03:50 +0000)]
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.
(This used to be commit 230e1cd777b0fba82dffcbd656cfa23c155d0560)

13 years agor2646: - use a talloc destructor to ensure that sockets from the new socket
Andrew Tridgell [Sun, 26 Sep 2004 03:05:04 +0000 (03:05 +0000)]
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
(This used to be commit 2dc334a3284858eb1c7190f9687c9b6c879ecc9d)

13 years agor2645: converted the NTLMSSP code to the new style of talloc
Andrew Tridgell [Sun, 26 Sep 2004 02:16:25 +0000 (02:16 +0000)]
r2645: converted the NTLMSSP code to the new style of talloc
(This used to be commit b378aae95d4001c4cf4e6e59ed80ee1bd55382ee)

13 years agor2644: removed an unused function
Andrew Tridgell [Sun, 26 Sep 2004 02:14:25 +0000 (02:14 +0000)]
r2644: removed an unused function
(This used to be commit bc779cb2ce6bc13157f9d046400ce99d107ccd52)

13 years agor2643: convert more of the auth subsyystem to the new talloc methods. This
Andrew Tridgell [Sun, 26 Sep 2004 01:43:05 +0000 (01:43 +0000)]
r2643: convert more of the auth subsyystem to the new talloc methods. This
also fixes a memory leak found with --leak-check.
(This used to be commit f19201ea274f0a542314c61c4af676197bf154ad)

13 years agor2642: smb_iconv_t is a pointer, so checks against -1 errors should use a cast
Andrew Tridgell [Sun, 26 Sep 2004 01:41:55 +0000 (01:41 +0000)]
r2642: smb_iconv_t is a pointer, so checks against -1 errors should use a cast
(This used to be commit 28dcd2202948b003f8d13951395baa4a722593f4)

13 years agor2641: talloc_p() now produces a named talloc pointer, with the name
Andrew Tridgell [Sun, 26 Sep 2004 01:41:04 +0000 (01:41 +0000)]
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()
(This used to be commit bd86ebe2972af4d424df20db1e422919aa6203d0)

13 years agor2640: valgrind does a great job on some types of memory leaks, but is slow
Andrew Tridgell [Sun, 26 Sep 2004 01:14:26 +0000 (01:14 +0000)]
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.
(This used to be commit 96d33d36a5639e7fc46b14a470ccac674d87c62a)

13 years agor2639: we doon't need the valid_table code, so get rid of it
Andrew Tridgell [Sun, 26 Sep 2004 01:09:04 +0000 (01:09 +0000)]
r2639: we doon't need the valid_table code, so get rid of it
(This used to be commit 480636ebbca102172621609496bdab682d4bda8a)

13 years agor2638: do lazy initialisation of iconv handles, so we don't initialise a
Andrew Tridgell [Sun, 26 Sep 2004 01:08:29 +0000 (01:08 +0000)]
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.
(This used to be commit 60e8d154fda548862cd6f8e8c1dadd64b3c4bd9c)

13 years agor2635: mem_ctx cleanups on the lsa and netlogon pipes in the rpc server
Andrew Tridgell [Sat, 25 Sep 2004 13:28:38 +0000 (13:28 +0000)]
r2635: mem_ctx cleanups on the lsa and netlogon pipes in the rpc server
(This used to be commit 1ee5ed4197f49f12372835f66160801f19ee35a6)

13 years agor2634: use discard_const_p() in a few places
Andrew Tridgell [Sat, 25 Sep 2004 12:48:56 +0000 (12:48 +0000)]
r2634: use discard_const_p() in a few places
(This used to be commit 56ecda2178e33508c55c6195ccec41c06e099d6f)

13 years agor2633: fixed some function types in the (unused) print backend
Andrew Tridgell [Sat, 25 Sep 2004 12:48:09 +0000 (12:48 +0000)]
r2633: fixed some function types in the (unused) print backend
(This used to be commit e9803058ecc0b0f849aee48a077bff4e2c8feaa5)

13 years agor2632: a new approach to handling const errors. We have had huge numbers of
Andrew Tridgell [Sat, 25 Sep 2004 12:36:36 +0000 (12:36 +0000)]
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.
(This used to be commit fec3288ad6ce58e8273e3f16e88037db49ecf046)

13 years agor2631: the strchr family of functions should not return const strings.
Andrew Tridgell [Sat, 25 Sep 2004 12:31:49 +0000 (12:31 +0000)]
r2631: the strchr family of functions should not return const strings.
(This used to be commit 2a7e5f07086ef4aebbb2be35acbf9c7c39b13c75)

13 years agor2630: I missed a couple of places in the gensec talloc conversion
Andrew Tridgell [Sat, 25 Sep 2004 12:30:10 +0000 (12:30 +0000)]
r2630: I missed a couple of places in the gensec talloc conversion
(This used to be commit 7124949140141513193f41bb8491aa6a283efed7)

13 years agor2629: convert gensec to the new talloc model
Andrew Tridgell [Sat, 25 Sep 2004 12:08:57 +0000 (12:08 +0000)]
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
(This used to be commit f12ee2f241aab1549bc1d9ca4c35a35a1ca0d09d)

13 years agor2628: got rid of some warnings and converted a few more places to use hierarchical...
Andrew Tridgell [Sat, 25 Sep 2004 11:48:30 +0000 (11:48 +0000)]
r2628: got rid of some warnings and converted a few more places to use hierarchical memory allocation
(This used to be commit 26da45a8019a2d6c9ff2ac2a6739c7d0b42b00de)

13 years agor2627: use the new talloc capabilities in a bunch more places in the rpc
Andrew Tridgell [Sat, 25 Sep 2004 11:24:10 +0000 (11:24 +0000)]
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.
(This used to be commit 76d0b8206ce64d6ff4a192979c43dddbec726d6e)

13 years agor2626: the symbol gai_error is defined in /usr/include, so don't use that name in...
Andrew Tridgell [Sat, 25 Sep 2004 11:19:29 +0000 (11:19 +0000)]
r2626: the symbol gai_error is defined in /usr/include, so don't use that name in our code
(This used to be commit 458f85328850905db8e9808d02898c69b5f9b872)

13 years agor2625: use talloc_p, not talloc when possible (when allocating a structure in particu...
Andrew Tridgell [Sat, 25 Sep 2004 11:18:50 +0000 (11:18 +0000)]
r2625: use talloc_p, not talloc when possible (when allocating a structure in particular), as it gives us type checking.
(This used to be commit dabc7ddd9f940db414d1c3c7bf3cebcd108fbf6f)

13 years agor2624: - save some system calls by only trying read/write operations that select...
Andrew Tridgell [Sat, 25 Sep 2004 11:18:04 +0000 (11:18 +0000)]
r2624: - save some system calls by only trying read/write operations that select has indicated are possible

- when a socket is dead, don't try to do anything more on it
(This used to be commit e95e5c591fcf9c3b7fde7fbdcc1837e22195e0a8)

13 years agor2623: don't do pointer arithmetic on void*, as it doesn't work with non-GNU compilers
Andrew Tridgell [Sat, 25 Sep 2004 11:17:09 +0000 (11:17 +0000)]
r2623: don't do pointer arithmetic on void*, as it doesn't work with non-GNU compilers
(This used to be commit c2be7b696ccb338df06a5212ed1f7b78e4c116c2)

13 years agor2622: to implement the SOCKET_FLAG_BLOCK option in the socket library we
Andrew Tridgell [Sat, 25 Sep 2004 11:16:30 +0000 (11:16 +0000)]
r2622: to implement the SOCKET_FLAG_BLOCK option in the socket library we
need to add MSG_WAITALL to the recv() flags. This is needed by the
current server code or sometimes it will fail with a receive error.
(This used to be commit 4cb11fb77acf74ab53bf5782a114151965c558f0)

13 years agor2621: - now that the client code is non-blocking, we no longer need
Andrew Tridgell [Sat, 25 Sep 2004 11:15:18 +0000 (11:15 +0000)]
r2621: - now that the client code is non-blocking, we no longer need
  write_data and read_data, which are inherently blocking operations

- got rid of some old NBT keepalive routines that are not needed
(This used to be commit e73b4ae4e500d3b7ee57e160e0f8b63c99b2542a)