s3: Remove a pointless else branch
[nivanova/samba-autobuild/.git] / source3 / libsmb / ntlmssp_wrap.c
index a470444054704aa8a60f9ed081b23f43b6aa5263..c0b130790544dd738dbb9e16d0a0929dd275f8f1 100644 (file)
 
 #include "includes.h"
 #include "auth/ntlmssp/ntlmssp.h"
-#include "ntlmssp_wrap.h"
+#include "auth/ntlmssp/ntlmssp_private.h"
+#include "auth_generic.h"
 #include "auth/gensec/gensec.h"
 #include "auth/credentials/credentials.h"
 #include "librpc/rpc/dcerpc.h"
 #include "lib/param/param.h"
 
-NTSTATUS auth_ntlmssp_set_username(struct auth_ntlmssp_state *ans,
-                                  const char *user)
-{
-       cli_credentials_set_username(ans->credentials, user, CRED_SPECIFIED);
-       return NT_STATUS_OK;
-}
-
-NTSTATUS auth_ntlmssp_set_domain(struct auth_ntlmssp_state *ans,
-                                const char *domain)
-{
-       cli_credentials_set_domain(ans->credentials, domain, CRED_SPECIFIED);
-       return NT_STATUS_OK;
-}
-
-NTSTATUS auth_ntlmssp_set_password(struct auth_ntlmssp_state *ans,
-                                  const char *password)
-{
-       cli_credentials_set_password(ans->credentials, password, CRED_SPECIFIED);
-       return NT_STATUS_OK;
-}
-
-void auth_ntlmssp_want_feature(struct auth_ntlmssp_state *ans, uint32_t feature)
-{
-       if (feature & NTLMSSP_FEATURE_SESSION_KEY) {
-               gensec_want_feature(ans->gensec_security, GENSEC_FEATURE_SESSION_KEY);
-       }
-       if (feature & NTLMSSP_FEATURE_SIGN) {
-               gensec_want_feature(ans->gensec_security, GENSEC_FEATURE_SIGN);
-       }
-       if (feature & NTLMSSP_FEATURE_SEAL) {
-               gensec_want_feature(ans->gensec_security, GENSEC_FEATURE_SEAL);
-       }
-}
-
-DATA_BLOB auth_ntlmssp_get_session_key(struct auth_ntlmssp_state *ans, TALLOC_CTX *mem_ctx)
-{
-       DATA_BLOB session_key;
-       NTSTATUS status = gensec_session_key(ans->gensec_security, mem_ctx, &session_key);
-       if (NT_STATUS_IS_OK(status)) {
-               return session_key;
-       } else {
-               return data_blob_null;
-       }
-}
-
 static NTSTATUS gensec_ntlmssp3_client_update(struct gensec_security *gensec_security,
                                              TALLOC_CTX *out_mem_ctx,
                                              struct tevent_context *ev,
@@ -156,7 +112,7 @@ static const char *gensec_ntlmssp3_client_oids[] = {
        NULL
 };
 
-static const struct gensec_security_ops gensec_ntlmssp3_client_ops = {
+const struct gensec_security_ops gensec_ntlmssp3_client_ops = {
        .name           = "ntlmssp3_client",
        .sasl_name      = GENSEC_SASL_NAME_NTLMSSP, /* "NTLM" */
        .auth_type      = DCERPC_AUTH_TYPE_NTLMSSP,
@@ -176,76 +132,3 @@ static const struct gensec_security_ops gensec_ntlmssp3_client_ops = {
        .enabled        = true,
        .priority       = GENSEC_NTLMSSP
 };
-
-NTSTATUS auth_ntlmssp_client_prepare(TALLOC_CTX *mem_ctx, struct auth_ntlmssp_state **auth_ntlmssp_state)
-{
-       struct auth_ntlmssp_state *ans;
-       NTSTATUS nt_status;
-
-       struct gensec_settings *gensec_settings;
-       struct loadparm_context *lp_ctx;
-
-       ans = talloc_zero(mem_ctx, struct auth_ntlmssp_state);
-       if (!ans) {
-               DEBUG(0,("auth_ntlmssp_start: talloc failed!\n"));
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       lp_ctx = loadparm_init_s3(ans, loadparm_s3_context());
-       if (lp_ctx == NULL) {
-               DEBUG(10, ("loadparm_init_s3 failed\n"));
-               TALLOC_FREE(ans);
-               return NT_STATUS_INVALID_SERVER_STATE;
-       }
-       
-       gensec_settings = lpcfg_gensec_settings(ans, lp_ctx);
-       if (lp_ctx == NULL) {
-               DEBUG(10, ("lpcfg_gensec_settings failed\n"));
-               TALLOC_FREE(ans);
-               return NT_STATUS_NO_MEMORY;
-       }
-       
-       nt_status = gensec_client_start(ans, &ans->gensec_security, gensec_settings);
-       
-       if (!NT_STATUS_IS_OK(nt_status)) {
-               TALLOC_FREE(ans);
-               return nt_status;
-       }
-
-       ans->credentials = cli_credentials_init(ans);
-       if (!ans->credentials) {
-               TALLOC_FREE(ans);
-               return NT_STATUS_NO_MEMORY;
-       }
-
-       cli_credentials_guess(ans->credentials, lp_ctx);
-
-       talloc_unlink(ans, lp_ctx);
-       talloc_unlink(ans, gensec_settings);
-
-       *auth_ntlmssp_state = ans;
-       return NT_STATUS_OK;
-}
-
-NTSTATUS auth_ntlmssp_client_start(struct auth_ntlmssp_state *ans)
-{
-       NTSTATUS status;
-
-       /* Transfer the credentials to gensec */
-       status = gensec_set_credentials(ans->gensec_security, ans->credentials);
-       if (!NT_STATUS_IS_OK(status)) {
-               DEBUG(1, ("Failed to set GENSEC credentials: %s\n", 
-                         nt_errstr(status)));
-               return status;
-       }
-       talloc_unlink(ans, ans->credentials);
-       ans->credentials = NULL;
-
-       status = gensec_start_mech_by_ops(ans->gensec_security,
-                                         &gensec_ntlmssp3_client_ops);
-       if (!NT_STATUS_IS_OK(status)) {
-               return status;
-       }
-
-       return NT_STATUS_OK;
-}