1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

Forward port the change to talloc_init() to make all talloc contexts

named. Ensure we can query them.
Jeremy.
This commit is contained in:
Jeremy Allison -
parent 0637f582fe
commit 09a218a9f6
40 changed files with 179 additions and 84 deletions

View File

@ -74,9 +74,9 @@ static const uint8 *get_ntlm_challenge(struct auth_context *auth_context)
continue;
}
mem_ctx = talloc_init_named("auth_get_challenge for module %s", auth_method->name);
mem_ctx = talloc_init("auth_get_challenge for module %s", auth_method->name);
if (!mem_ctx) {
smb_panic("talloc_init_named() failed!");
smb_panic("talloc_init() failed!");
}
challenge = auth_method->get_chal(auth_context, &auth_method->private_data, mem_ctx);
@ -211,7 +211,7 @@ static NTSTATUS check_ntlm_password(const struct auth_context *auth_context,
return NT_STATUS_LOGON_FAILURE;
for (auth_method = auth_context->auth_method_list;auth_method; auth_method = auth_method->next) {
mem_ctx = talloc_init_named("%s authentication for user %s\\%s", auth_method->name,
mem_ctx = talloc_init("%s authentication for user %s\\%s", auth_method->name,
user_info->domain.str, user_info->smb_name.str);
nt_status = auth_method->auth(auth_context, auth_method->private_data, mem_ctx, user_info, server_info);
@ -290,7 +290,7 @@ static NTSTATUS make_auth_context(struct auth_context **auth_context)
{
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init_named("authentication context");
mem_ctx = talloc_init("authentication context");
*auth_context = talloc(mem_ctx, sizeof(**auth_context));
if (!*auth_context) {

View File

@ -32,7 +32,7 @@
**/
typedef struct talloc_ctx TALLOC_CTX;
TALLOC_CTX *talloc_init_named(char const *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
TALLOC_CTX *talloc_init(char const *fmt, ...) PRINTF_ATTRIBUTE(1, 2);
char *talloc_vasprintf(TALLOC_CTX *t, const char *fmt, va_list ap)
PRINTF_ATTRIBUTE(2, 0);

View File

@ -117,7 +117,7 @@ static void talloc_disenroll(TALLOC_CTX *t)
/** Create a new talloc context. **/
TALLOC_CTX *talloc_init(void)
static TALLOC_CTX *talloc_init_internal(void)
{
TALLOC_CTX *t;
@ -139,12 +139,12 @@ TALLOC_CTX *talloc_init(void)
* Please call this in preference to talloc_init().
**/
TALLOC_CTX *talloc_init_named(char const *fmt, ...)
TALLOC_CTX *talloc_init(char const *fmt, ...)
{
TALLOC_CTX *t;
va_list ap;
t = talloc_init();
t = talloc_init_internal();
if (t && fmt) {
/*
* t->name must not be talloced.

View File

@ -34,7 +34,7 @@ void msg_pool_usage(int msg_type, pid_t src_pid,
void *UNUSED(buf), size_t UNUSED(len))
{
char *reply;
TALLOC_CTX *reply_pool = talloc_init_named("msg_pool_usage");
TALLOC_CTX *reply_pool = talloc_init("msg_pool_usage");
SMB_ASSERT(msg_type == MSG_REQ_POOL_USAGE);

View File

@ -420,7 +420,7 @@ ADS_STATUS ads_do_paged_search(ADS_STRUCT *ads, const char *bind_path,
*res = NULL;
if (!(ctx = talloc_init()))
if (!(ctx = talloc_init("ads_do_paged_search")))
return ADS_ERROR(LDAP_NO_MEMORY);
/* 0 means the conversion worked but the result was empty
@ -642,7 +642,7 @@ ADS_STATUS ads_do_search(ADS_STRUCT *ads, const char *bind_path, int scope,
char *utf8_exp, *utf8_path, **search_attrs = NULL;
TALLOC_CTX *ctx;
if (!(ctx = talloc_init())) {
if (!(ctx = talloc_init("ads_do_search"))) {
DEBUG(1,("ads_do_search: talloc_init() failed!"));
return ADS_ERROR(LDAP_NO_MEMORY);
}
@ -1031,7 +1031,7 @@ static ADS_STATUS ads_add_machine_acct(ADS_STRUCT *ads, const char *hostname,
char *psp;
unsigned acct_control;
if (!(ctx = talloc_init_named("machine_account")))
if (!(ctx = talloc_init("machine_account")))
return ADS_ERROR(LDAP_NO_MEMORY);
ret = ADS_ERROR(LDAP_NO_MEMORY);
@ -1144,7 +1144,7 @@ static void dump_sd(const char *filed, struct berval **values)
SEC_DESC *psd = 0;
TALLOC_CTX *ctx = 0;
if (!(ctx = talloc_init_named("sec_io_desc")))
if (!(ctx = talloc_init("sec_io_desc")))
return;
/* prepare data */
@ -1246,7 +1246,7 @@ void ads_process_results(ADS_STRUCT *ads, void *res,
void *msg;
TALLOC_CTX *ctx;
if (!(ctx = talloc_init()))
if (!(ctx = talloc_init("ads_process_results")))
return;
for (msg = ads_first_entry(ads, res); msg;
@ -1429,7 +1429,7 @@ ADS_STATUS ads_set_machine_sd(ADS_STRUCT *ads, const char *hostname, char *dn)
msg = ads_first_entry(ads, res);
ads_pull_sid(ads, msg, attrs[1], &sid);
if (!(ctx = talloc_init_named("sec_io_desc"))) {
if (!(ctx = talloc_init("sec_io_desc"))) {
ret = ADS_ERROR(LDAP_NO_MEMORY);
goto ads_set_sd_error;
}
@ -1785,7 +1785,7 @@ ADS_STATUS ads_server_info(ADS_STRUCT *ads)
char *timestr;
TALLOC_CTX *ctx;
if (!(ctx = talloc_init())) {
if (!(ctx = talloc_init("ads_server_info"))) {
return ADS_ERROR(LDAP_NO_MEMORY);
}

View File

@ -50,7 +50,7 @@ ADS_STATUS ads_add_user_acct(ADS_STRUCT *ads, const char *user,
if (fullname && *fullname) name = fullname;
else name = user;
if (!(ctx = talloc_init_named("ads_add_user_acct")))
if (!(ctx = talloc_init("ads_add_user_acct")))
return ADS_ERROR(LDAP_NO_MEMORY);
status = ADS_ERROR(LDAP_NO_MEMORY);
@ -88,7 +88,7 @@ ADS_STATUS ads_add_group_acct(ADS_STRUCT *ads, const char *group,
char *new_dn;
const char *objectClass[] = {"top", "group", NULL};
if (!(ctx = talloc_init_named("ads_add_group_acct")))
if (!(ctx = talloc_init("ads_add_group_acct")))
return ADS_ERROR(LDAP_NO_MEMORY);
status = ADS_ERROR(LDAP_NO_MEMORY);

View File

@ -262,7 +262,7 @@ struct cli_state *cli_initialise(struct cli_state *cli)
if (!cli->outbuf || !cli->inbuf)
goto error;
if ((cli->mem_ctx = talloc_init_named("cli based talloc")) == NULL)
if ((cli->mem_ctx = talloc_init("cli based talloc")) == NULL)
goto error;
memset(cli->outbuf, 0, cli->bufsize);

View File

@ -83,7 +83,7 @@ BOOL cli_set_secdesc(struct cli_state *cli, int fnum, SEC_DESC *sd)
prs_struct pd;
BOOL ret = False;
if ((mem_ctx = talloc_init()) == NULL) {
if ((mem_ctx = talloc_init("cli_set_secdesc")) == NULL) {
DEBUG(0,("talloc_init failed.\n"));
goto cleanup;
}

View File

@ -1003,7 +1003,7 @@ BOOL set_posix_lock(files_struct *fsp, SMB_BIG_UINT u_offset, SMB_BIG_UINT u_cou
* semantics that if a write lock is added, then it will be first in the array.
*/
if ((l_ctx = talloc_init()) == NULL) {
if ((l_ctx = talloc_init("set_posix_lock")) == NULL) {
DEBUG(0,("set_posix_lock: unable to init talloc context.\n"));
return True; /* Not a fatal error. */
}
@ -1149,7 +1149,7 @@ BOOL release_posix_lock(files_struct *fsp, SMB_BIG_UINT u_offset, SMB_BIG_UINT u
}
}
if ((ul_ctx = talloc_init()) == NULL) {
if ((ul_ctx = talloc_init("release_posix_lock")) == NULL) {
DEBUG(0,("release_posix_lock: unable to init talloc context.\n"));
return True; /* Not a fatal error. */
}

View File

@ -95,6 +95,25 @@ static void sig_hup(int sig)
sys_select_signal();
}
/*******************************************************************
Print out all talloc memory info.
********************************************************************/
void return_all_talloc_info(int msg_type, pid_t src_pid, void *buf, size_t len)
{
TALLOC_CTX *ctx = talloc_init("info context");
char *info = NULL;
if (!ctx)
return;
info = talloc_describe_all(ctx);
if (info)
DEBUG(10,(info));
message_send_pid(src_pid, MSG_TALLOC_USAGE, info, info ? strlen(info) + 1 : 0, True);
talloc_destroy(ctx);
}
#if DUMP_CORE
/**************************************************************************** **
Prepare to dump a core file - carefully!
@ -682,6 +701,7 @@ static BOOL open_sockets(BOOL isdaemon, int port)
message_register(MSG_FORCE_ELECTION, nmbd_message_election);
message_register(MSG_WINS_NEW_ENTRY, nmbd_wins_new_entry);
message_register(MSG_SHUTDOWN, nmbd_terminate);
message_register(MSG_REQ_TALLOC_USAGE, return_all_talloc_info);
DEBUG( 3, ( "Opening sockets %d\n", global_nmb_port ) );

View File

@ -58,6 +58,25 @@ static BOOL reload_services_file(BOOL test)
return(ret);
}
/*******************************************************************
Print out all talloc memory info.
********************************************************************/
void return_all_talloc_info(int msg_type, pid_t src_pid, void *buf, size_t len)
{
TALLOC_CTX *ctx = talloc_init("info context");
char *info = NULL;
if (!ctx)
return;
info = talloc_describe_all(ctx);
if (info)
DEBUG(10,(info));
message_send_pid(src_pid, MSG_TALLOC_USAGE, info, info ? strlen(info) + 1: 0, True);
talloc_destroy(ctx);
}
#if DUMP_CORE
/**************************************************************************** **
@ -864,6 +883,7 @@ static void usage(void)
}
register_msg_pool_usage();
message_register(MSG_REQ_TALLOC_USAGE, return_all_talloc_info);
/* Loop waiting for requests */

View File

@ -677,7 +677,7 @@ static NTSTATUS alternate_name(struct winbindd_domain *domain)
ads = ads_cached_connection(domain);
if (!ads) return NT_STATUS_UNSUCCESSFUL;
if (!(ctx = talloc_init_named("alternate_name"))) {
if (!(ctx = talloc_init("alternate_name"))) {
return NT_STATUS_NO_MEMORY;
}

View File

@ -64,7 +64,7 @@ static BOOL fill_grent_mem(struct winbindd_domain *domain,
TALLOC_CTX *mem_ctx;
NTSTATUS status;
if (!(mem_ctx = talloc_init_named("fill_grent_mem(%s)", domain->name)))
if (!(mem_ctx = talloc_init("fill_grent_mem(%s)", domain->name)))
return False;
/* Initialise group membership information */
@ -408,7 +408,7 @@ static BOOL get_sam_group_entries(struct getent_state *ent)
if (ent->got_sam_entries)
return False;
if (!(mem_ctx = talloc_init_named("get_sam_group_entries(%s)",
if (!(mem_ctx = talloc_init("get_sam_group_entries(%s)",
ent->domain_name))) {
DEBUG(1, ("get_sam_group_entries: could not create talloc context!\n"));
return False;
@ -820,7 +820,7 @@ enum winbindd_result winbindd_getgroups(struct winbindd_cli_state *state)
DEBUG(3, ("[%5d]: getgroups %s\n", state->pid,
state->request.data.username));
if (!(mem_ctx = talloc_init_named("winbindd_getgroups(%s)",
if (!(mem_ctx = talloc_init("winbindd_getgroups(%s)",
state->request.data.username)))
return WINBINDD_ERROR;

View File

@ -77,7 +77,7 @@ enum winbindd_result winbindd_pam_auth(struct winbindd_cli_state *state)
DEBUG(3, ("[%5d]: pam auth %s\n", state->pid,
state->request.data.auth.user));
if (!(mem_ctx = talloc_init_named("winbind pam auth for %s", state->request.data.auth.user))) {
if (!(mem_ctx = talloc_init("winbind pam auth for %s", state->request.data.auth.user))) {
DEBUG(0, ("winbindd_pam_auth: could not talloc_init()!\n"));
result = NT_STATUS_NO_MEMORY;
goto done;
@ -179,7 +179,7 @@ enum winbindd_result winbindd_pam_auth_crap(struct winbindd_cli_state *state)
/* Ensure null termination */
state->request.data.auth_crap.domain[sizeof(state->request.data.auth_crap.domain)-1]='\0';
if (!(mem_ctx = talloc_init_named("winbind pam auth crap for (utf8) %s", state->request.data.auth_crap.user))) {
if (!(mem_ctx = talloc_init("winbind pam auth crap for (utf8) %s", state->request.data.auth_crap.user))) {
DEBUG(0, ("winbindd_pam_auth_crap: could not talloc_init()!\n"));
result = NT_STATUS_NO_MEMORY;
goto done;

View File

@ -71,7 +71,7 @@ static NTSTATUS query_user_list(struct winbindd_domain *domain,
ctr.sam.info1 = &info1;
ctx2 = talloc_init_named("winbindd dispinfo");
ctx2 = talloc_init("winbindd dispinfo");
if (!ctx2) {
result = NT_STATUS_NO_MEMORY;
goto done;
@ -152,7 +152,7 @@ static NTSTATUS enum_dom_groups(struct winbindd_domain *domain,
uint32 count = 0, start = *num_entries;
TALLOC_CTX *mem_ctx2;
mem_ctx2 = talloc_init_named("enum_dom_groups[rpc]");
mem_ctx2 = talloc_init("enum_dom_groups[rpc]");
status = cli_samr_enum_dom_groups(hnd->cli, mem_ctx2, &dom_pol,
&start,
@ -212,7 +212,7 @@ static NTSTATUS enum_local_groups(struct winbindd_domain *domain,
uint32 count = 0, start = *num_entries;
TALLOC_CTX *mem_ctx2;
mem_ctx2 = talloc_init_named("enum_dom_local_groups[rpc]");
mem_ctx2 = talloc_init("enum_dom_local_groups[rpc]");
result = cli_samr_enum_als_groups( hnd->cli, mem_ctx2, &dom_pol,
&start, 0xFFFF, &info2, &count);
@ -257,7 +257,7 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
DEBUG(3,("rpc: name_to_sid name=%s\n", name));
if (!(mem_ctx = talloc_init_named("name_to_sid[rpc] for [%s]\\[%s]", domain->name, name))) {
if (!(mem_ctx = talloc_init("name_to_sid[rpc] for [%s]\\[%s]", domain->name, name))) {
DEBUG(0, ("talloc_init failed!\n"));
return NT_STATUS_NO_MEMORY;
}
@ -587,7 +587,7 @@ static NTSTATUS sequence_number(struct winbindd_domain *domain, uint32 *seq)
*seq = DOM_SEQUENCE_NONE;
if (!(mem_ctx = talloc_init_named("sequence_number[rpc]")))
if (!(mem_ctx = talloc_init("sequence_number[rpc]")))
return NT_STATUS_NO_MEMORY;
/* Get sam handle */
@ -667,7 +667,7 @@ static NTSTATUS domain_sid(struct winbindd_domain *domain, DOM_SID *sid)
DEBUG(3,("rpc: domain_sid\n"));
if (!(mem_ctx = talloc_init_named("domain_sid[rpc]")))
if (!(mem_ctx = talloc_init("domain_sid[rpc]")))
return NT_STATUS_NO_MEMORY;
/* Get sam handle */

View File

@ -137,7 +137,7 @@ enum winbindd_result winbindd_getpwnam(struct winbindd_cli_state *state)
from the winbind_lookup_by_name() call and use it in a
winbind_lookup_userinfo() */
if (!(mem_ctx = talloc_init_named("winbindd_getpwnam([%s]\\[%s])",
if (!(mem_ctx = talloc_init("winbindd_getpwnam([%s]\\[%s])",
name_domain, name_user))) {
DEBUG(1, ("out of memory\n"));
return WINBINDD_ERROR;
@ -217,7 +217,7 @@ enum winbindd_result winbindd_getpwuid(struct winbindd_cli_state *state)
/* Get some user info */
if (!(mem_ctx = talloc_init_named("winbind_getpwuid(%d)",
if (!(mem_ctx = talloc_init("winbind_getpwuid(%d)",
state->request.data.uid))) {
DEBUG(1, ("out of memory\n"));
@ -336,7 +336,7 @@ static BOOL get_sam_user_entries(struct getent_state *ent)
if (ent->num_sam_entries)
return False;
if (!(mem_ctx = talloc_init_named("get_sam_user_entries(%s)",
if (!(mem_ctx = talloc_init("get_sam_user_entries(%s)",
ent->domain_name)))
return False;
@ -531,7 +531,7 @@ enum winbindd_result winbindd_list_users(struct winbindd_cli_state *state)
DEBUG(3, ("[%5d]: list users\n", state->pid));
if (!(mem_ctx = talloc_init_named("winbindd_list_users")))
if (!(mem_ctx = talloc_init("winbindd_list_users")))
return WINBINDD_ERROR;
/* Enumerate over trusted domains */

View File

@ -166,7 +166,7 @@ void rescan_trusted_domains(void)
DEBUG(1, ("scanning trusted domain list\n"));
if (!(mem_ctx = talloc_init_named("init_domain_list")))
if (!(mem_ctx = talloc_init("init_domain_list")))
return;
for (domain = _domain_list; domain; domain = domain->next) {
@ -335,7 +335,7 @@ BOOL winbindd_lookup_name_by_sid(DOM_SID *sid,
/* Lookup name */
if (!(mem_ctx = talloc_init_named("winbindd_lookup_name_by_sid")))
if (!(mem_ctx = talloc_init("winbindd_lookup_name_by_sid")))
return False;
result = domain->methods->sid_to_name(domain, mem_ctx, sid, &names, type);

View File

@ -1462,7 +1462,7 @@ static char *lp_string(const char *s)
#endif
if (!lp_talloc)
lp_talloc = talloc_init_named("lp_talloc");
lp_talloc = talloc_init("lp_talloc");
ret = (char *)talloc(lp_talloc, len + 100); /* leave room for substitution */

View File

@ -139,7 +139,7 @@ NTSTATUS pdb_init_sam(SAM_ACCOUNT **user)
TALLOC_CTX *mem_ctx;
NTSTATUS nt_status;
mem_ctx = talloc_init_named("passdb internal SAM_ACCOUNT allocation");
mem_ctx = talloc_init("passdb internal SAM_ACCOUNT allocation");
if (!mem_ctx) {
DEBUG(0,("pdb_init_sam: error while doing talloc_init()\n"));

View File

@ -415,7 +415,7 @@ static NTSTATUS make_pdb_context(struct pdb_context **context)
{
TALLOC_CTX *mem_ctx;
mem_ctx = talloc_init_named("pdb_context internal allocation context");
mem_ctx = talloc_init("pdb_context internal allocation context");
if (!mem_ctx) {
DEBUG(0, ("make_pdb_context: talloc init failed!\n"));

View File

@ -146,7 +146,7 @@ static void send_spoolss_notify2_msg(struct spoolss_notify_msg *msg)
return;
if (!send_ctx)
send_ctx = talloc_init_named("print notify queue");
send_ctx = talloc_init("print notify queue");
if (!send_ctx)
goto fail;

View File

@ -2574,7 +2574,7 @@ static void store_printer_guid(NT_PRINTER_INFO_LEVEL_2 *info2, GUID guid)
static WERROR publish_it(NT_PRINTER_INFO_LEVEL *printer)
{
ADS_STATUS ads_rc;
TALLOC_CTX *ctx = talloc_init();
TALLOC_CTX *ctx = talloc_init("publish_it");
ADS_MODLIST mods = ads_init_mods(ctx);
char *prt_dn = NULL, *srv_dn, **srv_cn;
void *res = NULL;
@ -3713,7 +3713,7 @@ static WERROR save_driver_init_2(NT_PRINTER_INFO_LEVEL *printer, uint8 *data, ui
* saved to tdb.
*/
if ((ctx = talloc_init()) == NULL)
if ((ctx = talloc_init("save_driver_init_2")) == NULL)
return WERR_NOMEM;
if ((nt_devmode = (NT_DEVICEMODE*)malloc(sizeof(NT_DEVICEMODE))) == NULL) {
@ -4397,7 +4397,7 @@ WERROR nt_printing_setsec(const char *printername, SEC_DESC_BUF *secdesc_ctr)
fstring key;
WERROR status;
mem_ctx = talloc_init();
mem_ctx = talloc_init("nt_printing_setsec");
if (mem_ctx == NULL)
return WERR_NOMEM;
@ -4744,7 +4744,7 @@ BOOL print_access_check(struct current_user *user, int snum, int access_type)
/* Get printer security descriptor */
if(!(mem_ctx = talloc_init())) {
if(!(mem_ctx = talloc_init("print_access_check"))) {
errno = ENOMEM;
return False;
}

View File

@ -33,7 +33,7 @@
void regsubkey_ctr_init( REGSUBKEY_CTR *ctr )
{
if ( !ctr->ctx )
ctr->ctx = talloc_init();
ctr->ctx = talloc_init("regsubkey_ctr_init for ctr %p", ctr);
}
/***********************************************************************
@ -114,7 +114,7 @@ void regsubkey_ctr_destroy( REGSUBKEY_CTR *ctr )
void regval_ctr_init( REGVAL_CTR *ctr )
{
if ( !ctr->ctx )
ctr->ctx = talloc_init();
ctr->ctx = talloc_init("regval_ctr_init for ctr %p", ctr);
}
/***********************************************************************

View File

@ -63,7 +63,7 @@ void main_loop_talloc_free(void)
TALLOC_CTX *main_loop_talloc_get(void)
{
if (!main_loop_talloc) {
main_loop_talloc = talloc_init_named("main loop talloc (mainly parse_misc)");
main_loop_talloc = talloc_init("main loop talloc (mainly parse_misc)");
if (!main_loop_talloc)
smb_panic("main_loop_talloc: malloc fail\n");
}

View File

@ -293,7 +293,7 @@ static void *make_internal_rpc_pipe_p(char *pipe_name,
ZERO_STRUCTP(p);
if ((p->mem_ctx = talloc_init()) == NULL) {
if ((p->mem_ctx = talloc_init("pipe %s %p", pipe_name, p)) == NULL) {
DEBUG(0,("open_rpc_pipe_p: talloc_init failed.\n"));
SAFE_FREE(p);
return NULL;
@ -544,7 +544,7 @@ void free_pipe_context(pipes_struct *p)
DEBUG(3,("free_pipe_context: destroying talloc pool of size %u\n", talloc_pool_size(p->mem_ctx) ));
talloc_destroy_pool(p->mem_ctx);
} else {
p->mem_ctx = talloc_init();
p->mem_ctx = talloc_init("pipe %s %p", p->name, p);
if (p->mem_ctx == NULL)
p->fault_state = True;
}

View File

@ -134,7 +134,7 @@ static struct samr_info *get_samr_info_by_sid(DOM_SID *psid)
fstrcpy(sid_str,"(NULL)");
}
mem_ctx = talloc_init_named("samr_info for domain sid %s", sid_str);
mem_ctx = talloc_init("samr_info for domain sid %s", sid_str);
if ((info = (struct samr_info *)talloc(mem_ctx, sizeof(struct samr_info))) == NULL)
return NULL;

View File

@ -776,7 +776,7 @@ static void notify_msg_ctr_init( SPOOLSS_NOTIFY_MSG_CTR *ctr )
if ( !ctr )
return;
ctr->ctx = talloc_init();
ctr->ctx = talloc_init("notify_msg_ctr_init %p", ctr);
return;
}

View File

@ -237,7 +237,7 @@ static BOOL set_share_security(TALLOC_CTX *ctx, const char *share_name, SEC_DESC
fstring key;
BOOL ret = False;
mem_ctx = talloc_init();
mem_ctx = talloc_init("set_share_security");
if (mem_ctx == NULL)
return False;
@ -327,7 +327,7 @@ BOOL share_access_check(connection_struct *conn, int snum, user_struct *vuser, u
NT_USER_TOKEN *token = NULL;
BOOL ret = True;
mem_ctx = talloc_init();
mem_ctx = talloc_init("share_access_check");
if (mem_ctx == NULL)
return False;

View File

@ -1310,7 +1310,7 @@ static NTSTATUS cmd_samr_query_sec_obj(struct cli_state *cli,
SEC_DESC_BUF *sec_desc_buf=NULL;
BOOL domain = False;
ctx=talloc_init();
ctx=talloc_init("cmd_samr_query_sec_obj");
if ((argc < 1) || (argc > 2)) {
printf("Usage: %s [rid|-d]\n", argv[0]);

View File

@ -197,7 +197,7 @@ static void fetch_machine_sid(struct cli_state *cli)
if (got_domain_sid) return;
if (!(mem_ctx=talloc_init()))
if (!(mem_ctx=talloc_init("fetch_machine_sid")))
{
DEBUG(0,("fetch_machine_sid: talloc_init returned NULL!\n"));
goto error;
@ -479,7 +479,7 @@ static NTSTATUS do_cmd(struct cli_state *cli, struct cmd_set *cmd_entry,
/* Create mem_ctx */
if (!(mem_ctx = talloc_init())) {
if (!(mem_ctx = talloc_init("do_cmd"))) {
DEBUG(0, ("talloc_init() failed\n"));
goto done;
}

View File

@ -985,7 +985,7 @@ static NTSTATUS set_sd(files_struct *fsp, char *data, uint32 sd_len, uint32 secu
* Init the parse struct we will unmarshall from.
*/
if ((mem_ctx = talloc_init()) == NULL) {
if ((mem_ctx = talloc_init("set_sd")) == NULL) {
DEBUG(0,("set_sd: talloc_init failed.\n"));
return NT_STATUS_NO_MEMORY;
}
@ -1538,7 +1538,7 @@ static int call_nt_transact_query_security_desc(connection_struct *conn,
*ppparams = params;
if ((mem_ctx = talloc_init()) == NULL) {
if ((mem_ctx = talloc_init("call_nt_transact_query_security_desc")) == NULL) {
DEBUG(0,("call_nt_transact_query_security_desc: talloc_init failed.\n"));
return ERROR_DOS(ERRDOS,ERRnomem);
}

View File

@ -463,6 +463,25 @@ BOOL reload_services(BOOL test)
return(ret);
}
/*******************************************************************
Print out all talloc memory info.
********************************************************************/
void return_all_talloc_info(int msg_type, pid_t src_pid, void *buf, size_t len)
{
TALLOC_CTX *ctx = talloc_init("info context");
char *info = NULL;
if (!ctx)
return;
info = talloc_describe_all(ctx);
if (info)
DEBUG(10,(info));
message_send_pid(src_pid, MSG_TALLOC_USAGE, info, info ? strlen(info) + 1 : 0, True);
talloc_destroy(ctx);
}
#if DUMP_CORE
/*******************************************************************
prepare to dump a core file - carefully!
@ -759,19 +778,18 @@ static BOOL init_structs(void )
setpgid( (pid_t)0, (pid_t)0);
#endif
if (!directory_exist(lp_lockdir(), NULL)) {
if (!directory_exist(lp_lockdir(), NULL))
mkdir(lp_lockdir(), 0755);
}
if (is_daemon) {
if (is_daemon)
pidfile_create("smbd");
}
if (!message_init()) {
if (!message_init())
exit(1);
}
register_msg_pool_usage();
register_dmalloc_msgs();
message_register(MSG_REQ_TALLOC_USAGE, return_all_talloc_info);
if (!print_backend_init())
exit(1);
@ -840,7 +858,6 @@ static BOOL init_structs(void )
/* register our message handlers */
message_register(MSG_SMB_FORCE_TDIS, msg_force_tdis);
talloc_init_named("dummy!");
smbd_process();

View File

@ -304,7 +304,7 @@ static NTSTATUS do_cmd(struct vfs_state *vfs, struct cmd_set *cmd_entry, char *c
if (mem_ctx == NULL) {
/* Create mem_ctx */
if (!(mem_ctx = talloc_init())) {
if (!(mem_ctx = talloc_init("do_cmd"))) {
DEBUG(0, ("talloc_init() failed\n"));
goto done;
}

View File

@ -180,7 +180,7 @@ static int net_ads_workgroup(int argc, const char **argv)
if (!(ads = ads_startup())) return -1;
if (!(ctx = talloc_init_named("net_ads_workgroup"))) {
if (!(ctx = talloc_init("net_ads_workgroup"))) {
return -1;
}
@ -748,7 +748,7 @@ static int net_ads_printer_publish(int argc, const char **argv)
struct in_addr server_ip;
NTSTATUS nt_status;
extern char *opt_workgroup;
TALLOC_CTX *mem_ctx = talloc_init();
TALLOC_CTX *mem_ctx = talloc_init("net_ads_printer_publish");
ADS_MODLIST mods = ads_init_mods(mem_ctx);
char *prt_dn, *srv_dn, **srv_cn;
void *res = NULL;

View File

@ -62,7 +62,7 @@ static DOM_SID *net_get_remote_domain_sid(struct cli_state *cli)
goto error;
}
if (!(mem_ctx=talloc_init()))
if (!(mem_ctx=talloc_init("net_get_remote_domain_sid")))
{
DEBUG(0,("net_get_remote_domain_sid: talloc_init returned NULL!\n"));
goto error;
@ -138,7 +138,7 @@ static int run_rpc_command(struct cli_state *cli_arg, const int pipe_idx, int co
/* Create mem_ctx */
if (!(mem_ctx = talloc_init())) {
if (!(mem_ctx = talloc_init("run_rpc_command"))) {
DEBUG(0, ("talloc_init() failed\n"));
cli_shutdown(cli);
return -1;
@ -374,7 +374,7 @@ rpc_info_internals(const DOM_SID *domain_sid, struct cli_state *cli,
result = cli_samr_query_dom_info(cli, mem_ctx, &domain_pol,
2, &ctr);
if (NT_STATUS_IS_OK(result)) {
TALLOC_CTX *ctx = talloc_init();
TALLOC_CTX *ctx = talloc_init("rpc_info_internals");
d_printf("Domain Name: %s\n", unistr2_tdup(ctx, &ctr.info.inf2.uni_domain));
d_printf("Domain SID: %s\n", sid_str);
d_printf("Sequence number: %u\n", ctr.info.inf2.seq_num);
@ -1721,7 +1721,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
return -1;
}
if (!(mem_ctx = talloc_init_named("establishing trust relationship to domain %s",
if (!(mem_ctx = talloc_init("establishing trust relationship to domain %s",
domain_name))) {
DEBUG(0, ("talloc_init() failed\n"));
cli_shutdown(cli);
@ -1743,7 +1743,7 @@ static int rpc_trustdom_establish(int argc, const char **argv)
* Call LsaOpenPolicy and LsaQueryInfo
*/
if (!(mem_ctx = talloc_init())) {
if (!(mem_ctx = talloc_init("rpc_trustdom_establish"))) {
DEBUG(0, ("talloc_init() failed\n"));
cli_shutdown(cli);
return -1;
@ -1903,7 +1903,7 @@ static int rpc_trustdom_list(int argc, const char **argv)
* Listing trusted domains (stored in secrets.tdb, if local)
*/
mem_ctx = talloc_init_named("trust relationships listing");
mem_ctx = talloc_init("trust relationships listing");
/*
* set domain and pdc name to local samba server (default)

View File

@ -141,7 +141,7 @@ int net_rpc_join_newstyle(int argc, const char **argv)
if (!(cli = net_make_ipc_connection(NET_FLAGS_PDC)))
return 1;
if (!(mem_ctx = talloc_init())) {
if (!(mem_ctx = talloc_init("net_rpc_join_newstyle"))) {
DEBUG(0, ("Could not initialise talloc context\n"));
goto done;
}

View File

@ -128,7 +128,7 @@ static void dump_database(struct cli_state *cli, unsigned db_type, DOM_CRED *ret
SAM_DELTA_CTR *deltas;
uint32 num_deltas;
if (!(mem_ctx = talloc_init())) {
if (!(mem_ctx = talloc_init("dump_database"))) {
return;
}
@ -452,7 +452,7 @@ fetch_group_mem_info(uint32 rid, SAM_GROUP_MEM_INFO *delta)
d_printf("Group members of %s: ", grp->gr_name);
if (!(t = talloc_init())) {
if (!(t = talloc_init("fetch_group_mem_info"))) {
DEBUG(0, ("could not talloc_init\n"));
return NT_STATUS_NO_MEMORY;
}
@ -656,7 +656,7 @@ fetch_database(struct cli_state *cli, unsigned db_type, DOM_CRED *ret_creds,
SAM_DELTA_CTR *deltas;
uint32 num_deltas;
if (!(mem_ctx = talloc_init())) {
if (!(mem_ctx = talloc_init("fetch_database"))) {
return;
}

View File

@ -777,7 +777,7 @@ You can string acls together with spaces, commas or newlines\n\
struct cli_state *cli;
ctx=talloc_init();
ctx=talloc_init("main");
setlinebuf(stdout);

View File

@ -43,6 +43,7 @@ static struct {
{"dmalloc-log-changed", MSG_REQ_DMALLOC_LOG_CHANGED },
{"shutdown", MSG_SHUTDOWN },
{"drvupgrade", MSG_PRINTER_DRVUPGRADE},
{"tallocdump", MSG_REQ_TALLOC_USAGE},
{NULL, -1}
};
@ -75,8 +76,10 @@ static void usage(BOOL doexit)
static int pong_count;
static BOOL got_level;
static BOOL got_pool;
static BOOL pong_registered = False;
static BOOL debuglevel_registered = False;
static BOOL poolusage_registered = False;
static BOOL profilelevel_registered = False;
@ -108,6 +111,22 @@ void pong_function(int msg_type, pid_t src, void *buf, size_t len)
printf("PONG from PID %u\n",(unsigned int)src);
}
/****************************************************************************
Prints out the current talloc list.
****************************************************************************/
void tallocdump_function(int msg_type, pid_t src, void *buf, size_t len)
{
char *info = (char *)buf;
printf("Current talloc contexts for process %u\n", (unsigned int)src );
if (len == 0)
printf("None returned\n");
else
printf(info);
printf("\n");
got_pool = True;
}
/****************************************************************************
Prints out the current Debug level returned by MSG_DEBUGLEVEL
****************************************************************************/
@ -347,6 +366,25 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
}
break;
case MSG_REQ_TALLOC_USAGE:
if (!poolusage_registered) {
message_register(MSG_TALLOC_USAGE, tallocdump_function);
poolusage_registered = True;
}
got_pool = False;
retval = send_message(dest, MSG_REQ_TALLOC_USAGE, NULL, 0, True);
if (retval) {
timeout_start = time(NULL);
while (!got_pool) {
message_dispatch();
if ((time(NULL) - timeout_start) > MAX_WAIT) {
fprintf(stderr,"tallocdump timeout\n");
break;
}
}
}
break;
case MSG_REQ_DEBUGLEVEL:
if (!debuglevel_registered) {
message_register(MSG_DEBUGLEVEL, debuglevel_function);

View File

@ -707,7 +707,7 @@ static void process(void)
}
/* Initialise the memory context */
mem_ctx=talloc_init_named("wins repl talloc ctx");
mem_ctx=talloc_init("wins repl talloc ctx");
/* initialise the global partners table */
partner_count=init_wins_partner_table();