summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/Makefile.in1
-rw-r--r--source3/auth/auth_util.c108
-rw-r--r--source3/auth/user_info.c131
-rw-r--r--source3/include/proto.h14
4 files changed, 146 insertions, 108 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index c783777ed3..4de937aacd 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -766,6 +766,7 @@ AUTH_NETLOGOND_OBJ = auth/auth_netlogond.o
AUTH_OBJ = auth/auth.o @AUTH_STATIC@ auth/auth_util.o auth/token_util.o \
auth/server_info.o \
auth/server_info_sam.o \
+ auth/user_info.o \
auth/auth_compat.o auth/auth_ntlmssp.o \
$(PLAINTEXT_AUTH_OBJ) $(SLCACHE_OBJ) $(DCUTIL_OBJ)
diff --git a/source3/auth/auth_util.c b/source3/auth/auth_util.c
index 0e94fd9dd4..5e39dca60a 100644
--- a/source3/auth/auth_util.c
+++ b/source3/auth/auth_util.c
@@ -104,87 +104,6 @@ static int _smb_create_user(const char *domain, const char *unix_username, const
}
/****************************************************************************
- Create an auth_usersupplied_data structure
-****************************************************************************/
-
-static NTSTATUS make_user_info(struct auth_usersupplied_info **user_info,
- const char *smb_name,
- const char *internal_username,
- const char *client_domain,
- const char *domain,
- const char *wksta_name,
- DATA_BLOB *lm_pwd, DATA_BLOB *nt_pwd,
- DATA_BLOB *lm_interactive_pwd, DATA_BLOB *nt_interactive_pwd,
- DATA_BLOB *plaintext,
- bool encrypted)
-{
-
- DEBUG(5,("attempting to make a user_info for %s (%s)\n", internal_username, smb_name));
-
- *user_info = SMB_MALLOC_P(struct auth_usersupplied_info);
- if (*user_info == NULL) {
- DEBUG(0,("malloc failed for user_info (size %lu)\n", (unsigned long)sizeof(*user_info)));
- return NT_STATUS_NO_MEMORY;
- }
-
- ZERO_STRUCTP(*user_info);
-
- DEBUG(5,("making strings for %s's user_info struct\n", internal_username));
-
- (*user_info)->smb_name = SMB_STRDUP(smb_name);
- if ((*user_info)->smb_name == NULL) {
- free_user_info(user_info);
- return NT_STATUS_NO_MEMORY;
- }
-
- (*user_info)->internal_username = SMB_STRDUP(internal_username);
- if ((*user_info)->internal_username == NULL) {
- free_user_info(user_info);
- return NT_STATUS_NO_MEMORY;
- }
-
- (*user_info)->domain = SMB_STRDUP(domain);
- if ((*user_info)->domain == NULL) {
- free_user_info(user_info);
- return NT_STATUS_NO_MEMORY;
- }
-
- (*user_info)->client_domain = SMB_STRDUP(client_domain);
- if ((*user_info)->client_domain == NULL) {
- free_user_info(user_info);
- return NT_STATUS_NO_MEMORY;
- }
-
- (*user_info)->wksta_name = SMB_STRDUP(wksta_name);
- if ((*user_info)->wksta_name == NULL) {
- free_user_info(user_info);
- return NT_STATUS_NO_MEMORY;
- }
-
- DEBUG(5,("making blobs for %s's user_info struct\n", internal_username));
-
- if (lm_pwd)
- (*user_info)->lm_resp = data_blob(lm_pwd->data, lm_pwd->length);
- if (nt_pwd)
- (*user_info)->nt_resp = data_blob(nt_pwd->data, nt_pwd->length);
- if (lm_interactive_pwd)
- (*user_info)->lm_interactive_pwd = data_blob(lm_interactive_pwd->data, lm_interactive_pwd->length);
- if (nt_interactive_pwd)
- (*user_info)->nt_interactive_pwd = data_blob(nt_interactive_pwd->data, nt_interactive_pwd->length);
-
- if (plaintext)
- (*user_info)->plaintext_password = data_blob(plaintext->data, plaintext->length);
-
- (*user_info)->encrypted = encrypted;
-
- (*user_info)->logon_parameters = 0;
-
- DEBUG(10,("made an %sencrypted user_info for %s (%s)\n", encrypted ? "":"un" , internal_username, smb_name));
-
- return NT_STATUS_OK;
-}
-
-/****************************************************************************
Create an auth_usersupplied_data structure after appropriate mapping.
****************************************************************************/
@@ -1607,33 +1526,6 @@ NTSTATUS make_server_info_wbcAuthUserInfo(TALLOC_CTX *mem_ctx,
return NT_STATUS_OK;
}
-/***************************************************************************
- Free a user_info struct
-***************************************************************************/
-
-void free_user_info(struct auth_usersupplied_info **user_info)
-{
- DEBUG(5,("attempting to free (and zero) a user_info structure\n"));
- if (*user_info != NULL) {
- if ((*user_info)->smb_name) {
- DEBUG(10,("structure was created for %s\n",
- (*user_info)->smb_name));
- }
- SAFE_FREE((*user_info)->smb_name);
- SAFE_FREE((*user_info)->internal_username);
- SAFE_FREE((*user_info)->client_domain);
- SAFE_FREE((*user_info)->domain);
- SAFE_FREE((*user_info)->wksta_name);
- data_blob_free(&(*user_info)->lm_resp);
- data_blob_free(&(*user_info)->nt_resp);
- data_blob_clear_free(&(*user_info)->lm_interactive_pwd);
- data_blob_clear_free(&(*user_info)->nt_interactive_pwd);
- data_blob_clear_free(&(*user_info)->plaintext_password);
- ZERO_STRUCT(**user_info);
- }
- SAFE_FREE(*user_info);
-}
-
/**
* Verify whether or not given domain is trusted.
*
diff --git a/source3/auth/user_info.c b/source3/auth/user_info.c
new file mode 100644
index 0000000000..df08b73bff
--- /dev/null
+++ b/source3/auth/user_info.c
@@ -0,0 +1,131 @@
+/*
+ Unix SMB/CIFS implementation.
+ Authentication utility functions
+ Copyright (C) Volker Lendecke 2010
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "includes.h"
+
+#undef DBGC_CLASS
+#define DBGC_CLASS DBGC_AUTH
+
+/****************************************************************************
+ Create an auth_usersupplied_data structure
+****************************************************************************/
+
+NTSTATUS make_user_info(struct auth_usersupplied_info **user_info,
+ const char *smb_name,
+ const char *internal_username,
+ const char *client_domain,
+ const char *domain,
+ const char *wksta_name,
+ DATA_BLOB *lm_pwd, DATA_BLOB *nt_pwd,
+ DATA_BLOB *lm_interactive_pwd, DATA_BLOB *nt_interactive_pwd,
+ DATA_BLOB *plaintext,
+ bool encrypted)
+{
+
+ DEBUG(5,("attempting to make a user_info for %s (%s)\n", internal_username, smb_name));
+
+ *user_info = SMB_MALLOC_P(struct auth_usersupplied_info);
+ if (*user_info == NULL) {
+ DEBUG(0,("malloc failed for user_info (size %lu)\n", (unsigned long)sizeof(*user_info)));
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ ZERO_STRUCTP(*user_info);
+
+ DEBUG(5,("making strings for %s's user_info struct\n", internal_username));
+
+ (*user_info)->smb_name = SMB_STRDUP(smb_name);
+ if ((*user_info)->smb_name == NULL) {
+ free_user_info(user_info);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ (*user_info)->internal_username = SMB_STRDUP(internal_username);
+ if ((*user_info)->internal_username == NULL) {
+ free_user_info(user_info);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ (*user_info)->domain = SMB_STRDUP(domain);
+ if ((*user_info)->domain == NULL) {
+ free_user_info(user_info);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ (*user_info)->client_domain = SMB_STRDUP(client_domain);
+ if ((*user_info)->client_domain == NULL) {
+ free_user_info(user_info);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ (*user_info)->wksta_name = SMB_STRDUP(wksta_name);
+ if ((*user_info)->wksta_name == NULL) {
+ free_user_info(user_info);
+ return NT_STATUS_NO_MEMORY;
+ }
+
+ DEBUG(5,("making blobs for %s's user_info struct\n", internal_username));
+
+ if (lm_pwd)
+ (*user_info)->lm_resp = data_blob(lm_pwd->data, lm_pwd->length);
+ if (nt_pwd)
+ (*user_info)->nt_resp = data_blob(nt_pwd->data, nt_pwd->length);
+ if (lm_interactive_pwd)
+ (*user_info)->lm_interactive_pwd = data_blob(lm_interactive_pwd->data, lm_interactive_pwd->length);
+ if (nt_interactive_pwd)
+ (*user_info)->nt_interactive_pwd = data_blob(nt_interactive_pwd->data, nt_interactive_pwd->length);
+
+ if (plaintext)
+ (*user_info)->plaintext_password = data_blob(plaintext->data, plaintext->length);
+
+ (*user_info)->encrypted = encrypted;
+
+ (*user_info)->logon_parameters = 0;
+
+ DEBUG(10,("made an %sencrypted user_info for %s (%s)\n", encrypted ? "":"un" , internal_username, smb_name));
+
+ return NT_STATUS_OK;
+}
+
+/***************************************************************************
+ Free a user_info struct
+***************************************************************************/
+
+void free_user_info(struct auth_usersupplied_info **user_info)
+{
+ DEBUG(5,("attempting to free (and zero) a user_info structure\n"));
+ if (*user_info != NULL) {
+ if ((*user_info)->smb_name) {
+ DEBUG(10,("structure was created for %s\n",
+ (*user_info)->smb_name));
+ }
+ SAFE_FREE((*user_info)->smb_name);
+ SAFE_FREE((*user_info)->internal_username);
+ SAFE_FREE((*user_info)->client_domain);
+ SAFE_FREE((*user_info)->domain);
+ SAFE_FREE((*user_info)->wksta_name);
+ data_blob_free(&(*user_info)->lm_resp);
+ data_blob_free(&(*user_info)->nt_resp);
+ data_blob_clear_free(&(*user_info)->lm_interactive_pwd);
+ data_blob_clear_free(&(*user_info)->nt_interactive_pwd);
+ data_blob_clear_free(&(*user_info)->plaintext_password);
+ ZERO_STRUCT(**user_info);
+ }
+ SAFE_FREE(*user_info);
+}
diff --git a/source3/include/proto.h b/source3/include/proto.h
index eefde96911..930dcc8541 100644
--- a/source3/include/proto.h
+++ b/source3/include/proto.h
@@ -154,6 +154,20 @@ void free_user_info(struct auth_usersupplied_info **user_info);
bool make_auth_methods(struct auth_context *auth_context, auth_methods **auth_method) ;
bool is_trusted_domain(const char* dom_name);
+/* The following definitions come from auth/user_info.c */
+
+NTSTATUS make_user_info(struct auth_usersupplied_info **user_info,
+ const char *smb_name,
+ const char *internal_username,
+ const char *client_domain,
+ const char *domain,
+ const char *wksta_name,
+ DATA_BLOB *lm_pwd, DATA_BLOB *nt_pwd,
+ DATA_BLOB *lm_interactive_pwd, DATA_BLOB *nt_interactive_pwd,
+ DATA_BLOB *plaintext,
+ bool encrypted);
+void free_user_info(struct auth_usersupplied_info **user_info);
+
/* The following definitions come from auth/auth_winbind.c */
NTSTATUS auth_winbind_init(void);