From 1d6b98cdab4f0a400673cf967225214e858ab1ee Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 24 Jul 2017 13:10:30 -0700 Subject: [PATCH] s3: rpcclient: Split out initialization and free of event context. Allows us to control shutdown. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12932 Signed-off-by: Jeremy Allison Reviewed-by: Andrew Bartlett --- source3/rpcclient/rpcclient.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source3/rpcclient/rpcclient.c b/source3/rpcclient/rpcclient.c index be7769672c0..835b288ee20 100644 --- a/source3/rpcclient/rpcclient.c +++ b/source3/rpcclient/rpcclient.c @@ -948,6 +948,7 @@ out_free: const char *binding_string = NULL; const char *host; int signing_state = SMB_SIGNING_IPC_DEFAULT; + struct tevent_context *ev_ctx = NULL; /* make sure the vars that get altered (4th field) are in a fixed location or certain compilers complain */ @@ -1013,8 +1014,15 @@ out_free: poptFreeContext(pc); popt_burn_cmdline_password(argc, argv); + ev_ctx = samba_tevent_context_init(frame); + if (ev_ctx == NULL) { + fprintf(stderr, "Could not init event context\n"); + result = 1; + goto done; + } + nt_status = messaging_init_client(talloc_autofree_context(), - samba_tevent_context_init(talloc_autofree_context()), + ev_ctx, &rpcclient_msg_ctx); if (geteuid() != 0 && NT_STATUS_EQUAL(nt_status, NT_STATUS_ACCESS_DENIED)) { @@ -1246,6 +1254,7 @@ done: cli_shutdown(cli); } popt_free_cmdline_auth_info(); + TALLOC_FREE(ev_ctx); TALLOC_FREE(frame); return result; }