auth/gensec: fix gensec_update() with ev == NULL.
authorStefan Metzmacher <metze@samba.org>
Fri, 13 Dec 2013 09:00:24 +0000 (10:00 +0100)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 26 Mar 2014 23:36:31 +0000 (00:36 +0100)
In future we should remove the tevent_context argument from
gensec_update() completely!

If we have sane backends we should also remove the
tevent_loop_allow_nesting() call again!
t
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
auth/gensec/gensec.c

index 26e3ea5b5d620c3163d75cdab37349724be080b0..a95a6cc80c70796f17d1e9657e6855eda1aaf2a6 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "includes.h"
 #include "system/network.h"
+#define TEVENT_DEPRECATED 1
 #include <tevent.h>
 #include "lib/tsocket/tsocket.h"
 #include "lib/util/tevent_ntstatus.h"
@@ -225,8 +226,25 @@ _PUBLIC_ NTSTATUS gensec_update(struct gensec_security *gensec_security, TALLOC_
 
        if (ops->update_send == NULL) {
 
+               if (ev == NULL) {
+                       frame = talloc_stackframe();
+
+                       ev = samba_tevent_context_init(frame);
+                       if (ev == NULL) {
+                               status = NT_STATUS_NO_MEMORY;
+                               goto fail;
+                       }
+
+                       /*
+                        * TODO: remove this hack once the backends
+                        * are fixed.
+                        */
+                       tevent_loop_allow_nesting(ev);
+               }
+
                status = ops->update(gensec_security, out_mem_ctx,
                                     ev, in, out);
+               TALLOC_FREE(frame);
                if (!NT_STATUS_IS_OK(status)) {
                        return status;
                }
@@ -271,6 +289,20 @@ _PUBLIC_ NTSTATUS gensec_update(struct gensec_security *gensec_security, TALLOC_
 
        frame = talloc_stackframe();
 
+       if (ev == NULL) {
+               ev = samba_tevent_context_init(frame);
+               if (ev == NULL) {
+                       status = NT_STATUS_NO_MEMORY;
+                       goto fail;
+               }
+
+               /*
+                * TODO: remove this hack once the backends
+                * are fixed.
+                */
+               tevent_loop_allow_nesting(ev);
+       }
+
        subreq = ops->update_send(frame, ev, gensec_security, in);
        if (subreq == NULL) {
                status = NT_STATUS_NO_MEMORY;