summaryrefslogtreecommitdiff
path: root/source3/auth/auth_compat.c
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2002-01-20 08:58:21 +0000
committerAndrew Bartlett <abartlet@samba.org>2002-01-20 08:58:21 +0000
commit2d06adc3f02ba18b832886bf4cda95679b13a39b (patch)
treee9047f631d95201d32dab38162dab757c6e185cb /source3/auth/auth_compat.c
parent8d2d97b17647d4a9c6bc39cb87ae99dc3c86cc06 (diff)
downloadsamba-2d06adc3f02ba18b832886bf4cda95679b13a39b.tar.gz
samba-2d06adc3f02ba18b832886bf4cda95679b13a39b.tar.bz2
samba-2d06adc3f02ba18b832886bf4cda95679b13a39b.zip
Add a touch of 'const' to some auth components, and move the simple plaintext
password check into its own helper funciton. (This will allow it to be called from other places). Andrew Bartlett (This used to be commit 9e96f438057da21254f40facdd9a31dd20652f35)
Diffstat (limited to 'source3/auth/auth_compat.c')
-rw-r--r--source3/auth/auth_compat.c53
1 files changed, 31 insertions, 22 deletions
diff --git a/source3/auth/auth_compat.c b/source3/auth/auth_compat.c
index 28a9780d3f..8cf304a071 100644
--- a/source3/auth/auth_compat.c
+++ b/source3/auth/auth_compat.c
@@ -31,8 +31,34 @@ SMB hash
return True if the password is correct, False otherwise
****************************************************************************/
-static NTSTATUS pass_check_smb(char *smb_name,
- char *domain,
+NTSTATUS check_plaintext_password(const char *smb_name, DATA_BLOB plaintext_password, auth_serversupplied_info **server_info)
+{
+ struct auth_context *plaintext_auth_context = NULL;
+ auth_usersupplied_info *user_info = NULL;
+ const uint8 *chal;
+ NTSTATUS nt_status;
+ if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(&plaintext_auth_context))) {
+ return nt_status;
+ }
+
+ chal = plaintext_auth_context->get_ntlm_challenge(plaintext_auth_context);
+
+ if (!make_user_info_for_reply(&user_info,
+ smb_name, lp_workgroup(), chal,
+ plaintext_password)) {
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ nt_status = plaintext_auth_context->check_ntlm_password(plaintext_auth_context,
+ user_info, server_info);
+
+ (plaintext_auth_context->free)(&plaintext_auth_context);
+ free_user_info(&user_info);
+ return nt_status;
+}
+
+static NTSTATUS pass_check_smb(const char *smb_name,
+ const char *domain,
DATA_BLOB lm_pwd,
DATA_BLOB nt_pwd,
DATA_BLOB plaintext_password,
@@ -40,37 +66,20 @@ static NTSTATUS pass_check_smb(char *smb_name,
{
NTSTATUS nt_status;
- auth_usersupplied_info *user_info = NULL;
extern struct auth_context *negprot_global_auth_context;
auth_serversupplied_info *server_info = NULL;
if (encrypted) {
+ auth_usersupplied_info *user_info = NULL;
make_user_info_for_reply_enc(&user_info, smb_name,
domain,
lm_pwd,
nt_pwd);
nt_status = negprot_global_auth_context->check_ntlm_password(negprot_global_auth_context,
user_info, &server_info);
+ free_user_info(&user_info);
} else {
- struct auth_context *plaintext_auth_context = NULL;
- const uint8 *chal;
- if (!NT_STATUS_IS_OK(nt_status = make_auth_context_subsystem(&plaintext_auth_context))) {
- return nt_status;
- }
-
- chal = plaintext_auth_context->get_ntlm_challenge(plaintext_auth_context);
-
- if (!make_user_info_for_reply(&user_info,
- smb_name, domain, chal,
- plaintext_password)) {
- return NT_STATUS_NO_MEMORY;
- }
-
- nt_status = plaintext_auth_context->check_ntlm_password(plaintext_auth_context,
- user_info, &server_info);
-
- (plaintext_auth_context->free)(&plaintext_auth_context);
+ nt_status = check_plaintext_password(smb_name, plaintext_password, &server_info);
}
- free_user_info(&user_info);
free_server_info(&server_info);
return nt_status;
}