summaryrefslogtreecommitdiff
path: root/source3/smbd/negprot.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2010-07-19 16:45:16 -0700
committerJeremy Allison <jra@samba.org>2010-07-19 16:45:16 -0700
commit8cba4a0c9639c48ec2433a98529bd8352e9d06c9 (patch)
tree9cf2522fea2214e8cc11f23d5a4e904b7202357d /source3/smbd/negprot.c
parent625a51138916473eacc1447b11ffd93db0832077 (diff)
downloadsamba-8cba4a0c9639c48ec2433a98529bd8352e9d06c9.tar.gz
samba-8cba4a0c9639c48ec2433a98529bd8352e9d06c9.tar.bz2
samba-8cba4a0c9639c48ec2433a98529bd8352e9d06c9.zip
Move the addition of the 16 byte guid out of spnego_gen_negTokenInit() and
into negprot_spnego() where it belongs (it's not an SPNEGO operation). Add a TALLOC_CTX for callers of negprot_spnego(). Closer to unifying all the gen_negTokenXXX calls. Jeremy.
Diffstat (limited to 'source3/smbd/negprot.c')
-rw-r--r--source3/smbd/negprot.c55
1 files changed, 32 insertions, 23 deletions
diff --git a/source3/smbd/negprot.c b/source3/smbd/negprot.c
index 4d73216854..e7cf5b7591 100644
--- a/source3/smbd/negprot.c
+++ b/source3/smbd/negprot.c
@@ -176,15 +176,15 @@ static void reply_lanman2(struct smb_request *req, uint16 choice)
Generate the spnego negprot reply blob. Return the number of bytes used.
****************************************************************************/
-DATA_BLOB negprot_spnego(struct smbd_server_connection *sconn)
+DATA_BLOB negprot_spnego(TALLOC_CTX *ctx, struct smbd_server_connection *sconn)
{
- DATA_BLOB blob;
+ DATA_BLOB blob = data_blob_null;
+ DATA_BLOB blob_out = data_blob_null;
nstring dos_name;
fstring unix_name;
#ifdef DEVELOPER
size_t slen;
#endif
- char guid[17];
const char *OIDs_krb5[] = {OID_KERBEROS5,
OID_KERBEROS5_OLD,
OID_NTLMSSP,
@@ -192,22 +192,6 @@ DATA_BLOB negprot_spnego(struct smbd_server_connection *sconn)
const char *OIDs_plain[] = {OID_NTLMSSP, NULL};
sconn->smb1.negprot.spnego = true;
-
- memset(guid, '\0', sizeof(guid));
-
- safe_strcpy(unix_name, global_myname(), sizeof(unix_name)-1);
- strlower_m(unix_name);
- push_ascii_nstring(dos_name, unix_name);
- safe_strcpy(guid, dos_name, sizeof(guid)-1);
-
-#ifdef DEVELOPER
- /* Fix valgrind 'uninitialized bytes' issue. */
- slen = strlen(dos_name);
- if (slen < sizeof(guid)) {
- memset(guid+slen, '\0', sizeof(guid) - slen);
- }
-#endif
-
/* strangely enough, NT does not sent the single OID NTLMSSP when
not a ADS member, it sends no OIDs at all
@@ -227,7 +211,7 @@ DATA_BLOB negprot_spnego(struct smbd_server_connection *sconn)
blob = data_blob(guid, 16);
#else
/* Code for standalone WXP client */
- blob = spnego_gen_negTokenInit(guid, OIDs_plain, "NONE");
+ blob = spnego_gen_negTokenInit(OIDs_plain, "NONE");
#endif
} else {
fstring myname;
@@ -238,11 +222,36 @@ DATA_BLOB negprot_spnego(struct smbd_server_connection *sconn)
== -1) {
return data_blob_null;
}
- blob = spnego_gen_negTokenInit(guid, OIDs_krb5, host_princ_s);
+ blob = spnego_gen_negTokenInit(OIDs_krb5, host_princ_s);
SAFE_FREE(host_princ_s);
}
- return blob;
+ blob_out = data_blob_talloc(ctx, NULL, 16 + blob.length);
+ if (blob_out.data == NULL) {
+ data_blob_free(&blob);
+ return data_blob_null;
+ }
+
+ memset(blob_out.data, '\0', 16);
+
+ safe_strcpy(unix_name, global_myname(), sizeof(unix_name)-1);
+ strlower_m(unix_name);
+ push_ascii_nstring(dos_name, unix_name);
+ safe_strcpy((char *)blob_out.data, dos_name, 16);
+
+#ifdef DEVELOPER
+ /* Fix valgrind 'uninitialized bytes' issue. */
+ slen = strlen(dos_name);
+ if (slen < sizeof(16)) {
+ memset(blob_out.data+slen, '\0', 16 - slen);
+ }
+#endif
+
+ memcpy(&blob_out.data[16], blob.data, blob.length);
+
+ data_blob_free(&blob);
+
+ return blob_out;
}
/****************************************************************************
@@ -381,7 +390,7 @@ static void reply_nt1(struct smb_request *req, uint16 choice)
}
DEBUG(3,("not using SPNEGO\n"));
} else {
- DATA_BLOB spnego_blob = negprot_spnego(req->sconn);
+ DATA_BLOB spnego_blob = negprot_spnego(req, req->sconn);
if (spnego_blob.data == NULL) {
reply_nterror(req, NT_STATUS_NO_MEMORY);