pass the mailslot name to process_logon_packet()
authorAndrew Tridgell <tridge@samba.org>
Fri, 28 Nov 1997 05:52:31 +0000 (05:52 +0000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 28 Nov 1997 05:52:31 +0000 (05:52 +0000)
- fixed process_logon_packet() to always send the reply to/from the
correct netbios name (it should match the query)

- only do a NT style QUERYFORPDC if the query came in on a
NT_LOGON_MAILSLOT

Luke, can you check to see if these changes work in your branch with
NT logons?
(This used to be commit e89611985b35155770648c8f16ddd19acfb5ee13)

source3/include/proto.h
source3/namelogon.c
source3/namepacket.c

index 1b8d5be1417939e865f4e59939ec33eec039b86d..c47b7582f308d9a6e79e9285083299f4e72d442b 100644 (file)
@@ -547,7 +547,8 @@ BOOL check_elections(void);
 
 /*The following definitions come from  namelogon.c  */
 
-void process_logon_packet(struct packet_struct *p,char *buf,int len);
+void process_logon_packet(struct packet_struct *p,char *buf,int len, 
+                         char *mailslot);
 
 /*The following definitions come from  namepacket.c  */
 
index 697a11a16a4494f279ec6d75cf2827be01ec0138..08e0f036077321a8b4345a580c39d04305006f14 100644 (file)
@@ -36,9 +36,9 @@ extern pstring myname;
 
 /****************************************************************************
    process a domain logon packet
-
    **************************************************************************/
-void process_logon_packet(struct packet_struct *p,char *buf,int len)
+void process_logon_packet(struct packet_struct *p,char *buf,int len, 
+                         char *mailslot)
 {
        struct dgram_packet *dgram = &p->packet.dgram;
        pstring my_name;
@@ -57,9 +57,9 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
        uint32 domainsidsize;
        uint16 requestcount;
        char *domainsid;
+       char *getdc;
        char *uniuser; /* Unicode user name */
        pstring ascuser;
-       char *mailslot;
        char *unicomp; /* Unicode computer name */
        struct smb_passwd *smb_pass; /* To check if machine account exists */
 
@@ -83,8 +83,8 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
                        char *machine = q;
                        char *user = skip_string(machine,1);
 
-                       mailslot = skip_string(user,1);
-                       q = skip_string(mailslot,1);
+                       getdc = skip_string(user,1);
+                       q = skip_string(getdc,1);
                        unknown_byte = CVAL(q,0);
                        request_count = SVAL(q,1);
                        token = SVAL(q,3);
@@ -107,9 +107,12 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
 
                        dump_data(4, outbuf, PTR_DIFF(q, outbuf));
 
-                       send_mailslot_reply(True, mailslot, ClientDGRAM,
+                       send_mailslot_reply(True, getdc, ClientDGRAM,
                                            outbuf,PTR_DIFF(q,outbuf),
-                                           my_name,&dgram->source_name.name[0],0x20,0,
+                                           dgram->dest_name.name,
+                                           dgram->source_name.name,
+                                           dgram->dest_name.name_type,
+                                           dgram->source_name.name_type,
                                            p->ip, *iface_ip(p->ip));  
                        break;
                }
@@ -119,8 +122,8 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
                        char *q = buf + 2;
                        char *machine = q;
 
-                       mailslot = skip_string(machine,1);
-                       unicomp = skip_string(mailslot,1);
+                       getdc = skip_string(machine,1);
+                       unicomp = skip_string(getdc,1);
 
                        q = align2(unicomp, buf);
 
@@ -138,14 +141,18 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
                        strcpy(reply_name,my_name);
                        strcpy(q, reply_name); q = skip_string(q, 1); /* PDC name */
 
-                       q = align2(q, buf);
+                       if (strcmp(mailslot, NT_LOGON_MAILSLOT)==0) {
+                               q = align2(q, buf);
 
-                       PutUniCode(q, my_name); q = skip_unicode_string(q, 1); /* PDC name */
-                       PutUniCode(q, lp_workgroup()); q = skip_unicode_string(q, 1); /* Domain name. */
+                               PutUniCode(q, my_name); /* PDC name */
+                               q = skip_unicode_string(q, 1); 
+                               PutUniCode(q, lp_workgroup()); /* Domain name*/
+                               q = skip_unicode_string(q, 1); 
 
-                       SIVAL(q, 0, ntversion); q += 4;
-                       SSVAL(q, 0, lmnttoken); q += 2;
-                       SSVAL(q, 0, lm20token); q += 2;
+                               SIVAL(q, 0, ntversion); q += 4;
+                               SSVAL(q, 0, lmnttoken); q += 2;
+                               SSVAL(q, 0, lm20token); q += 2;
+                       }
 
                        DEBUG(3,("GETDC request from %s(%s), reporting %s domain %s 0x%x ntversion=%x lm_nt token=%x lm_20 token=%x\n",
                                  machine,inet_ntoa(p->ip), reply_name, lp_workgroup(),
@@ -154,9 +161,12 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
 
                        dump_data(4, outbuf, PTR_DIFF(q, outbuf));
 
-                       send_mailslot_reply(True, mailslot,ClientDGRAM,
+                       send_mailslot_reply(True, getdc,ClientDGRAM,
                                            outbuf,PTR_DIFF(q,outbuf),
-                                           my_name,&dgram->source_name.name[0],0x20,0,
+                                           dgram->dest_name.name,
+                                           dgram->source_name.name,
+                                           dgram->dest_name.name_type,
+                                           dgram->source_name.name_type,
                                            p->ip, *iface_ip(p->ip));  
                        return;
                }
@@ -168,8 +178,8 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
                        requestcount = SVAL(q, 0); q += 2;
                        unicomp = q;
                        uniuser = skip_unicode_string(unicomp,1);
-                       mailslot = skip_unicode_string(uniuser,1);
-                       q = skip_string(mailslot,1);
+                       getdc = skip_unicode_string(uniuser,1);
+                       q = skip_string(getdc,1);
                        allowableaccount = IVAL(q, 0); q += 4;
                        domainsidsize = IVAL(q, 0); q += 4;
                        domainsid = q;
@@ -221,9 +231,12 @@ void process_logon_packet(struct packet_struct *p,char *buf,int len)
 
                        dump_data(4, outbuf, PTR_DIFF(q, outbuf));
 
-                       send_mailslot_reply(True, mailslot,ClientDGRAM,
+                       send_mailslot_reply(True, getdc,ClientDGRAM,
                                            outbuf,PTR_DIFF(q,outbuf),
-                                           my_name,&dgram->source_name.name[0],0x20,0,
+                                           dgram->dest_name.name,
+                                           dgram->source_name.name,
+                                           dgram->dest_name.name_type,
+                                           dgram->source_name.name_type,
                                            p->ip, *iface_ip(p->ip));  
                        break;
                }
index 626e50b788a11420890b62de81008fa2dc81df39..be099340c3961cc13cf24f8b23f9c7584e2344e0 100644 (file)
@@ -382,13 +382,13 @@ static void process_dgram(struct packet_struct *p)
 
    /* datagram packet received for the domain log on mailslot */
    if (strequal(smb_buf(buf),NET_LOGON_MAILSLOT)) {
-     process_logon_packet(p,buf2,len);
+     process_logon_packet(p,buf2,len, NET_LOGON_MAILSLOT);
      return;
    }
 
    /* datagram packet received for the NT domain log on mailslot */
    if (strequal(smb_buf(buf),NT_LOGON_MAILSLOT)) {
-     process_logon_packet(p,buf2,len);
+     process_logon_packet(p,buf2,len, NT_LOGON_MAILSLOT);
      return;
    }
 }