From e6c3ac59c5adb433d6269cae7141e575da7fdc8d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 12:19:56 +0100 Subject: Failure while unjoining a domain is non-critical. Just continue joining to the workgroup in that case. Guenther (This used to be commit bf9ce2a928e3136d3bfe368f75d5b99273c5b04f) --- source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c index d12e66bb26..1e1681ba37 100644 --- a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c +++ b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c @@ -449,14 +449,8 @@ static void callback_do_join(GtkWidget *widget, initial_workgroup_type, state->name_buffer_initial, err_str); - - g_signal_connect_swapped(dialog, "response", - G_CALLBACK(gtk_widget_destroy), - dialog); - - gtk_widget_show(dialog); - - return; + gtk_dialog_run(GTK_DIALOG(dialog)); + gtk_widget_destroy(dialog); } } -- cgit From 68ec31427735e3d127544e52d4107d1e97eeeada Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 12:41:18 +0100 Subject: In gfree_debugsyms() free the format_bufr as well. Guenther (This used to be commit 48f09ca376f9fc7923309f3466e5d72f7c21a56f) --- source3/lib/debug.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/debug.c b/source3/lib/debug.c index 9ea2dc151a..6c1bfea04f 100644 --- a/source3/lib/debug.c +++ b/source3/lib/debug.c @@ -199,6 +199,8 @@ void gfree_debugsyms(void) if ( DEBUGLEVEL_CLASS_ISSET != &debug_all_class_isset_hack ) SAFE_FREE( DEBUGLEVEL_CLASS_ISSET ); + + SAFE_FREE(format_bufr); } /**************************************************************************** -- cgit From be7df54c3912a2db024f19d789d385e99ed98917 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 12:44:25 +0100 Subject: Fix two memleaks in libnetapi. Guenther (This used to be commit d73bde99e8518607bb78b5625ce5fb1991d8e402) --- source3/lib/netapi/netapi.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 032798d0f9..9c418f254c 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -1,7 +1,7 @@ /* * Unix SMB/CIFS implementation. * NetApi Support - * Copyright (C) Guenther Deschner 2007 + * Copyright (C) Guenther Deschner 2007-2008 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -90,6 +90,9 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) gfree_charcnv(); gfree_interfaces(); + gencache_shutdown(); + secrets_shutdown(); + TALLOC_FREE(ctx); TALLOC_FREE(frame); -- cgit From 02f67cfcfa09245e79ecbe41dfadd04f5418253a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 14:15:48 +0100 Subject: Add free_local_machine_name(). Guenther (This used to be commit f3ebb4f96bb0364dae9924e798652e759b63bb52) --- source3/lib/substitute.c | 5 +++++ source3/lib/util.c | 1 + 2 files changed, 6 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/substitute.c b/source3/lib/substitute.c index 80feee9579..59b54c4dff 100644 --- a/source3/lib/substitute.c +++ b/source3/lib/substitute.c @@ -34,6 +34,11 @@ fstring remote_proto="UNKNOWN"; static char *local_machine; +void free_local_machine_name(void) +{ + SAFE_FREE(local_machine); +} + bool set_local_machine_name(const char *local_name, bool perm) { static bool already_perm = false; diff --git a/source3/lib/util.c b/source3/lib/util.c index c69a1450a0..25b2700ae3 100644 --- a/source3/lib/util.c +++ b/source3/lib/util.c @@ -183,6 +183,7 @@ void gfree_names(void) SAFE_FREE( smb_myworkgroup ); SAFE_FREE( smb_scope ); free_netbios_names_array(); + free_local_machine_name(); } void gfree_all( void ) -- cgit From fa1e5e95d505d28eb50398511f95ebf13a28b4e5 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 18:36:06 +0100 Subject: Add NET_API_STATUS_SUCCESS define. Guenther (This used to be commit a72ad63163a8c642ea762087a739e6d63c37647a) --- source3/lib/netapi/netapi.c | 18 +++++++++--------- source3/lib/netapi/netapi.h | 6 +++++- 2 files changed, 14 insertions(+), 10 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 9c418f254c..a37ed7c072 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -32,7 +32,7 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) if (stat_ctx && libnetapi_initialized) { *context = stat_ctx; - return W_ERROR_V(WERR_OK); + return NET_API_STATUS_SUCCESS; } frame = talloc_stackframe(); @@ -69,14 +69,14 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) *context = stat_ctx = ctx; - return W_ERROR_V(WERR_OK); + return NET_API_STATUS_SUCCESS; } NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx) { if (stat_ctx) { *ctx = stat_ctx; - return W_ERROR_V(WERR_OK); + return NET_API_STATUS_SUCCESS; } return libnetapi_init(ctx); @@ -98,7 +98,7 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) gfree_debugsyms(); - return W_ERROR_V(WERR_OK); + return NET_API_STATUS_SUCCESS; } NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, @@ -109,14 +109,14 @@ NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, if (!debug_parse_levels(debuglevel)) { return W_ERROR_V(WERR_GENERAL_FAILURE); } - return W_ERROR_V(WERR_OK); + return NET_API_STATUS_SUCCESS; } NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, const char **debuglevel) { *debuglevel = ctx->debuglevel; - return W_ERROR_V(WERR_OK); + return NET_API_STATUS_SUCCESS; } NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, @@ -127,7 +127,7 @@ NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, if (!ctx->username) { return W_ERROR_V(WERR_NOMEM); } - return W_ERROR_V(WERR_OK); + return NET_API_STATUS_SUCCESS; } NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx, @@ -138,7 +138,7 @@ NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx, if (!ctx->password) { return W_ERROR_V(WERR_NOMEM); } - return W_ERROR_V(WERR_OK); + return NET_API_STATUS_SUCCESS; } NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, @@ -149,7 +149,7 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, if (!ctx->workgroup) { return W_ERROR_V(WERR_NOMEM); } - return W_ERROR_V(WERR_OK); + return NET_API_STATUS_SUCCESS; } const char *libnetapi_errstr(struct libnetapi_ctx *ctx, diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 0dd6d95ceb..2c6e126949 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -1,7 +1,7 @@ /* * Unix SMB/CIFS implementation. * NetApi Support - * Copyright (C) Guenther Deschner 2007 + * Copyright (C) Guenther Deschner 2007-2008 * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,6 +21,10 @@ #define __LIB_NETAPI_H__ #define NET_API_STATUS uint32_t +#define NET_API_STATUS_SUCCESS 0 + +/**************************************************************** +****************************************************************/ struct libnetapi_ctx { const char *debuglevel; -- cgit From cc1982ab1cb436a9410699bac5bafa7c6077530a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 18:37:04 +0100 Subject: Close registry in libnetapi_free(). Guenther (This used to be commit e7258a4408e40686ff090d0f8e120ce78acbd097) --- source3/lib/netapi/netapi.c | 1 + 1 file changed, 1 insertion(+) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index a37ed7c072..33ca67ec85 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -92,6 +92,7 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) gencache_shutdown(); secrets_shutdown(); + regdb_close(); TALLOC_FREE(ctx); TALLOC_FREE(frame); -- cgit From 0b92d8bc79172dc587f53ce4b35a8fa3128ae0ea Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 18:40:25 +0100 Subject: Free libnet_JoinCtx after joining. Guenther (This used to be commit 5abae9ef15fa9884c5c4a0e256274f70f6ecd779) --- source3/lib/netapi/joindomain.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index c7849c952f..8fe6193f40 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -77,7 +77,10 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, r->in.join_flags = join_flags; r->in.modify_config = true; - return libnet_Join(mem_ctx, r); + werr = libnet_Join(mem_ctx, r); + TALLOC_FREE(r); + + return werr; } static WERROR NetJoinDomainRemote(struct libnetapi_ctx *ctx, -- cgit From 528d253cc834235213f29411a058485681260140 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 18:41:49 +0100 Subject: Rearrange order of libnet join context init. Guenther (This used to be commit 89669c66f27fb47c9769d1058e29bff83f862752) --- source3/lib/netapi/joindomain.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index 8fe6193f40..ceb7ca10d9 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -33,13 +33,13 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, struct libnet_JoinCtx *r = NULL; WERROR werr; - werr = libnet_init_JoinCtx(mem_ctx, &r); - W_ERROR_NOT_OK_RETURN(werr); - if (!domain_name) { return WERR_INVALID_PARAM; } + werr = libnet_init_JoinCtx(mem_ctx, &r); + W_ERROR_NOT_OK_RETURN(werr); + r->in.domain_name = talloc_strdup(mem_ctx, domain_name); W_ERROR_HAVE_NO_MEMORY(r->in.domain_name); -- cgit From 1fba8c801934233e754710dd477cafdab97841bd Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 20:01:28 +0100 Subject: Let libnetapi use it's own krb5 cred cache in memory if necessary. Guenther (This used to be commit 863fb30038e384585502f0154a742481594b99d0) --- source3/lib/netapi/netapi.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 33ca67ec85..6d27b99d96 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -26,9 +26,13 @@ struct libnetapi_ctx *stat_ctx = NULL; TALLOC_CTX *frame = NULL; static bool libnetapi_initialized = false; +/**************************************************************** +****************************************************************/ + NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) { struct libnetapi_ctx *ctx = NULL; + char *krb5_cc_env = NULL; if (stat_ctx && libnetapi_initialized) { *context = stat_ctx; @@ -65,6 +69,12 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) BlockSignals(True, SIGPIPE); + krb5_cc_env = getenv(KRB5_ENV_CCNAME); + if (!krb5_cc_env || (strlen(krb5_cc_env) == 0)) { + ctx->krb5_cc_env = talloc_strdup(frame, "MEMORY:libnetapi"); + setenv(KRB5_ENV_CCNAME, ctx->krb5_cc_env, 1); + } + libnetapi_initialized = true; *context = stat_ctx = ctx; @@ -72,6 +82,9 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx) { if (stat_ctx) { @@ -82,6 +95,9 @@ NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx) return libnetapi_init(ctx); } +/**************************************************************** +****************************************************************/ + NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) { gfree_names(); @@ -94,6 +110,11 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) secrets_shutdown(); regdb_close(); + if (ctx->krb5_cc_env && + (strequal(ctx->krb5_cc_env, getenv(KRB5_ENV_CCNAME)))) { + unsetenv(KRB5_ENV_CCNAME); + } + TALLOC_FREE(ctx); TALLOC_FREE(frame); @@ -102,6 +123,9 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, const char *debuglevel) { @@ -113,6 +137,9 @@ NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, const char **debuglevel) { @@ -120,6 +147,9 @@ NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *username) { @@ -153,6 +183,9 @@ NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, return NET_API_STATUS_SUCCESS; } +/**************************************************************** +****************************************************************/ + const char *libnetapi_errstr(struct libnetapi_ctx *ctx, NET_API_STATUS status) { -- cgit From 1b3520db8836437b9d4d48fab4df69126c1d9b5d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 20:03:32 +0100 Subject: Add krb5 cc env to libnetapi_ctx. Guenther (This used to be commit df2b078fa1658bdbff1280f7fe0b062d9eabd60c) --- source3/lib/netapi/netapi.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 2c6e126949..3c9d3b3853 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -31,8 +31,12 @@ struct libnetapi_ctx { char *username; char *workgroup; char *password; + char *krb5_cc_env; }; +/**************************************************************** +****************************************************************/ + NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx); NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx); NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx); -- cgit From 751fc874bec2cbc93b4a84067f3e7102f39bd76c Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 20:06:41 +0100 Subject: Add libnetapi_set_error_string and libnetapi_get_error_string. Guenther (This used to be commit f8806bad8134d544229c426f58bee143ba752cf8) --- source3/lib/netapi/netapi.c | 27 +++++++++++++++++++++++++-- source3/lib/netapi/netapi.h | 10 ++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 6d27b99d96..d5527dc4ff 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -130,7 +130,7 @@ NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, const char *debuglevel) { AllowDebugChange = true; - ctx->debuglevel = debuglevel; + ctx->debuglevel = talloc_strdup(ctx, debuglevel); if (!debug_parse_levels(debuglevel)) { return W_ERROR_V(WERR_GENERAL_FAILURE); } @@ -141,7 +141,7 @@ NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, ****************************************************************/ NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, - const char **debuglevel) + char **debuglevel) { *debuglevel = ctx->debuglevel; return NET_API_STATUS_SUCCESS; @@ -195,3 +195,26 @@ const char *libnetapi_errstr(struct libnetapi_ctx *ctx, return get_friendly_werror_msg(W_ERROR(status)); } + +/**************************************************************** +****************************************************************/ + +NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, + const char *error_string) +{ + TALLOC_FREE(ctx->error_string); + ctx->error_string = talloc_strdup(ctx, error_string); + if (!ctx->error_string) { + return W_ERROR_V(WERR_NOMEM); + } + return NET_API_STATUS_SUCCESS; + +} + +/**************************************************************** +****************************************************************/ + +const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx) +{ + return ctx->error_string; +} diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 3c9d3b3853..46dd8e1a24 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -27,7 +27,8 @@ ****************************************************************/ struct libnetapi_ctx { - const char *debuglevel; + char *debuglevel; + char *error_string; char *username; char *workgroup; char *password; @@ -41,11 +42,16 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **ctx); NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx); NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx); NET_API_STATUS libnetapi_set_debuglevel(struct libnetapi_ctx *ctx, const char *debuglevel); -NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, const char **debuglevel); +NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, char **debuglevel); NET_API_STATUS libnetapi_set_username(struct libnetapi_ctx *ctx, const char *username); NET_API_STATUS libnetapi_set_password(struct libnetapi_ctx *ctx, const char *password); NET_API_STATUS libnetapi_set_workgroup(struct libnetapi_ctx *ctx, const char *workgroup); const char *libnetapi_errstr(struct libnetapi_ctx *ctx, NET_API_STATUS status); +NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *error_string); +const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx); + +/**************************************************************** +****************************************************************/ /* wkssvc */ NET_API_STATUS NetJoinDomain(const char *server, -- cgit From d6659f8ac84d5b3f19fb16a739657240f835c358 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 20:08:45 +0100 Subject: In the local path of NetJoinDomain, try to get error string from libnetjoin. Guenther (This used to be commit 0f0f0e13022da584b77e850fec2cef6169e1ac28) --- source3/lib/netapi/joindomain.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index ceb7ca10d9..aa8ec6e0b5 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -78,6 +78,9 @@ static WERROR NetJoinDomainLocal(struct libnetapi_ctx *mem_ctx, r->in.modify_config = true; werr = libnet_Join(mem_ctx, r); + if (!W_ERROR_IS_OK(werr) && r->out.error_string) { + libnetapi_set_error_string(mem_ctx, r->out.error_string); + } TALLOC_FREE(r); return werr; -- cgit From 74fc0bf9e5f4fe21b80a4b6df144d780e1bb943a Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 20:10:47 +0100 Subject: In libnetapi example, use libnetapi_get_error_string(). Guenther (This used to be commit b624db92d61809a44881abbdd09dfa3a74ff7a88) --- source3/lib/netapi/examples/netdomjoin/netdomjoin.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/examples/netdomjoin/netdomjoin.c b/source3/lib/netapi/examples/netdomjoin/netdomjoin.c index 634d265597..a0ac0b1e56 100644 --- a/source3/lib/netapi/examples/netdomjoin/netdomjoin.c +++ b/source3/lib/netapi/examples/netdomjoin/netdomjoin.c @@ -104,7 +104,12 @@ int main(int argc, char **argv) password, join_flags); if (status != 0) { - printf("Join failed with: %s\n", libnetapi_errstr(ctx, status)); + const char *errstr = NULL; + errstr = libnetapi_get_error_string(ctx); + if (!errstr) { + errstr = libnetapi_errstr(ctx, status); + } + printf("Join failed with: %s\n", errstr); } else { printf("Successfully joined\n"); } -- cgit From 8d261ee580f7d589920eb405a68aec04e6cc8e7a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 6 Jan 2008 17:25:20 +0100 Subject: talloc_stackframe only needs 1 talloc (This used to be commit c0c2084d40b79e949dab7c68626aa665b9ea1a8e) --- source3/lib/talloc_stack.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/talloc_stack.c b/source3/lib/talloc_stack.c index e6e4ed321a..cc7ce3a518 100644 --- a/source3/lib/talloc_stack.c +++ b/source3/lib/talloc_stack.c @@ -41,16 +41,18 @@ static int talloc_stacksize; static TALLOC_CTX **talloc_stack; -static int talloc_pop(int *ptr) +static int talloc_pop(TALLOC_CTX *frame) { - int tos = *ptr; int i; - for (i=talloc_stacksize-1; i>=tos; i--) { + for (i=talloc_stacksize-1; i>0; i--) { + if (frame == talloc_stack[i]) { + break; + } talloc_free(talloc_stack[i]); } - talloc_stacksize = tos; + talloc_stacksize = i; return 0; } @@ -64,7 +66,6 @@ static int talloc_pop(int *ptr) TALLOC_CTX *talloc_stackframe(void) { TALLOC_CTX **tmp, *top; - int *cleanup; if (!(tmp = TALLOC_REALLOC_ARRAY(NULL, talloc_stack, TALLOC_CTX *, talloc_stacksize + 1))) { @@ -77,12 +78,7 @@ TALLOC_CTX *talloc_stackframe(void) goto fail; } - if (!(cleanup = talloc(top, int))) { - goto fail; - } - - *cleanup = talloc_stacksize; - talloc_set_destructor(cleanup, talloc_pop); + talloc_set_destructor(top, talloc_pop); talloc_stack[talloc_stacksize++] = top; -- cgit From 6dc988c918d7909b6eec052e6c3511467e9be697 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 7 Jan 2008 00:14:24 +0100 Subject: Change db_tdb_fetch_locked to use only one talloc (This used to be commit 921c8657e2eeb71d5b9ae2675255a852b26cc30d) --- source3/lib/dbwrap_tdb.c | 88 +++++++++++++++++++++++++++++------------------- 1 file changed, 53 insertions(+), 35 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c index b24fd0618a..cce987d789 100644 --- a/source3/lib/dbwrap_tdb.c +++ b/source3/lib/dbwrap_tdb.c @@ -43,33 +43,50 @@ static int db_tdb_record_destr(struct db_record* data) return 0; } -static struct db_record *db_tdb_fetch_locked(struct db_context *db, - TALLOC_CTX *mem_ctx, TDB_DATA key) -{ - struct db_tdb_ctx *ctx = talloc_get_type_abort(db->private_data, - struct db_tdb_ctx); +struct tdb_fetch_locked_state { + TALLOC_CTX *mem_ctx; struct db_record *result; - TDB_DATA value; +}; - result = TALLOC_P(mem_ctx, struct db_record); - if (result == NULL) { - DEBUG(0, ("talloc failed\n")); - return NULL; +static int db_tdb_fetchlock_parse(TDB_DATA key, TDB_DATA data, + void *private_data) +{ + struct tdb_fetch_locked_state *state = + (struct tdb_fetch_locked_state *)private_data; + + state->result = (struct db_record *)talloc_size( + state->mem_ctx, + sizeof(struct db_record) + key.dsize + data.dsize); + + if (state->result == NULL) { + return 0; } - result->key.dsize = key.dsize; - result->key.dptr = (uint8 *)talloc_memdup(result, key.dptr, key.dsize); - if (result->key.dptr == NULL) { - DEBUG(0, ("talloc failed\n")); - TALLOC_FREE(result); - return NULL; + state->result->key.dsize = key.dsize; + state->result->key.dptr = ((uint8 *)state->result) + + sizeof(struct db_record); + memcpy(state->result->key.dptr, key.dptr, key.dsize); + + state->result->value.dsize = data.dsize; + + if (data.dsize > 0) { + state->result->value.dptr = state->result->key.dptr + key.dsize; + memcpy(state->result->value.dptr, data.dptr, data.dsize); } + else { + state->result->value.dptr = NULL; + } + + return 0; +} - result->value.dptr = NULL; - result->value.dsize = 0; - result->private_data = talloc_reference(result, ctx); - result->store = db_tdb_store; - result->delete_rec = db_tdb_delete; +static struct db_record *db_tdb_fetch_locked(struct db_context *db, + TALLOC_CTX *mem_ctx, TDB_DATA key) +{ + struct db_tdb_ctx *ctx = talloc_get_type_abort(db->private_data, + struct db_tdb_ctx); + struct tdb_fetch_locked_state state; + int res; if (DEBUGLEVEL >= 10) { char *keystr = hex_encode(NULL, key.dptr, key.dsize); @@ -81,32 +98,33 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db, if (tdb_chainlock(ctx->wtdb->tdb, key) != 0) { DEBUG(3, ("tdb_chainlock failed\n")); - TALLOC_FREE(result); return NULL; } - talloc_set_destructor(result, db_tdb_record_destr); + state.mem_ctx = mem_ctx; + state.result = NULL; - value = tdb_fetch(ctx->wtdb->tdb, key); + res = tdb_parse_record(ctx->wtdb->tdb, key, db_tdb_fetchlock_parse, + &state); - if (value.dptr == NULL) { - return result; + if (state.result == NULL) { + db_tdb_fetchlock_parse(key, tdb_null, &state); } - result->value.dsize = value.dsize; - result->value.dptr = (uint8 *)talloc_memdup(result, value.dptr, - value.dsize); - if (result->value.dptr == NULL) { - DEBUG(3, ("talloc failed\n")); - TALLOC_FREE(result); + if (state.result == NULL) { + tdb_chainunlock(ctx->wtdb->tdb, key); return NULL; } - SAFE_FREE(value.dptr); + talloc_set_destructor(state.result, db_tdb_record_destr); - DEBUG(10, ("Allocated locked data 0x%p\n", result)); + state.result->private_data = talloc_reference(state.result, ctx); + state.result->store = db_tdb_store; + state.result->delete_rec = db_tdb_delete; - return result; + DEBUG(10, ("Allocated locked data 0x%p\n", state.result)); + + return state.result; } static int db_tdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, -- cgit From c3c19615c16a2a2dc7d3620d7117b9f261e5c35a Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Mon, 7 Jan 2008 00:41:26 +0100 Subject: make db_tdb_fetch use tdb_parse_record (This used to be commit 88d82d0623e71ae1ef4f8fdefba10e3a230ea526) --- source3/lib/dbwrap_tdb.c | 46 +++++++++++++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 13 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/dbwrap_tdb.c b/source3/lib/dbwrap_tdb.c index cce987d789..83a0d111aa 100644 --- a/source3/lib/dbwrap_tdb.c +++ b/source3/lib/dbwrap_tdb.c @@ -70,7 +70,7 @@ static int db_tdb_fetchlock_parse(TDB_DATA key, TDB_DATA data, state->result->value.dsize = data.dsize; if (data.dsize > 0) { - state->result->value.dptr = state->result->key.dptr + key.dsize; + state->result->value.dptr = state->result->key.dptr+key.dsize; memcpy(state->result->value.dptr, data.dptr, data.dsize); } else { @@ -127,29 +127,49 @@ static struct db_record *db_tdb_fetch_locked(struct db_context *db, return state.result; } +struct tdb_fetch_state { + TALLOC_CTX *mem_ctx; + int result; + TDB_DATA data; +}; + +static int db_tdb_fetch_parse(TDB_DATA key, TDB_DATA data, + void *private_data) +{ + struct tdb_fetch_state *state = + (struct tdb_fetch_state *)private_data; + + state->data.dptr = (uint8 *)talloc_memdup(state->mem_ctx, data.dptr, + data.dsize); + if (state->data.dptr == NULL) { + state->result = -1; + return 0; + } + + state->data.dsize = data.dsize; + return 0; +} + static int db_tdb_fetch(struct db_context *db, TALLOC_CTX *mem_ctx, TDB_DATA key, TDB_DATA *pdata) { struct db_tdb_ctx *ctx = talloc_get_type_abort( db->private_data, struct db_tdb_ctx); - TDB_DATA data; - - data = tdb_fetch(ctx->wtdb->tdb, key); + struct tdb_fetch_state state; - if (data.dptr == NULL) { - pdata->dptr = NULL; - pdata->dsize = 0; - return 0; - } + state.mem_ctx = mem_ctx; + state.result = 0; + state.data.dptr = NULL; + state.data.dsize = 0; - pdata->dptr = (uint8 *)talloc_memdup(mem_ctx, data.dptr, data.dsize); - SAFE_FREE(data.dptr); + tdb_parse_record(ctx->wtdb->tdb, key, db_tdb_fetch_parse, &state); - if (pdata->dptr == NULL) { + if (state.result == -1) { return -1; } - pdata->dsize = data.dsize; + + *pdata = state.data; return 0; } -- cgit From e3ea1e1391a10fb1f4708abab038c0cfc2b86b41 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Mon, 7 Jan 2008 22:48:19 +0100 Subject: Enable talloc reporting in libnetapi if DEVELOPER compiled. Guenther (This used to be commit 01e9151546a83e0c772a144efa85437ca0c8a307) --- source3/lib/netapi/netapi.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index d5527dc4ff..61b51909c9 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -39,6 +39,9 @@ NET_API_STATUS libnetapi_init(struct libnetapi_ctx **context) return NET_API_STATUS_SUCCESS; } +#ifdef DEVELOPER + talloc_enable_leak_report(); +#endif frame = talloc_stackframe(); ctx = talloc_zero(frame, struct libnetapi_ctx); -- cgit From 62e9d503d82d645cf29af643732ad97c0eb8b340 Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Mon, 7 Jan 2008 23:53:34 +0100 Subject: Remove redundant parameter fd from SMB_VFS_SYS_ACL_GET_FD(). Michael (This used to be commit 42663e8736e1a3dfb57e0aafdcbf5fec880da779) --- source3/lib/sysacls.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/sysacls.c b/source3/lib/sysacls.c index 3e61f42aa5..f23d03f706 100644 --- a/source3/lib/sysacls.c +++ b/source3/lib/sysacls.c @@ -364,9 +364,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, return posixacl_sys_acl_get_file(handle, path_p, type); } -SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd) +SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp) { - return posixacl_sys_acl_get_fd(handle, fsp, fd); + return posixacl_sys_acl_get_fd(handle, fsp); } int sys_acl_set_file(vfs_handle_struct *handle, @@ -395,9 +395,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, return aixacl_sys_acl_get_file(handle, path_p, type); } -SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd) +SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp) { - return aixacl_sys_acl_get_fd(handle, fsp, fd); + return aixacl_sys_acl_get_fd(handle, fsp); } int sys_acl_set_file(vfs_handle_struct *handle, @@ -426,9 +426,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, return tru64acl_sys_acl_get_file(handle, path_p, type); } -SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd) +SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp) { - return tru64acl_sys_acl_get_fd(handle, fsp, fd); + return tru64acl_sys_acl_get_fd(handle, fsp); } int sys_acl_set_file(vfs_handle_struct *handle, @@ -457,9 +457,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, return solarisacl_sys_acl_get_file(handle, path_p, type); } -SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd) +SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp) { - return solarisacl_sys_acl_get_fd(handle, fsp, fd); + return solarisacl_sys_acl_get_fd(handle, fsp); } int sys_acl_set_file(vfs_handle_struct *handle, @@ -488,9 +488,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, return hpuxacl_sys_acl_get_file(handle, path_p, type); } -SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd) +SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp) { - return hpuxacl_sys_acl_get_fd(handle, fsp, fd); + return hpuxacl_sys_acl_get_fd(handle, fsp); } int sys_acl_set_file(vfs_handle_struct *handle, @@ -519,9 +519,9 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, return irixacl_sys_acl_get_file(handle, path_p, type); } -SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd) +SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp) { - return irixacl_sys_acl_get_fd(handle, fsp, fd); + return irixacl_sys_acl_get_fd(handle, fsp); } int sys_acl_set_file(vfs_handle_struct *handle, @@ -555,7 +555,7 @@ SMB_ACL_T sys_acl_get_file(vfs_handle_struct *handle, return NULL; } -SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp, int fd) +SMB_ACL_T sys_acl_get_fd(vfs_handle_struct *handle, files_struct *fsp) { #ifdef ENOTSUP errno = ENOTSUP; -- cgit From 5921607f2647cec20a6bcebd17c5a0c53449c1ba Mon Sep 17 00:00:00 2001 From: Michael Adam Date: Tue, 8 Jan 2008 01:54:19 +0100 Subject: Remove redundant parameter fd from SMB_VFS_SYS_ACL_SET_FD(). Michael (This used to be commit 9296e93588c0e795cae770765050247ac1474a74) --- source3/lib/sysacls.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/sysacls.c b/source3/lib/sysacls.c index f23d03f706..9c1256ed65 100644 --- a/source3/lib/sysacls.c +++ b/source3/lib/sysacls.c @@ -3,7 +3,7 @@ Samba system utilities for ACL support. Copyright (C) Jeremy Allison 2000. Copyright (C) Volker Lendecke 2006 - Copyright (C) Michael Adam 2006 + Copyright (C) Michael Adam 2006,2008 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -376,9 +376,9 @@ int sys_acl_set_file(vfs_handle_struct *handle, } int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T acl_d) + SMB_ACL_T acl_d) { - return posixacl_sys_acl_set_fd(handle, fsp, fd, acl_d); + return posixacl_sys_acl_set_fd(handle, fsp, acl_d); } int sys_acl_delete_def_file(vfs_handle_struct *handle, @@ -407,9 +407,9 @@ int sys_acl_set_file(vfs_handle_struct *handle, } int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T acl_d) + SMB_ACL_T acl_d) { - return aixacl_sys_acl_set_fd(handle, fsp, fd, acl_d); + return aixacl_sys_acl_set_fd(handle, fsp, acl_d); } int sys_acl_delete_def_file(vfs_handle_struct *handle, @@ -438,9 +438,9 @@ int sys_acl_set_file(vfs_handle_struct *handle, } int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T acl_d) + SMB_ACL_T acl_d) { - return tru64acl_sys_acl_set_fd(handle, fsp, fd, acl_d); + return tru64acl_sys_acl_set_fd(handle, fsp, acl_d); } int sys_acl_delete_def_file(vfs_handle_struct *handle, @@ -469,9 +469,9 @@ int sys_acl_set_file(vfs_handle_struct *handle, } int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T acl_d) + SMB_ACL_T acl_d) { - return solarisacl_sys_acl_set_fd(handle, fsp, fd, acl_d); + return solarisacl_sys_acl_set_fd(handle, fsp, acl_d); } int sys_acl_delete_def_file(vfs_handle_struct *handle, @@ -500,9 +500,9 @@ int sys_acl_set_file(vfs_handle_struct *handle, } int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T acl_d) + SMB_ACL_T acl_d) { - return hpuxacl_sys_acl_set_fd(handle, fsp, fd, acl_d); + return hpuxacl_sys_acl_set_fd(handle, fsp, acl_d); } int sys_acl_delete_def_file(vfs_handle_struct *handle, @@ -531,9 +531,9 @@ int sys_acl_set_file(vfs_handle_struct *handle, } int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T acl_d) + SMB_ACL_T acl_d) { - return irixacl_sys_acl_set_fd(handle, fsp, fd, acl_d); + return irixacl_sys_acl_set_fd(handle, fsp, acl_d); } int sys_acl_delete_def_file(vfs_handle_struct *handle, @@ -577,7 +577,7 @@ int sys_acl_set_file(vfs_handle_struct *handle, } int sys_acl_set_fd(vfs_handle_struct *handle, files_struct *fsp, - int fd, SMB_ACL_T acl_d) + SMB_ACL_T acl_d) { #ifdef ENOTSUP errno = ENOTSUP; -- cgit From ab216a1b4ea585faa42be4908a24a475173683d2 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 8 Jan 2008 11:49:35 +0100 Subject: Fix crash bug when strequal is used too late in libnetapi_free. Guenther (This used to be commit ba2b8a310e1d6f78116350e24c17ae4db08b9bed) --- source3/lib/netapi/netapi.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 61b51909c9..3516105353 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -103,6 +103,14 @@ NET_API_STATUS libnetapi_getctx(struct libnetapi_ctx **ctx) NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) { + + if (ctx->krb5_cc_env) { + char *env = getenv(KRB5_ENV_CCNAME); + if (env && (strequal(ctx->krb5_cc_env, env))) { + unsetenv(KRB5_ENV_CCNAME); + } + } + gfree_names(); gfree_loadparm(); gfree_case_tables(); @@ -113,11 +121,6 @@ NET_API_STATUS libnetapi_free(struct libnetapi_ctx *ctx) secrets_shutdown(); regdb_close(); - if (ctx->krb5_cc_env && - (strequal(ctx->krb5_cc_env, getenv(KRB5_ENV_CCNAME)))) { - unsetenv(KRB5_ENV_CCNAME); - } - TALLOC_FREE(ctx); TALLOC_FREE(frame); -- cgit From a01dc30db7cb16c794f5daf23ad2df607f891626 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 8 Jan 2008 11:53:38 +0100 Subject: Add NetApiBufferFree() to libnetapi. Guenther (This used to be commit c49196954d38f0c2851abbfe25086cd6fe660a2e) --- source3/lib/netapi/netapi.c | 14 ++++++++++++++ source3/lib/netapi/netapi.h | 5 +++++ 2 files changed, 19 insertions(+) (limited to 'source3/lib') diff --git a/source3/lib/netapi/netapi.c b/source3/lib/netapi/netapi.c index 3516105353..d4cb3a9fe2 100644 --- a/source3/lib/netapi/netapi.c +++ b/source3/lib/netapi/netapi.c @@ -224,3 +224,17 @@ const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx) { return ctx->error_string; } + +/**************************************************************** +****************************************************************/ + +NET_API_STATUS NetApiBufferFree(void *buffer) +{ + if (!buffer) { + return W_ERROR_V(WERR_INSUFFICIENT_BUFFER); + } + + talloc_free(buffer); + + return NET_API_STATUS_SUCCESS; +} diff --git a/source3/lib/netapi/netapi.h b/source3/lib/netapi/netapi.h index 46dd8e1a24..4a40b32fc9 100644 --- a/source3/lib/netapi/netapi.h +++ b/source3/lib/netapi/netapi.h @@ -53,6 +53,11 @@ const char *libnetapi_get_error_string(struct libnetapi_ctx *ctx); /**************************************************************** ****************************************************************/ +NET_API_STATUS NetApiBufferFree(void *buffer); + +/**************************************************************** +****************************************************************/ + /* wkssvc */ NET_API_STATUS NetJoinDomain(const char *server, const char *domain, -- cgit From 200bba3ad6592952041daa9da9805941c6dd03ba Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 8 Jan 2008 11:54:51 +0100 Subject: Make name_buffer in NetGetJoinInformation() talloced. Guenther (This used to be commit 421905fb608df6736944ac21ac67abee24991521) --- source3/lib/netapi/joindomain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/joindomain.c b/source3/lib/netapi/joindomain.c index aa8ec6e0b5..e4fb63eebb 100644 --- a/source3/lib/netapi/joindomain.c +++ b/source3/lib/netapi/joindomain.c @@ -437,9 +437,9 @@ static WERROR NetGetJoinInformationLocal(struct libnetapi_ctx *ctx, uint16_t *name_type) { if ((lp_security() == SEC_ADS) && lp_realm()) { - *name_buffer = SMB_STRDUP(lp_realm()); + *name_buffer = talloc_strdup(ctx, lp_realm()); } else { - *name_buffer = SMB_STRDUP(lp_workgroup()); + *name_buffer = talloc_strdup(ctx, lp_workgroup()); } if (!*name_buffer) { return WERR_NOMEM; -- cgit From 67f2afe3c4cfd46aa20b7a7c568ac6b5ab16acb8 Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Tue, 8 Jan 2008 11:55:45 +0100 Subject: Correctly free buffers in netdomjoin-gui. Guenther (This used to be commit 04d78d4d9a8cffe44c927036038aef1d6d6b44b2) --- source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'source3/lib') diff --git a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c index 1e1681ba37..4a3588e9ab 100644 --- a/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c +++ b/source3/lib/netapi/examples/netdomjoin-gui/netdomjoin-gui.c @@ -249,6 +249,8 @@ static void callback_do_reboot(GtkWidget *widget, SAFE_FREE(buffer); state->name_type_new = type; #endif + NetApiBufferFree((void *)buffer); + gtk_label_set_text(GTK_LABEL(state->label_current_name_buffer), state->name_buffer_new); if (state->name_type_new == NetSetupDomainName) { @@ -1292,8 +1294,12 @@ static int initialize_join_state(struct join_state *state, if (status) { return status; } - state->name_buffer_initial = (char *)buffer; + state->name_buffer_initial = strdup(buffer); + if (!state->name_buffer_initial) { + return -1; + } state->name_type_initial = type; + NetApiBufferFree((void *)buffer); } { @@ -1311,6 +1317,7 @@ static int initialize_join_state(struct join_state *state, if (!state->comment) { return -1; } + NetApiBufferFree(buffer); } #if 0 { -- cgit