/* Print it all out at once to prevent split syslog output. */
if( lp_debug_prefix_timestamp() ) {
(void)Debug1( "[%s, %2d%s] ",
- current_timestring(lp_debug_hires_timestamp()), level,
- header_str);
+ current_timestring(debug_ctx(),
+ lp_debug_hires_timestamp()),
+ level, header_str);
} else {
(void)Debug1( "[%s, %2d%s] %s:%s(%d)\n",
- current_timestring(lp_debug_hires_timestamp()), level,
- header_str, file, func, line );
+ current_timestring(debug_ctx(),
+ lp_debug_hires_timestamp()),
+ level, header_str, file, func, line );
}
}
fstring pidstr, vnnstr;
char addr[INET6_ADDRSTRLEN];
const char *local_machine_name = get_local_machine_name();
+ TALLOC_CTX *tmp_ctx = NULL;
/* workaround to prevent a crash while looking at bug #687 */
DEBUG(0, ("alloc_sub_basic: Out of memory!\n"));
return NULL;
}
-
+
+ tmp_ctx = talloc_stackframe();
+
for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
r = NULL;
b = a_string;
-
+
switch (*(p+1)) {
case 'U' :
r = strdup_lower(smb_name);
if (r == NULL) {
goto error;
}
- pass = Get_Pwnam_alloc(talloc_tos(), r);
+ pass = Get_Pwnam_alloc(tmp_ctx, r);
if (pass != NULL) {
a_string = realloc_string_sub(
a_string, "%G",
a_string = realloc_string_sub(a_string, "%R", remote_proto);
break;
case 'T' :
- a_string = realloc_string_sub(a_string, "%T", current_timestring(False));
+ a_string = realloc_string_sub(a_string, "%T", current_timestring(tmp_ctx, False));
break;
case 'a' :
a_string = realloc_string_sub(a_string, "%a",
p++;
SAFE_FREE(r);
-
- if ( !a_string ) {
- return NULL;
+
+ if (a_string == NULL) {
+ goto done;
}
}
- return a_string;
+ goto done;
error:
SAFE_FREE(a_string);
- return NULL;
+
+done:
+ TALLOC_FREE(tmp_ctx);
+ return a_string;
}
/****************************************************************************
Return the date and time as a string
****************************************************************************/
-char *current_timestring(bool hires)
+char *current_timestring(TALLOC_CTX *ctx, bool hires)
{
fstring TimeBuf;
struct timeval tp;
}
#endif
}
- return talloc_strdup(talloc_tos(), TimeBuf);
+ return talloc_strdup(ctx, TimeBuf);
}
if (NT_STATUS_IS_OK(nt_status)) {
DEBUG(3,("%s : trust_pw_change_and_store_it: Changed password.\n",
- current_timestring(False)));
+ current_timestring(debug_ctx(), False)));
/*
* Return the result of trying to write the new password
* back into the trust account file.
PRINTER_INFO_CTR ctr;
PRINTER_INFO_0 info;
REGISTRY_VALUE value;
+ TALLOC_CTX *tmp_ctx = talloc_stackframe();
/* parse the command arguements */
if (argc < 5) {
printf ("Usage: %s <printer> <string|binary|dword|multistring>"
" <value> <data>\n",
argv[0]);
- return WERR_INVALID_PARAM;
+ result = WERR_INVALID_PARAM;
+ goto done;
}
slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->cli->desthost);
if (value.type == REG_NONE) {
printf("Unknown data type: %s\n", argv[2]);
- return WERR_INVALID_PARAM;
+ result = WERR_INVALID_PARAM;
+ goto done;
}
/* get a printer handle */
if (!W_ERROR_IS_OK(result))
goto done;
- printf("%s\n", current_timestring(True));
+ printf("%s\n", current_timestring(tmp_ctx, True));
printf("\tchange_id (before set)\t:[0x%x]\n", info.change_id);
/* Set the printer data */
if (!W_ERROR_IS_OK(result))
goto done;
- printf("%s\n", current_timestring(True));
+ printf("%s\n", current_timestring(tmp_ctx, True));
printf("\tchange_id (after set)\t:[0x%x]\n", info.change_id);
done:
/* cleanup */
+ TALLOC_FREE(tmp_ctx);
if (opened_hnd)
rpccli_spoolss_close_printer(cli, mem_ctx, &pol);
failed:
if (!NT_STATUS_IS_OK(nt_status)) {
DEBUG(0,("%s : change_trust_account_password: Failed to change password for domain %s.\n",
- current_timestring(False), domain));
+ current_timestring(debug_ctx(), False), domain));
}
else
DEBUG(5,("change_trust_account_password: sucess!\n"));
****************************************************************************/
static void write_config(FILE *f, bool show_defaults)
{
+ TALLOC_CTX *ctx = talloc_stackframe();
+
fprintf(f, "# Samba config file created using SWAT\n");
fprintf(f, "# from %s (%s)\n", cgi_remote_host(), cgi_remote_addr());
- fprintf(f, "# Date: %s\n\n", current_timestring(False));
+ fprintf(f, "# Date: %s\n\n", current_timestring(ctx, False));
lp_dump(f, show_defaults, iNumNonAutoPrintServices);
+
+ TALLOC_FREE(ctx);
}
/****************************************************************************