Fix Samba4 build errors with common libcli/samsync
[ira/wip.git] / source4 / auth / ntlmssp / ntlmssp.c
index f957ac9dbd373b7d66a26e0c25823a8f723c0179..1388ad4a2242fa229bd5c5ccffe365814320eb07 100644 (file)
 
 #include "includes.h"
 #include "auth/ntlmssp/ntlmssp.h"
-#include "auth/ntlmssp/msrpc_parse.h"
+#include "../libcli/auth/libcli_auth.h"
 #include "librpc/gen_ndr/ndr_dcerpc.h"
 #include "auth/credentials/credentials.h"
 #include "auth/gensec/gensec.h"
+#include "auth/gensec/gensec_proto.h"
 #include "auth/auth.h"
+#include "auth/ntlm/auth_proto.h"
+#include "param/param.h"
 
 /**
  * Callbacks for NTLMSSP - for both client and server operating modes
@@ -231,6 +234,10 @@ NTSTATUS gensec_ntlmssp_session_key(struct gensec_security *gensec_security,
 {
        struct gensec_ntlmssp_state *gensec_ntlmssp_state = (struct gensec_ntlmssp_state *)gensec_security->private_data;
 
+       if (gensec_ntlmssp_state->expected_state != NTLMSSP_DONE) {
+               return NT_STATUS_NO_USER_SESSION_KEY;
+       }
+
        if (!gensec_ntlmssp_state->session_key.data) {
                return NT_STATUS_NO_USER_SESSION_KEY;
        }
@@ -423,12 +430,10 @@ static const struct gensec_security_ops gensec_ntlmssp_security_ops = {
 };
 
 
-NTSTATUS gensec_ntlmssp_init(void)
+_PUBLIC_ NTSTATUS gensec_ntlmssp_init(void)
 {
        NTSTATUS ret;
 
-       auth_init();
-
        ret = gensec_register(&gensec_ntlmssp_security_ops);
        if (!NT_STATUS_IS_OK(ret)) {
                DEBUG(0,("Failed to register '%s' gensec backend!\n",