diff options
Diffstat (limited to 'source3/namelogon.c')
-rw-r--r-- | source3/namelogon.c | 164 |
1 files changed, 87 insertions, 77 deletions
diff --git a/source3/namelogon.c b/source3/namelogon.c index 3fab49cedd..1ea09ee2bb 100644 --- a/source3/namelogon.c +++ b/source3/namelogon.c @@ -47,104 +47,114 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len) { struct dgram_packet *dgram = &p->packet.dgram; struct in_addr ip = dgram->header.source_ip; - struct subnet_record *d = find_subnet(ip); + struct subnet_record *d = find_subnet_all(ip); char *logname,*q; fstring reply_name; BOOL add_slashes = False; pstring outbuf; int code,reply_code; struct work_record *work; - char unknown_byte = 0; - uint16 request_count = 0; - uint16 token = 0; + char unknown_byte = 0; + uint16 request_count = 0; + uint16 token = 0; - if (!d) return; - - if (!(work = find_workgroupstruct(d,dgram->dest_name.name, False))) return; + if (!lp_domain_logons()) + { + DEBUG(3,("No domain logons\n")); + return; + } - if (!lp_domain_logons()) - { - DEBUG(3,("No domain logons\n")); - return; - } + if (!d) + { + DEBUG(0,("process_logon_packet: Cannot find subnet for logon request from %s\n", + inet_ntoa(p->ip) )); + return; + } - code = SVAL(buf,0); - switch (code) - { - case 0: + if (!(work = find_workgroupstruct(d,dgram->dest_name.name, False))) { - char *machine = buf+2; - char *user = skip_string(machine,1); - char *tmp; - logname = skip_string(user,1); - tmp = skip_string(logname,1); - unknown_byte = CVAL(tmp,0); - request_count = SVAL(tmp,1); - token = SVAL(tmp,3); - - reply_code = 0x6; - strcpy(reply_name,myname); - strupper(reply_name); - add_slashes = True; - DEBUG(3,("Domain login request from %s(%s) user=%s token=%x\n", - machine,inet_ntoa(p->ip),user,token)); - break; - } - case 7: + DEBUG(0,("process_logon_packet: Cannot find WORKGROUP %s for logon request fomr %s\n", + dgram->dest_name.name, inet_ntoa(p->ip) )); + return; + } + + code = SVAL(buf,0); + switch (code) { - char *machine = buf+2; - logname = skip_string(machine,1); - token = SVAL(skip_string(logname,1),0); - - strcpy(reply_name,lp_domain_controller()); - if (!*reply_name) - { - /* oo! no domain controller. must be us, then */ + case 0: + { + char *machine = buf+2; + char *user = skip_string(machine,1); + char *tmp; + logname = skip_string(user,1); + tmp = skip_string(logname,1); + unknown_byte = CVAL(tmp,0); + request_count = SVAL(tmp,1); + token = SVAL(tmp,3); + + reply_code = 0x6; strcpy(reply_name,myname); - reply_code = 0xC; + strupper(reply_name); + add_slashes = True; + DEBUG(3,("Domain login request from %s(%s) user=%s token=%x\n", + machine,inet_ntoa(p->ip),user,token)); + break; + } + case 7: + { + char *machine = buf+2; + logname = skip_string(machine,1); + token = SVAL(skip_string(logname,1),0); + + strcpy(reply_name,lp_domain_controller()); + if (!*reply_name) + { + /* oo! no domain controller. must be us, then */ + strcpy(reply_name,myname); + reply_code = 0xC; + } + else + { + /* refer logon request to the domain controller */ + reply_code = 0x7; + } + + strupper(reply_name); + DEBUG(3,("GETDC request from %s(%s), reporting %s 0x%x token=%x\n", + machine,inet_ntoa(p->ip), reply_name, reply_code,token)); + break; + } + default: + { + DEBUG(3,("Unknown domain request %d\n",code)); + return; } - else - { - /* refer logon request to the domain controller */ - reply_code = 0x7; } - - strupper(reply_name); - DEBUG(3,("GETDC request from %s(%s), reporting %s 0x%x token=%x\n", - machine,inet_ntoa(p->ip), reply_name, reply_code,token)); - break; - } - default: - { - DEBUG(3,("Unknown domain request %d\n",code)); - return; - } - } bzero(outbuf,sizeof(outbuf)); q = outbuf; SSVAL(q,0,reply_code); q += 2; - - if (token == 0xffff || /* LM 2.0 or later */ - token == 0xfffe) /* WfWg networking */ + + if (token == 0xffff || /* LM 2.0 or later */ + token == 0xfffe) /* WfWg networking */ + { + if (add_slashes) { - if (add_slashes) - { - strcpy(q,"\\\\"); - q += 2; - } - strcpy(q, reply_name); - strupper(q); - q = skip_string(q,1); - - if (token == 0xffff) /* LM 2.0 or later */ - { - SSVAL(q,0,token); - q += 2; - } + strcpy(q,"\\\\"); + q += 2; } - + strcpy(q, reply_name); + strupper(q); + q = skip_string(q,1); + + if (token == 0xffff) /* LM 2.0 or later */ + { + SSVAL(q,0,token); + q += 2; + } + } + SSVAL(q,0,0xFFFF); q += 2; |