r5136: fix types
[Samba/gebeck_regimport.git] / source4 / samba3_nmbd.patch
blob772a0f917ebc5a8b99260d8e61d7e818b757009a
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.
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);
16 +int push_components(unsigned char *q, const char *s)
18 + char *p;
19 + int l, len = 0;
21 + if (*s == 0) {
22 + q[0] = 0;
23 + return 1;
24 + }
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 + }
35 + l = strlen(s);
36 + q[0] = l;
37 + memcpy(q+1, s, l+1);
38 + len += strlen(s)+2;
40 + return len;
43 /****************************************************************************
44 Process a domain logon packet
45 **************************************************************************/
47 void process_logon_packet(struct packet_struct *p, char *buf,int len,
48 const char *mailslot)
50 @@ -393,6 +420,8 @@
52 get_mydnsdomname(domain);
53 get_myname(hostname);
55 + pstrcpy(domain, "bludom.tridgell.net");
57 if (SVAL(uniuser, 0) == 0) {
58 SIVAL(q, 0, SAMLOGON_AD_UNK_R); /* user unknown */
59 @@ -403,6 +432,9 @@
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;
68 /* Push Domain GUID */
69 @@ -411,80 +443,34 @@
70 return;
73 + smb_string_to_uuid("b0eac516-4a33-8675-4127-6bf058911234", &domain_guid);
75 + dump_data(0, domain_guid.node, 6);
77 smb_uuid_pack(domain_guid, &flat_guid);
78 memcpy(q, &flat_guid.info, UUID_FLAT_SIZE);
79 - q += UUID_FLAT_SIZE;
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);
93 - /* Unk0 */
94 - SCVAL(q, 0, 0);
95 - q++;
96 + q += UUID_FLAT_SIZE;
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";
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;
112 - /* NETBIOS of domain */
113 - size = push_ascii(&q[1], lp_workgroup(), -1, STR_UPPER);
114 - SCVAL(q, 0, size);
115 - q += (size + 1);
117 - /* Unk1 */
118 - SCVAL(q, 0, 0);
119 - q++;
121 - /* NETBIOS of hostname */
122 - size = push_ascii(&q[1], my_name, -1, 0);
123 - SCVAL(q, 0, size);
124 - q += (size + 1);
126 - /* Unk2 */
127 - SCVAL(q, 0, 0);
128 - q++;
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);
144 + q += push_components(q, "Default-First-Site-Name");
145 + q += push_components(q, "Default-First-Site-Name");
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);
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;
159 - SCVAL(q, 0, PTR_DIFF(q,q1));
160 - SCVAL(q, 1, 0x10); /* unknown */
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
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 */