svn commit: samba r17343 - in branches/SAMBA_4_0/source/auth: .

metze at samba.org metze at samba.org
Mon Jul 31 15:42:27 GMT 2006


Author: metze
Date: 2006-07-31 15:42:27 +0000 (Mon, 31 Jul 2006)
New Revision: 17343

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=17343

Log:
let auth_winbind use IRPC against the winbind task.
(currently this uses the sync IRPC_CALL(), but when
auth_check_password will be async for the backend this will
change to IRPC_CALL_SEND()

the old module which uses the samba3 protocol against winbind
is still available as 'winbind_samba3'

metze
Modified:
   branches/SAMBA_4_0/source/auth/auth_winbind.c
   branches/SAMBA_4_0/source/auth/config.mk


Changeset:
Modified: branches/SAMBA_4_0/source/auth/auth_winbind.c
===================================================================
--- branches/SAMBA_4_0/source/auth/auth_winbind.c	2006-07-31 15:38:18 UTC (rev 17342)
+++ branches/SAMBA_4_0/source/auth/auth_winbind.c	2006-07-31 15:42:27 UTC (rev 17343)
@@ -26,6 +26,8 @@
 #include "auth/auth.h"
 #include "nsswitch/winbind_client.h"
 #include "librpc/gen_ndr/ndr_netlogon.h"
+#include "librpc/gen_ndr/ndr_winbind.h"
+#include "lib/messaging/irpc.h"
 
 static NTSTATUS get_info3_from_ndr(TALLOC_CTX *mem_ctx, struct winbindd_response *response, struct netr_SamInfo3 *info3)
 {
@@ -58,11 +60,14 @@
 	return NT_STATUS_OK;
 }
 
-/* Authenticate a user with a challenge/response */
-static NTSTATUS winbind_check_password(struct auth_method_context *ctx,
-				       TALLOC_CTX *mem_ctx,
-				       const struct auth_usersupplied_info *user_info, 
-				       struct auth_serversupplied_info **server_info)
+/*
+ Authenticate a user with a challenge/response
+ using the samba3 winbind protocol
+*/
+static NTSTATUS winbind_check_password_samba3(struct auth_method_context *ctx,
+					      TALLOC_CTX *mem_ctx,
+					      const struct auth_usersupplied_info *user_info, 
+					      struct auth_serversupplied_info **server_info)
 {
 	struct winbindd_request request;
 	struct winbindd_response response;
@@ -138,6 +143,111 @@
         return nt_status;
 }
 
+struct winbind_check_password_state {
+	struct winbind_SamLogon req;
+};
+
+/*
+ Authenticate a user with a challenge/response
+ using IRPC to the winbind task
+*/
+static NTSTATUS winbind_check_password(struct auth_method_context *ctx,
+				       TALLOC_CTX *mem_ctx,
+				       const struct auth_usersupplied_info *user_info, 
+				       struct auth_serversupplied_info **server_info)
+{
+	NTSTATUS status;
+	uint32_t *winbind_servers;
+	struct winbind_check_password_state *s;
+	const struct auth_usersupplied_info *user_info_new;
+	struct netr_IdentityInfo *identity_info;
+
+	winbind_servers = irpc_servers_byname(ctx->auth_ctx->msg_ctx, "winbind_server");
+	if ((winbind_servers == NULL) || (winbind_servers[0] == 0)) {
+		DEBUG(0, ("Winbind authentication for [%s]\\[%s] failed, " 
+			  "no winbind_server running!\n",
+			  user_info->client.domain_name, user_info->client.account_name));
+		return NT_STATUS_NO_LOGON_SERVERS;
+	}
+
+	s = talloc(mem_ctx, struct winbind_check_password_state);
+	NT_STATUS_HAVE_NO_MEMORY(s);
+
+	if (user_info->flags & USER_INFO_INTERACTIVE_LOGON) {
+		struct netr_PasswordInfo *password_info;
+
+		status = encrypt_user_info(s, ctx->auth_ctx, AUTH_PASSWORD_HASH,
+					   user_info, &user_info_new);
+		NT_STATUS_NOT_OK_RETURN(status);
+		user_info = user_info_new;
+
+		password_info = talloc(s, struct netr_PasswordInfo);
+		NT_STATUS_HAVE_NO_MEMORY(password_info);
+
+		password_info->lmpassword = *user_info->password.hash.lanman;
+		password_info->ntpassword = *user_info->password.hash.nt;
+
+		identity_info = &password_info->identity_info;
+		s->req.in.logon_level	= 1;
+		s->req.in.logon.password= password_info;
+	} else {
+		struct netr_NetworkInfo *network_info;
+		const uint8_t *challenge;
+
+		status = encrypt_user_info(s, ctx->auth_ctx, AUTH_PASSWORD_RESPONSE,
+					   user_info, &user_info_new);
+		NT_STATUS_NOT_OK_RETURN(status);
+		user_info = user_info_new;
+
+		network_info = talloc(s, struct netr_NetworkInfo);
+		NT_STATUS_HAVE_NO_MEMORY(network_info);
+
+		status = auth_get_challenge(ctx->auth_ctx, &challenge);
+		NT_STATUS_NOT_OK_RETURN(status);
+
+		memcpy(network_info->challenge, challenge, sizeof(network_info->challenge));
+
+		network_info->nt.length = user_info->password.response.nt.length;
+		network_info->nt.data	= user_info->password.response.nt.data;
+
+		network_info->nt.length = user_info->password.response.lanman.length;
+		network_info->nt.data	= user_info->password.response.lanman.data;
+
+		identity_info = &network_info->identity_info;
+		s->req.in.logon_level	= 2;
+		s->req.in.logon.network = network_info;
+	}
+
+	identity_info->domain_name.string	= user_info->client.domain_name;
+	identity_info->parameter_control	= user_info->logon_parameters; /* see MSV1_0_* */
+	identity_info->logon_id_low		= 0;
+	identity_info->logon_id_high		= 0;
+	identity_info->account_name.string	= user_info->client.account_name;
+	identity_info->workstation.string	= user_info->workstation_name;
+
+	s->req.in.validation_level	= 3;
+	status = IRPC_CALL(ctx->auth_ctx->msg_ctx, winbind_servers[0],
+			   winbind, WINBIND_SAMLOGON,
+			   &s->req, s);
+	NT_STATUS_NOT_OK_RETURN(status);
+
+	status = make_server_info_netlogon_validation(mem_ctx,
+						      user_info->client.account_name,
+						      s->req.in.validation_level,
+						      &s->req.out.validation,
+						      server_info);
+	NT_STATUS_NOT_OK_RETURN(status);
+
+	return NT_STATUS_OK;
+}
+
+static const struct auth_operations winbind_samba3_ops = {
+	.name		= "winbind_samba3",
+	.get_challenge	= auth_get_challenge_not_implemented,
+	.want_check	= winbind_want_check,
+	.check_password	= winbind_check_password_samba3
+};
+
 static const struct auth_operations winbind_ops = {
 	.name		= "winbind",
 	.get_challenge	= auth_get_challenge_not_implemented,
@@ -149,10 +259,17 @@
 {
 	NTSTATUS ret;
 
+	ret = auth_register(&winbind_samba3_ops);
+	if (!NT_STATUS_IS_OK(ret)) {
+		DEBUG(0,("Failed to register 'winbind_samba3' auth backend!\n"));
+		return ret;
+	}
+
 	ret = auth_register(&winbind_ops);
 	if (!NT_STATUS_IS_OK(ret)) {
 		DEBUG(0,("Failed to register 'winbind' auth backend!\n"));
 		return ret;
 	}
-	return ret;
+
+	return NT_STATUS_OK;
 }

Modified: branches/SAMBA_4_0/source/auth/config.mk
===================================================================
--- branches/SAMBA_4_0/source/auth/config.mk	2006-07-31 15:38:18 UTC (rev 17342)
+++ branches/SAMBA_4_0/source/auth/config.mk	2006-07-31 15:42:27 UTC (rev 17343)
@@ -36,7 +36,7 @@
 INIT_FUNCTION = auth_winbind_init
 SUBSYSTEM = auth
 OBJ_FILES = auth_winbind.o
-PUBLIC_DEPENDENCIES = LIBWINBIND-CLIENT NDR_NETLOGON LIBNDR
+PUBLIC_DEPENDENCIES = NDR_WINBIND MESSAGING LIBWINBIND-CLIENT
 # End MODULE auth_winbind
 #######################
 



More information about the samba-cvs mailing list