r4471: Running 'make eparser_idl' doesn't need --header anymore.
[samba.git] / source / samba3_nmbd.patch
1 This is a extremely rough patch that 'fixes' Samba3 nmbd to allow a
2 join from a WinXP client to a Samba4 server. Note that it hard-codes
3 the domain GUID. Please only use for testing Samba4 - do not apply
4 this to Samba3 svn.
5
6
7 Index: nmbd/nmbd_processlogon.c
8 ===================================================================
9 --- nmbd/nmbd_processlogon.c    (revision 4247)
10 +++ nmbd/nmbd_processlogon.c    (working copy)
11 @@ -58,10 +58,37 @@
12          tdb_close(tdb);
13  }
14  
15 +
16 +int push_components(unsigned char *q, const char *s)
17 +{
18 +       char *p;
19 +       int l, len = 0;
20 +
21 +       if (*s == 0) {
22 +               q[0] = 0;
23 +               return 1;
24 +       }
25 +
26 +       while ((p = strchr(s, '.'))) {
27 +               l = (p-s);
28 +               q[0] = l;
29 +               memcpy(q+1, s, l);
30 +               s += l + 1;
31 +               q += l+1;
32 +               len += l+1;
33 +       }
34 +
35 +       l = strlen(s);
36 +       q[0] = l;
37 +       memcpy(q+1, s, l+1);
38 +       len += strlen(s)+2;
39 +
40 +       return len;
41 +}
42 +
43  /****************************************************************************
44  Process a domain logon packet
45  **************************************************************************/
46 -
47  void process_logon_packet(struct packet_struct *p, char *buf,int len, 
48                            const char *mailslot)
49  {
50 @@ -393,6 +420,8 @@
51  
52                                         get_mydnsdomname(domain);
53                                         get_myname(hostname);
54 +
55 +                                       pstrcpy(domain, "bludom.tridgell.net");
56         
57                                         if (SVAL(uniuser, 0) == 0) {
58                                                 SIVAL(q, 0, SAMLOGON_AD_UNK_R); /* user unknown */
59 @@ -403,6 +432,9 @@
60  
61                                         SIVAL(q, 0, ADS_PDC|ADS_GC|ADS_LDAP|ADS_DS|
62                                                 ADS_KDC|ADS_TIMESERV|ADS_CLOSEST|ADS_WRITABLE);
63 +                                       SIVAL(q, 0, 0x3fd);
64 +                                       SIVAL(q, 0, ADS_PDC|ADS_DS|
65 +                                               ADS_TIMESERV|ADS_CLOSEST|ADS_WRITABLE);
66                                         q += 4;
67  
68                                         /* Push Domain GUID */
69 @@ -411,80 +443,34 @@
70                                                 return;
71                                         }
72  
73 +                                       smb_string_to_uuid("b0eac516-4a33-8675-4127-6bf058911234", &domain_guid);
74 +
75 +                                       dump_data(0, domain_guid.node, 6);
76 +
77                                         smb_uuid_pack(domain_guid, &flat_guid);
78                                         memcpy(q, &flat_guid.info, UUID_FLAT_SIZE);
79 -                                       q += UUID_FLAT_SIZE;
80  
81 -                                       /* Forest */
82 -                                       str_offset = q - q_orig;
83 -                                       dc = domain;
84 -                                       q1 = q;
85 -                                       while ((component = strtok(dc, "."))) {
86 -                                               dc = NULL;
87 -                                               size = push_ascii(&q[1], component, -1, 0);
88 -                                               SCVAL(q, 0, size);
89 -                                               q += (size + 1);
90 -                                       }
91 +                                       dump_data(0, q, 16);
92  
93 -                                       /* Unk0 */
94 -                                       SCVAL(q, 0, 0);
95 -                                       q++;
96 +                                       q += UUID_FLAT_SIZE;
97  
98 -                                       /* Domain */
99 -                                       SCVAL(q, 0, 0xc0 | ((str_offset >> 8) & 0x3F));
100 -                                       SCVAL(q, 1, str_offset & 0xFF);
101 -                                       q += 2;
102 +                                       const char *dnsname = "192.168.115.1";
103  
104 -                                       /* Hostname */
105 -                                       size = push_ascii(&q[1], hostname, -1, 0);
106 -                                       SCVAL(q, 0, size);
107 -                                       q += (size + 1);
108 -                                       SCVAL(q, 0, 0xc0 | ((str_offset >> 8) & 0x3F));
109 -                                       SCVAL(q, 1, str_offset & 0xFF);
110 -                                       q += 2;
111 -
112 -                                       /* NETBIOS of domain */
113 -                                       size = push_ascii(&q[1], lp_workgroup(), -1, STR_UPPER);
114 -                                       SCVAL(q, 0, size);
115 -                                       q += (size + 1);
116 -
117 -                                       /* Unk1 */
118 -                                       SCVAL(q, 0, 0);
119 -                                       q++;
120 -
121 -                                       /* NETBIOS of hostname */
122 -                                       size = push_ascii(&q[1], my_name, -1, 0);
123 -                                       SCVAL(q, 0, size);
124 -                                       q += (size + 1);
125 -
126 -                                       /* Unk2 */
127 -                                       SCVAL(q, 0, 0);
128 -                                       q++;
129 -
130 -                                       /* User name */
131 -                                       if (SVAL(uniuser, 0) != 0) {
132 -                                               size = push_ascii(&q[1], ascuser, -1, 0);
133 -                                               SCVAL(q, 0, size);
134 -                                               q += (size + 1);
135 +                                       q += push_components(q, domain);
136 +                                       q += push_components(q, domain);
137 +                                       q += push_components(q, dnsname);
138 +                                       q += push_components(q, lp_workgroup());
139 +                                       q += push_components(q, my_name);
140 +                                       q += push_components(q, "");
141 +                                       if (SVAL(uniuser, 0)) {
142 +                                               q += push_components(q, ascuser);
143                                         }
144 +                                       q += push_components(q, "Default-First-Site-Name");
145 +                                       q += push_components(q, "Default-First-Site-Name");
146  
147 -                                       q_orig = q;
148 -                                       /* Site name */
149 -                                       size = push_ascii(&q[1], "Default-First-Site-Name", -1, 0);
150 -                                       SCVAL(q, 0, size);
151 -                                       q += (size + 1);
152 -
153 -                                       /* Site name (2) */
154 -                                       str_offset = q - q_orig;
155 -                                       SCVAL(q, 0, 0xc0 | ((str_offset >> 8) & 0x3F));
156 -                                       SCVAL(q, 1, str_offset & 0xFF);
157 -                                       q += 2;
158 -
159 -                                       SCVAL(q, 0, PTR_DIFF(q,q1));
160 -                                       SCVAL(q, 1, 0x10); /* unknown */
161 -
162 -                                       SIVAL(q, 0, 0x00000002);
163 -                                       q += 4; /* unknown */
164 +                                       SCVAL(q, 0, 0x10); /* unknown */
165 +                                       SIVAL(q, 1, 0x00000002);
166 +                                       q += 5;
167                                         SIVAL(q, 0, (iface_ip(p->ip))->s_addr);
168                                         q += 4;
169                                         SIVAL(q, 0, 0x00000000);
170 @@ -495,7 +481,7 @@
171  #endif
172  
173                                 /* tell the client what version we are */
174 -                               SIVAL(q, 0, ((ntversion < 11) || (SEC_ADS != lp_security())) ? 1 : 13); 
175 +                               SIVAL(q, 0, 13);
176                                 /* our ntversion */
177                                 SSVAL(q, 4, 0xffff); /* our lmnttoken */ 
178                                 SSVAL(q, 6, 0xffff); /* our lm20token */