[SCM] Samba Shared Repository - branch master updated
Günther Deschner
gd at samba.org
Thu Sep 9 15:05:56 MDT 2010
The branch, master has been updated
via 71b9570 s3-nmbd: use autogenerated marshalling for LOGON_SAM_LOGON_REQUEST.
via 36d7efa s3-nmbd: use autogenerated marshalling for LOGON_PRIMARY_QUERY.
via bfda968 s3-nmbd: use autogenerated marshalling for LOGON_REQUEST.
via f002b7f s3-nmbd: handle source_name in one location in nmbd_process_logon().
via 5fc7d14 s3-nmbd: use nbt_netlogon_packet in process_logon_packet().
via fe30e35 libcli/netlogon: add LOGON_REQUEST handling to pull_nbt_netlogon_response().
via 9a1dbe0 libcli/netlogon: add LOGON_RESPONSE2 to pull_nbt_netlogon_response().
via daa948d libcli/netlogon: add NETLOGON_RESPONSE2 to push_nbt_netlogon_response().
from c82bcef s4:client/cifsdd.c - restore Solaris cc compatibility
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master
- Log -----------------------------------------------------------------
commit 71b95703f99d2a5b71c8d31abf04e2a05336afb8
Author: Günther Deschner <gd at samba.org>
Date: Wed Sep 8 18:55:27 2010 +0200
s3-nmbd: use autogenerated marshalling for LOGON_SAM_LOGON_REQUEST.
Guenther
commit 36d7efa75a799522b8ac5995509573d667213799
Author: Günther Deschner <gd at samba.org>
Date: Thu Sep 9 13:16:21 2010 +0200
s3-nmbd: use autogenerated marshalling for LOGON_PRIMARY_QUERY.
Couldn't find any reproducer for a short request, so removing it for now.
Guenther
commit bfda968e0776dfc95e761ffd3a91f72702286fee
Author: Günther Deschner <gd at samba.org>
Date: Thu Sep 9 22:39:05 2010 +0200
s3-nmbd: use autogenerated marshalling for LOGON_REQUEST.
Guenther
commit f002b7fa1b4162e691abb68eb95eee2a809faaf5
Author: Günther Deschner <gd at samba.org>
Date: Thu Sep 9 22:38:37 2010 +0200
s3-nmbd: handle source_name in one location in nmbd_process_logon().
Guenther
commit 5fc7d14b064d83b40c65a8c41ea05a9b43af6f5d
Author: Günther Deschner <gd at samba.org>
Date: Tue Sep 7 11:41:05 2010 +0200
s3-nmbd: use nbt_netlogon_packet in process_logon_packet().
Guenther
commit fe30e359670d67e9a8b8ccd22d4eb6d363f88827
Author: Günther Deschner <gd at samba.org>
Date: Wed Sep 8 11:58:04 2010 +0200
libcli/netlogon: add LOGON_REQUEST handling to pull_nbt_netlogon_response().
Guenther
commit 9a1dbe04a8f1a7cbd0352504990c9240fdd22dae
Author: Günther Deschner <gd at samba.org>
Date: Wed Sep 8 18:59:19 2010 +0200
libcli/netlogon: add LOGON_RESPONSE2 to pull_nbt_netlogon_response().
Guenther
commit daa948df2bf23f15bcdb4df170306ef71d952e7c
Author: Günther Deschner <gd at samba.org>
Date: Tue Sep 7 22:41:44 2010 +0200
libcli/netlogon: add NETLOGON_RESPONSE2 to push_nbt_netlogon_response().
Guenther
-----------------------------------------------------------------------
Summary of changes:
libcli/netlogon.c | 20 ++
libcli/netlogon.h | 3 +-
source3/nmbd/nmbd_processlogon.c | 647 +++++++++++---------------------------
3 files changed, 204 insertions(+), 466 deletions(-)
Changeset truncated at 500 lines:
diff --git a/libcli/netlogon.c b/libcli/netlogon.c
index d9b0196..ceb1c85 100644
--- a/libcli/netlogon.c
+++ b/libcli/netlogon.c
@@ -194,7 +194,17 @@ NTSTATUS push_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
data, mem_ctx,
&response->data.samlogon);
break;
+ case NETLOGON_RESPONSE2:
+ ndr_err = ndr_push_struct_blob(data, mem_ctx,
+ &response->data.response2,
+ (ndr_push_flags_fn_t)ndr_push_nbt_netlogon_response2);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+ status = NT_STATUS_OK;
+ break;
}
+
return status;
}
@@ -228,6 +238,15 @@ NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
status = NT_STATUS_OK;
response->response_type = NETLOGON_GET_PDC;
break;
+ case LOGON_RESPONSE2:
+ ndr_err = ndr_pull_struct_blob(data, mem_ctx, &response->data.response2,
+ (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_response2);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ return ndr_map_error2ntstatus(ndr_err);
+ }
+ status = NT_STATUS_OK;
+ response->response_type = NETLOGON_RESPONSE2;
+ break;
case LOGON_SAM_LOGON_RESPONSE:
case LOGON_SAM_LOGON_PAUSE_RESPONSE:
case LOGON_SAM_LOGON_USER_UNKNOWN:
@@ -242,6 +261,7 @@ NTSTATUS pull_nbt_netlogon_response(DATA_BLOB *data, TALLOC_CTX *mem_ctx,
/* These levels are queries, not responses */
case LOGON_PRIMARY_QUERY:
+ case LOGON_REQUEST:
case NETLOGON_ANNOUNCE_UAS:
case LOGON_SAM_LOGON_REQUEST:
status = NT_STATUS_INVALID_NETWORK_RESPONSE;
diff --git a/libcli/netlogon.h b/libcli/netlogon.h
index 6ca3de3..3e626ed 100644
--- a/libcli/netlogon.h
+++ b/libcli/netlogon.h
@@ -42,10 +42,11 @@ struct netlogon_samlogon_response
struct nbt_netlogon_response
{
- enum {NETLOGON_GET_PDC, NETLOGON_SAMLOGON} response_type;
+ enum {NETLOGON_GET_PDC, NETLOGON_SAMLOGON, NETLOGON_RESPONSE2} response_type;
union {
struct nbt_netlogon_response_from_pdc get_pdc;
struct netlogon_samlogon_response samlogon;
+ struct nbt_netlogon_response2 response2;
} data;
};
diff --git a/source3/nmbd/nmbd_processlogon.c b/source3/nmbd/nmbd_processlogon.c
index 357d00b..8780139 100644
--- a/source3/nmbd/nmbd_processlogon.c
+++ b/source3/nmbd/nmbd_processlogon.c
@@ -307,26 +307,19 @@ Process a domain logon packet
void process_logon_packet(struct packet_struct *p, char *buf,int len,
const char *mailslot)
{
+ fstring source_name;
struct dgram_packet *dgram = &p->packet.dgram;
- fstring my_name;
- fstring reply_name;
- char outbuf[1024];
- int code;
- uint16 token = 0;
- uint32 ntversion = 0;
- uint16 lmnttoken = 0;
- uint16 lm20token = 0;
- uint32 domainsidsize;
- bool short_request = False;
- char *getdc;
- char *uniuser; /* Unicode user name. */
- fstring ascuser;
- char *unicomp; /* Unicode computer name. */
- size_t size;
struct sockaddr_storage ss;
const struct sockaddr_storage *pss;
struct in_addr ip;
+ DATA_BLOB blob_in, blob_out;
+ enum ndr_err_code ndr_err;
+ struct nbt_netlogon_packet request;
+ struct nbt_netlogon_response response;
+ NTSTATUS status;
+ const char *pdc_name;
+
in_addr_to_sockaddr_storage(&ss, p->ip);
pss = iface_ip((struct sockaddr *)&ss);
if (!pss) {
@@ -337,217 +330,132 @@ void process_logon_packet(struct packet_struct *p, char *buf,int len,
}
ip = ((struct sockaddr_in *)pss)->sin_addr;
- memset(outbuf, 0, sizeof(outbuf));
-
if (!lp_domain_logons()) {
DEBUG(5,("process_logon_packet: Logon packet received from IP %s and domain \
logons are not enabled.\n", inet_ntoa(p->ip) ));
return;
}
- fstrcpy(my_name, global_myname());
+ pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
- code = get_safe_SVAL(buf,len,buf,0,-1);
- DEBUG(4,("process_logon_packet: Logon from %s: code = 0x%x\n", inet_ntoa(p->ip), code));
+ pdc_name = talloc_asprintf(talloc_tos(), "\\\\%s", global_myname());
+ if (!pdc_name) {
+ return;
+ }
- switch (code) {
- case 0: {
- fstring mach_str, user_str, getdc_str;
- char *q = buf + 2;
- char *machine = q;
- char *user = skip_string(buf,len,machine);
+ ZERO_STRUCT(request);
- if (!user || PTR_DIFF(user, buf) >= len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
- }
- getdc = skip_string(buf,len,user);
+ blob_in = data_blob_const(buf, len);
- if (!getdc || PTR_DIFF(getdc, buf) >= len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
- }
- q = skip_string(buf,len,getdc);
+ ndr_err = ndr_pull_struct_blob(&blob_in, talloc_tos(), &request,
+ (ndr_pull_flags_fn_t)ndr_pull_nbt_netlogon_packet);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(1,("process_logon_packet: Failed to pull logon packet\n"));
+ return;
+ }
- if (!q || PTR_DIFF(q + 5, buf) > len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
- }
- token = SVAL(q,3);
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_DEBUG(nbt_netlogon_packet, &request);
+ }
+
+ DEBUG(4,("process_logon_packet: Logon from %s: code = 0x%x\n",
+ inet_ntoa(p->ip), request.command));
- fstrcpy(reply_name,my_name);
+ switch (request.command) {
+ case LOGON_REQUEST: {
- pull_ascii_fstring(mach_str, machine);
- pull_ascii_fstring(user_str, user);
- pull_ascii_fstring(getdc_str, getdc);
+ struct nbt_netlogon_response2 response2;
DEBUG(5,("process_logon_packet: Domain login request from %s at IP %s user=%s token=%x\n",
- mach_str,inet_ntoa(p->ip),user_str,token));
-
- q = outbuf;
- SSVAL(q, 0, 6);
- q += 2;
-
- fstrcpy(reply_name, "\\\\");
- fstrcat(reply_name, my_name);
- size = push_ascii(q,reply_name,
- sizeof(outbuf)-PTR_DIFF(q, outbuf),
- STR_TERMINATE);
- if (size == (size_t)-1) {
+ request.req.logon0.computer_name, inet_ntoa(p->ip),
+ request.req.logon0.user_name,
+ request.req.logon0.lm20_token));
+
+ response2.command = LOGON_RESPONSE2;
+ response2.pdc_name = pdc_name;
+ response2.lm20_token = 0xffff;
+
+ response.response_type = NETLOGON_RESPONSE2;
+ response.data.response2 = response2;
+
+ status = push_nbt_netlogon_response(&blob_out, talloc_tos(), &response);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("process_logon_packet: failed to push packet\n"));
return;
}
- q = skip_string(outbuf,sizeof(outbuf),q); /* PDC name */
- SSVAL(q, 0, token);
- q += 2;
-
- dump_data(4, (uint8 *)outbuf, PTR_DIFF(q, outbuf));
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_DEBUG(nbt_netlogon_response2, &response.data.response2);
+ }
- send_mailslot(True, getdc_str,
- outbuf,PTR_DIFF(q,outbuf),
+ send_mailslot(True, request.req.logon0.mailslot_name,
+ (char *)blob_out.data,
+ blob_out.length,
global_myname(), 0x0,
- mach_str,
+ source_name,
dgram->source_name.name_type,
p->ip, ip, p->port);
break;
}
case LOGON_PRIMARY_QUERY: {
- fstring mach_str, getdc_str;
- fstring source_name;
- char *q = buf + 2;
- char *machine = q;
+
+ struct nbt_netlogon_response_from_pdc get_pdc;
if (!lp_domain_master()) {
/* We're not Primary Domain Controller -- ignore this */
return;
}
- getdc = skip_string(buf,len,machine);
-
- if (!getdc || PTR_DIFF(getdc, buf) >= len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
+ DEBUG(5,("process_logon_packet: GETDC request from %s at IP %s, "
+ "reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
+ request.req.pdc.computer_name,
+ inet_ntoa(p->ip),
+ global_myname(),
+ lp_workgroup(),
+ NETLOGON_RESPONSE_FROM_PDC,
+ request.req.pdc.nt_version,
+ request.req.pdc.lmnt_token,
+ request.req.pdc.lm20_token));
+
+ get_pdc.command = NETLOGON_RESPONSE_FROM_PDC;
+ get_pdc.pdc_name = global_myname();
+ get_pdc._pad = data_blob_null;
+ get_pdc.unicode_pdc_name = global_myname();
+ get_pdc.domain_name = lp_workgroup();
+ get_pdc.nt_version = 1;
+ get_pdc.lmnt_token = 0xffff;
+ get_pdc.lm20_token = 0xffff;
+
+ response.response_type = NETLOGON_GET_PDC;
+ response.data.get_pdc = get_pdc;
+
+ status = push_nbt_netlogon_response(&blob_out, talloc_tos(), &response);
+ if (!NT_STATUS_IS_OK(status)) {
+ DEBUG(0,("process_logon_packet: failed to push packet\n"));
return;
}
- q = skip_string(buf,len,getdc);
-
- if (!q || PTR_DIFF(q, buf) >= len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
- }
- q = ALIGN2(q, buf);
-
- /* At this point we can work out if this is a W9X or NT style
- request. Experiments show that the difference is wether the
- packet ends here. For a W9X request we now end with a pair of
- bytes (usually 0xFE 0xFF) whereas with NT we have two further
- strings - the following is a simple way of detecting this */
-
- if (len - PTR_DIFF(q, buf) <= 3) {
- short_request = True;
- } else {
- unicomp = q;
-
- if (PTR_DIFF(q, buf) >= len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
- }
-
- /* A full length (NT style) request */
- q = skip_unibuf(unicomp, PTR_DIFF(buf + len, unicomp));
-
- if (PTR_DIFF(q, buf) >= len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
- }
-
- if (len - PTR_DIFF(q, buf) > 8) {
- /* with NT5 clients we can sometimes
- get additional data - a length specificed string
- containing the domain name, then 16 bytes of
- data (no idea what it is) */
- int dom_len = CVAL(q, 0);
- q++;
- if (dom_len != 0) {
- q += dom_len + 1;
- }
- q += 16;
- }
-
- if (PTR_DIFF(q + 8, buf) > len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
- }
-
- ntversion = IVAL(q, 0);
- lmnttoken = SVAL(q, 4);
- lm20token = SVAL(q, 6);
- }
-
- /* Construct reply. */
- q = outbuf;
- SSVAL(q, 0, NETLOGON_RESPONSE_FROM_PDC);
- q += 2;
- fstrcpy(reply_name,my_name);
- size = push_ascii(q, reply_name,
- sizeof(outbuf)-PTR_DIFF(q, outbuf),
- STR_TERMINATE);
- if (size == (size_t)-1) {
- return;
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_DEBUG(nbt_netlogon_response_from_pdc, &response.data.get_pdc);
}
- q = skip_string(outbuf,sizeof(outbuf),q); /* PDC name */
-
- /* PDC and domain name */
- if (!short_request) {
- /* Make a full reply */
- q = ALIGN2(q, outbuf);
-
- q += dos_PutUniCode(q, my_name,
- sizeof(outbuf) - PTR_DIFF(q, outbuf),
- True); /* PDC name */
- q += dos_PutUniCode(q, lp_workgroup(),
- sizeof(outbuf) - PTR_DIFF(q, outbuf),
- True); /* Domain name*/
- if (sizeof(outbuf) - PTR_DIFF(q, outbuf) < 8) {
- return;
- }
- SIVAL(q, 0, 1); /* our nt version */
- SSVAL(q, 4, 0xffff); /* our lmnttoken */
- SSVAL(q, 6, 0xffff); /* our lm20token */
- q += 8;
- }
-
- /* RJS, 21-Feb-2000, we send a short reply if the request was short */
-
- pull_ascii_fstring(mach_str, machine);
- DEBUG(5,("process_logon_packet: GETDC request from %s at IP %s, \
-reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
- mach_str,inet_ntoa(p->ip), reply_name, lp_workgroup(),
- NETLOGON_RESPONSE_FROM_PDC, (uint32)ntversion, (uint32)lmnttoken,
- (uint32)lm20token ));
-
- dump_data(4, (uint8 *)outbuf, PTR_DIFF(q, outbuf));
-
- pull_ascii_fstring(getdc_str, getdc);
- pull_ascii_nstring(source_name, sizeof(source_name), dgram->source_name.name);
-
- send_mailslot(True, getdc_str,
- outbuf,PTR_DIFF(q,outbuf),
+ send_mailslot(True, request.req.pdc.mailslot_name,
+ (char *)blob_out.data,
+ blob_out.length,
global_myname(), 0x0,
source_name,
dgram->source_name.name_type,
p->ip, ip, p->port);
+
return;
}
case LOGON_SAM_LOGON_REQUEST: {
- fstring getdc_str;
- fstring source_name;
char *source_addr;
- char *q = buf + 2;
- fstring asccomp;
+ bool user_unknown = false;
+
+ struct netlogon_samlogon_response samlogon;
if (global_nmbd_proxy_logon) {
nmbd_proxy_logon(global_nmbd_proxy_logon,
@@ -555,318 +463,126 @@ reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
return;
}
- q += 2;
-
- if (PTR_DIFF(q, buf) >= len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
- }
-
- unicomp = q;
- uniuser = skip_unibuf(unicomp, PTR_DIFF(buf+len, unicomp));
-
- if (PTR_DIFF(uniuser, buf) >= len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
- }
-
- getdc = skip_unibuf(uniuser,PTR_DIFF(buf+len, uniuser));
-
- if (PTR_DIFF(getdc, buf) >= len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
- }
-
- q = skip_string(buf,len,getdc);
-
- if (!q || PTR_DIFF(q + 8, buf) >= len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
+ source_addr = SMB_STRDUP(inet_ntoa(dgram->header.source_ip));
+ if (source_addr == NULL) {
+ DEBUG(3, ("out of memory copying client"
+ " address string\n"));
return;
}
- q += 4; /* Account Control Bits - indicating username type */
- domainsidsize = IVAL(q, 0);
- q += 4;
-
- DEBUG(5,("process_logon_packet: LOGON_SAM_LOGON_REQUEST sidsize %d, len = %d\n", domainsidsize, len));
-
- if (domainsidsize < (len - PTR_DIFF(q, buf)) && (domainsidsize != 0)) {
- q += domainsidsize;
- q = ALIGN4(q, buf);
- }
-
- DEBUG(5,("process_logon_packet: len = %d PTR_DIFF(q, buf) = %ld\n", len, (unsigned long)PTR_DIFF(q, buf) ));
-
- if (len - PTR_DIFF(q, buf) > 8) {
- /* with NT5 clients we can sometimes
- get additional data - a length specificed string
- containing the domain name, then 16 bytes of
- data (no idea what it is) */
- int dom_len = CVAL(q, 0);
- q++;
- if (dom_len < (len - PTR_DIFF(q, buf)) && (dom_len != 0)) {
- q += dom_len + 1;
- }
- q += 16;
- }
-
- if (PTR_DIFF(q + 8, buf) > len) {
- DEBUG(0,("process_logon_packet: bad packet\n"));
- return;
+ DEBUG(5,("process_logon_packet: LOGON_SAM_LOGON_REQUEST request from %s(%s) for %s, returning logon svr %s domain %s code %x token=%x\n",
+ request.req.logon.computer_name,
+ inet_ntoa(p->ip),
+ request.req.logon.user_name,
+ pdc_name,
+ lp_workgroup(),
+ LOGON_SAM_LOGON_RESPONSE,
+ request.req.logon.lmnt_token));
+
+ if (!request.req.logon.user_name) {
+ user_unknown = true;
}
- ntversion = IVAL(q, 0);
- lmnttoken = SVAL(q, 4);
- lm20token = SVAL(q, 6);
- q += 8;
-
- DEBUG(3,("process_logon_packet: LOGON_SAM_LOGON_REQUEST sidsize %d ntv %d\n", domainsidsize, ntversion));
+ /* we want the simple version unless we are an ADS PDC..which means */
+ /* never, at least for now */
- /*
- * we respond regadless of whether the machine is in our password
- * database. If it isn't then we let smbd send an appropriate error.
- * Let's ignore the SID.
- */
- pull_ucs2_fstring(ascuser, uniuser);
- pull_ucs2_fstring(asccomp, unicomp);
- DEBUG(5,("process_logon_packet: LOGON_SAM_LOGON_REQUEST user %s\n", ascuser));
+ if ((request.req.logon.nt_version < (NETLOGON_NT_VERSION_1 | NETLOGON_NT_VERSION_5 | NETLOGON_NT_VERSION_5EX_WITH_IP)) ||
+ (SEC_ADS != lp_security()) || (ROLE_DOMAIN_PDC != lp_server_role())) {
- fstrcpy(reply_name, "\\\\"); /* Here it wants \\LOGONSERVER. */
--
Samba Shared Repository
More information about the samba-cvs
mailing list