From ab597b9a47102e111a426640ac3ab32aa291687b Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 3 Apr 2017 18:16:02 +0000 Subject: s4: server: Use state as the talloc context for open_schannel_session_store. Ensure it's freed on all error paths. Signed-off-by: Jeremy Allison Reviewed-by: Volker Lendecke Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Mon Apr 17 23:10:06 CEST 2017 on sn-devel-144 --- source4/smbd/server.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'source4/smbd') diff --git a/source4/smbd/server.c b/source4/smbd/server.c index 22b22a79fd9..fdc36dec129 100644 --- a/source4/smbd/server.c +++ b/source4/smbd/server.c @@ -463,8 +463,9 @@ static int binary_smbd_main(const char *binary_name, pidfile_create(lpcfg_pid_directory(cmdline_lp_ctx), binary_name); if (lpcfg_server_role(cmdline_lp_ctx) == ROLE_ACTIVE_DIRECTORY_DC) { - if (!open_schannel_session_store(talloc_autofree_context(), + if (!open_schannel_session_store(state, cmdline_lp_ctx)) { + TALLOC_FREE(state); exit_daemon("Samba cannot open schannel store " "for secured NETLOGON operations.", EACCES); } @@ -472,6 +473,7 @@ static int binary_smbd_main(const char *binary_name, /* make sure we won't go through nss_winbind */ if (!winbind_off()) { + TALLOC_FREE(state); exit_daemon("Samba failed to disable recusive " "winbindd calls.", EACCES); } @@ -492,6 +494,7 @@ static int binary_smbd_main(const char *binary_name, state->event_ctx = s4_event_context_init(state); if (state->event_ctx == NULL) { + TALLOC_FREE(state); exit_daemon("Initializing event context failed", EACCES); } @@ -511,6 +514,7 @@ static int binary_smbd_main(const char *binary_name, #endif if (fstat(0, &st) != 0) { + TALLOC_FREE(state); exit_daemon("Samba failed to set standard input handler", ENOTTY); } @@ -523,6 +527,7 @@ static int binary_smbd_main(const char *binary_name, server_stdin_handler, state); if (fde == NULL) { + TALLOC_FREE(state); exit_daemon("Initializing stdin failed", ENOMEM); } } @@ -538,6 +543,7 @@ static int binary_smbd_main(const char *binary_name, max_runtime_handler, state); if (te == NULL) { + TALLOC_FREE(state); exit_daemon("Maxruntime handler failed", ENOMEM); } } @@ -549,6 +555,7 @@ static int binary_smbd_main(const char *binary_name, sigterm_signal_handler, state); if (se == NULL) { + TALLOC_FREE(state); exit_daemon("Initialize SIGTERM handler failed", ENOMEM); } @@ -576,6 +583,7 @@ static int binary_smbd_main(const char *binary_name, status = setup_parent_messaging(state, cmdline_lp_ctx); if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(state); exit_daemon("Samba failed to setup parent messaging", NT_STATUS_V(status)); } @@ -585,6 +593,7 @@ static int binary_smbd_main(const char *binary_name, status = server_service_startup(state->event_ctx, cmdline_lp_ctx, model, lpcfg_server_services(cmdline_lp_ctx)); if (!NT_STATUS_IS_OK(status)) { + TALLOC_FREE(state); exit_daemon("Samba failed to start services", NT_STATUS_V(status)); } -- cgit v1.2.1