d4a1dc9c084f09abcf352ce000f37aafffc73922
[kai/samba-autobuild/.git] / source4 / smb_server / smb / negprot.c
1 /* 
2    Unix SMB/CIFS implementation.
3    negprot reply code
4    Copyright (C) Andrew Tridgell 1992-1998
5    
6    This program is free software; you can redistribute it and/or modify
7    it under the terms of the GNU General Public License as published by
8    the Free Software Foundation; either version 3 of the License, or
9    (at your option) any later version.
10    
11    This program is distributed in the hope that it will be useful,
12    but WITHOUT ANY WARRANTY; without even the implied warranty of
13    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14    GNU General Public License for more details.
15    
16    You should have received a copy of the GNU General Public License
17    along with this program.  If not, see <http://www.gnu.org/licenses/>.
18 */
19
20 #include "includes.h"
21 #include "auth/credentials/credentials.h"
22 #include "auth/gensec/gensec.h"
23 #include "auth/auth.h"
24 #include "smb_server/smb_server.h"
25 #include "libcli/smb2/smb2.h"
26 #include "smb_server/smb2/smb2_server.h"
27 #include "smbd/service_stream.h"
28 #include "lib/stream/packet.h"
29 #include "param/param.h"
30
31
32 /* initialise the auth_context for this server and return the cryptkey */
33 static NTSTATUS get_challenge(struct smbsrv_connection *smb_conn, uint8_t buff[8]) 
34 {
35         NTSTATUS nt_status;
36
37         /* muliple negprots are not premitted */
38         if (smb_conn->negotiate.auth_context) {
39                 DEBUG(3,("get challenge: is this a secondary negprot?  auth_context is non-NULL!\n"));
40                 return NT_STATUS_FOOBAR;
41         }
42
43         DEBUG(10, ("get challenge: creating negprot_global_auth_context\n"));
44
45         nt_status = auth_context_create(smb_conn, 
46                                         smb_conn->connection->event.ctx,
47                                         smb_conn->connection->msg_ctx,
48                                         smb_conn->lp_ctx,
49                                         &smb_conn->negotiate.auth_context);
50         if (!NT_STATUS_IS_OK(nt_status)) {
51                 DEBUG(0, ("auth_context_create() returned %s", nt_errstr(nt_status)));
52                 return nt_status;
53         }
54
55         nt_status = auth_get_challenge(smb_conn->negotiate.auth_context, buff);
56         if (!NT_STATUS_IS_OK(nt_status)) {
57                 DEBUG(0, ("auth_get_challenge() returned %s", nt_errstr(nt_status)));
58                 return nt_status;
59         }
60
61         return NT_STATUS_OK;
62 }
63
64 /****************************************************************************
65  Reply for the core protocol.
66 ****************************************************************************/
67 static void reply_corep(struct smbsrv_request *req, uint16_t choice)
68 {
69         smbsrv_setup_reply(req, 1, 0);
70
71         SSVAL(req->out.vwv, VWV(0), choice);
72
73         req->smb_conn->negotiate.protocol = PROTOCOL_CORE;
74
75         if (req->smb_conn->signing.mandatory_signing) {
76                 smbsrv_terminate_connection(req->smb_conn, 
77                                             "CORE does not support SMB signing, and it is mandatory\n");
78                 return;
79         }
80
81         smbsrv_send_reply(req);
82 }
83
84 /****************************************************************************
85  Reply for the coreplus protocol.
86 this is quite incomplete - we only fill in a small part of the reply, but as nobody uses
87 this any more it probably doesn't matter
88 ****************************************************************************/
89 static void reply_coreplus(struct smbsrv_request *req, uint16_t choice)
90 {
91         uint16_t raw;
92         if (lpcfg_async_smb_echo_handler(req->smb_conn->lp_ctx)) {
93                 raw = 0;
94         } else {
95                 raw = (lpcfg_read_raw(req->smb_conn->lp_ctx)?1:0) |
96                       (lpcfg_write_raw(req->smb_conn->lp_ctx)?2:0);
97         }
98
99         smbsrv_setup_reply(req, 13, 0);
100
101         /* Reply, SMBlockread, SMBwritelock supported. */
102         SCVAL(req->out.hdr,HDR_FLG,
103               CVAL(req->out.hdr, HDR_FLG) | FLAG_SUPPORT_LOCKREAD);
104
105         SSVAL(req->out.vwv, VWV(0), choice);
106         SSVAL(req->out.vwv, VWV(1), 0x1); /* user level security, don't encrypt */      
107
108         /* tell redirector we support
109            readbraw and writebraw (possibly) */
110         SSVAL(req->out.vwv, VWV(5), raw); 
111
112         req->smb_conn->negotiate.protocol = PROTOCOL_COREPLUS;
113
114         if (req->smb_conn->signing.mandatory_signing) {
115                 smbsrv_terminate_connection(req->smb_conn, 
116                                             "COREPLUS does not support SMB signing, and it is mandatory\n");
117                 return;
118         }
119
120         smbsrv_send_reply(req);
121 }
122
123 /****************************************************************************
124  Reply for the lanman 1.0 protocol.
125 ****************************************************************************/
126 static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
127 {
128         uint16_t raw;
129         if (lpcfg_async_smb_echo_handler(req->smb_conn->lp_ctx)) {
130                 raw = 0;
131         } else {
132                 raw = (lpcfg_read_raw(req->smb_conn->lp_ctx)?1:0) |
133                       (lpcfg_write_raw(req->smb_conn->lp_ctx)?2:0);
134         }
135         int secword=0;
136         time_t t = req->request_time.tv_sec;
137
138         req->smb_conn->negotiate.encrypted_passwords = lpcfg_encrypt_passwords(req->smb_conn->lp_ctx);
139
140         if (req->smb_conn->negotiate.encrypted_passwords)
141                 secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE;
142
143         req->smb_conn->negotiate.protocol = PROTOCOL_LANMAN1;
144
145         smbsrv_setup_reply(req, 13, req->smb_conn->negotiate.encrypted_passwords ? 8 : 0);
146
147         /* SMBlockread, SMBwritelock supported. */
148         SCVAL(req->out.hdr,HDR_FLG,
149               CVAL(req->out.hdr, HDR_FLG) | FLAG_SUPPORT_LOCKREAD);
150
151         SSVAL(req->out.vwv, VWV(0), choice);
152         SSVAL(req->out.vwv, VWV(1), secword); 
153         SSVAL(req->out.vwv, VWV(2), req->smb_conn->negotiate.max_recv);
154         SSVAL(req->out.vwv, VWV(3), lpcfg_max_mux(req->smb_conn->lp_ctx));
155         SSVAL(req->out.vwv, VWV(4), 1);
156         SSVAL(req->out.vwv, VWV(5), raw); 
157         SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.pid);
158         srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t);
159         SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60);
160         SIVAL(req->out.vwv, VWV(11), 0); /* reserved */
161
162         /* Create a token value and add it to the outgoing packet. */
163         if (req->smb_conn->negotiate.encrypted_passwords) {
164                 NTSTATUS nt_status;
165
166                 SSVAL(req->out.vwv, VWV(11), 8);
167
168                 nt_status = get_challenge(req->smb_conn, req->out.data);
169                 if (!NT_STATUS_IS_OK(nt_status)) {
170                         smbsrv_terminate_connection(req->smb_conn, "LANMAN1 get_challenge failed\n");
171                         return;
172                 }
173         }
174
175         if (req->smb_conn->signing.mandatory_signing) {
176                 smbsrv_terminate_connection(req->smb_conn, 
177                                             "LANMAN1 does not support SMB signing, and it is mandatory\n");
178                 return;
179         }
180
181         smbsrv_send_reply(req); 
182 }
183
184 /****************************************************************************
185  Reply for the lanman 2.0 protocol.
186 ****************************************************************************/
187 static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
188 {
189         int secword=0;
190         time_t t = req->request_time.tv_sec;
191         uint16_t raw;
192         if (lpcfg_async_smb_echo_handler(req->smb_conn->lp_ctx)) {
193                 raw = 0;
194         } else {
195                 raw = (lpcfg_read_raw(req->smb_conn->lp_ctx)?1:0) |
196                       (lpcfg_write_raw(req->smb_conn->lp_ctx)?2:0);
197         }
198
199         req->smb_conn->negotiate.encrypted_passwords = lpcfg_encrypt_passwords(req->smb_conn->lp_ctx);
200   
201         if (req->smb_conn->negotiate.encrypted_passwords)
202                 secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE;
203
204         req->smb_conn->negotiate.protocol = PROTOCOL_LANMAN2;
205
206         smbsrv_setup_reply(req, 13, 0);
207
208         SSVAL(req->out.vwv, VWV(0), choice);
209         SSVAL(req->out.vwv, VWV(1), secword); 
210         SSVAL(req->out.vwv, VWV(2), req->smb_conn->negotiate.max_recv);
211         SSVAL(req->out.vwv, VWV(3), lpcfg_max_mux(req->smb_conn->lp_ctx));
212         SSVAL(req->out.vwv, VWV(4), 1);
213         SSVAL(req->out.vwv, VWV(5), raw); 
214         SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.pid);
215         srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t);
216         SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60);
217         SIVAL(req->out.vwv, VWV(11), 0);
218
219         /* Create a token value and add it to the outgoing packet. */
220         if (req->smb_conn->negotiate.encrypted_passwords) {
221                 SSVAL(req->out.vwv, VWV(11), 8);
222                 req_grow_data(req, 8);
223                 get_challenge(req->smb_conn, req->out.data);
224         }
225
226         req_push_str(req, NULL, lpcfg_workgroup(req->smb_conn->lp_ctx), -1, STR_TERMINATE);
227
228         if (req->smb_conn->signing.mandatory_signing) {
229                 smbsrv_terminate_connection(req->smb_conn, 
230                                             "LANMAN2 does not support SMB signing, and it is mandatory\n");
231                 return;
232         }
233
234         smbsrv_send_reply(req);
235 }
236
237 static void reply_nt1_orig(struct smbsrv_request *req)
238 {
239         /* Create a token value and add it to the outgoing packet. */
240         if (req->smb_conn->negotiate.encrypted_passwords) {
241                 req_grow_data(req, 8);
242                 /* note that we do not send a challenge at all if
243                    we are using plaintext */
244                 get_challenge(req->smb_conn, req->out.ptr);
245                 req->out.ptr += 8;
246                 SCVAL(req->out.vwv+1, VWV(16), 8);
247         }
248         req_push_str(req, NULL, lpcfg_workgroup(req->smb_conn->lp_ctx), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
249         req_push_str(req, NULL, lpcfg_netbios_name(req->smb_conn->lp_ctx), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
250         DEBUG(3,("not using extended security (SPNEGO or NTLMSSP)\n"));
251 }
252
253 /****************************************************************************
254  Reply for the nt protocol.
255 ****************************************************************************/
256 static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
257 {
258         /* dual names + lock_and_read + nt SMBs + remote API calls */
259         int capabilities;
260         int secword=0;
261         time_t t = req->request_time.tv_sec;
262         NTTIME nttime;
263         bool negotiate_spnego = false;
264         char *large_test_path;
265
266         unix_to_nt_time(&nttime, t);
267
268         capabilities = 
269                 CAP_NT_FIND | CAP_LOCK_AND_READ | 
270                 CAP_LEVEL_II_OPLOCKS | CAP_NT_SMBS | CAP_RPC_REMOTE_APIS;
271
272         req->smb_conn->negotiate.encrypted_passwords = lpcfg_encrypt_passwords(req->smb_conn->lp_ctx);
273
274         /* do spnego in user level security if the client
275            supports it and we can do encrypted passwords */
276         
277         if (req->smb_conn->negotiate.encrypted_passwords && 
278             lpcfg_use_spnego(req->smb_conn->lp_ctx) &&
279             (req->flags2 & FLAGS2_EXTENDED_SECURITY)) {
280                 negotiate_spnego = true; 
281                 capabilities |= CAP_EXTENDED_SECURITY;
282         }
283         
284         if (lpcfg_large_readwrite(req->smb_conn->lp_ctx)) {
285                 capabilities |= CAP_LARGE_READX | CAP_LARGE_WRITEX | CAP_W2K_SMBS;
286         }
287
288         large_test_path = lpcfg_lock_path(req, req->smb_conn->lp_ctx, "large_test.dat");
289         if (large_file_support(large_test_path)) {
290                 capabilities |= CAP_LARGE_FILES;
291         }
292
293         if (!lpcfg_async_smb_echo_handler(req->smb_conn->lp_ctx) &&
294             lpcfg_read_raw(req->smb_conn->lp_ctx) &&
295             lpcfg_write_raw(req->smb_conn->lp_ctx)) {
296                 capabilities |= CAP_RAW_MODE;
297         }
298         
299         /* allow for disabling unicode */
300         if (lpcfg_unicode(req->smb_conn->lp_ctx)) {
301                 capabilities |= CAP_UNICODE;
302         }
303
304         if (lpcfg_nt_status_support(req->smb_conn->lp_ctx)) {
305                 capabilities |= CAP_STATUS32;
306         }
307         
308         if (lpcfg_host_msdfs(req->smb_conn->lp_ctx)) {
309                 capabilities |= CAP_DFS;
310         }
311         
312         secword |= NEGOTIATE_SECURITY_USER_LEVEL;
313
314         if (req->smb_conn->negotiate.encrypted_passwords) {
315                 secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE;
316         }
317
318         if (req->smb_conn->signing.allow_smb_signing) {
319                 secword |= NEGOTIATE_SECURITY_SIGNATURES_ENABLED;
320         }
321
322         if (req->smb_conn->signing.mandatory_signing) {
323                 secword |= NEGOTIATE_SECURITY_SIGNATURES_REQUIRED;
324         }
325         
326         req->smb_conn->negotiate.protocol = PROTOCOL_NT1;
327
328         smbsrv_setup_reply(req, 17, 0);
329         
330         SSVAL(req->out.vwv, VWV(0), choice);
331         SCVAL(req->out.vwv, VWV(1), secword);
332
333         /* notice the strange +1 on vwv here? That's because
334            this is the one and only SMB packet that is malformed in
335            the specification - all the command words after the secword
336            are offset by 1 byte */
337         SSVAL(req->out.vwv+1, VWV(1), lpcfg_max_mux(req->smb_conn->lp_ctx));
338         SSVAL(req->out.vwv+1, VWV(2), 1); /* num vcs */
339         SIVAL(req->out.vwv+1, VWV(3), req->smb_conn->negotiate.max_recv);
340         SIVAL(req->out.vwv+1, VWV(5), 0x10000); /* raw size. full 64k */
341         SIVAL(req->out.vwv+1, VWV(7), req->smb_conn->connection->server_id.pid); /* session key */
342
343         SIVAL(req->out.vwv+1, VWV(9), capabilities);
344         push_nttime(req->out.vwv+1, VWV(11), nttime);
345         SSVALS(req->out.vwv+1,VWV(15), req->smb_conn->negotiate.zone_offset/60);
346         
347         if (!negotiate_spnego) {
348                 reply_nt1_orig(req);
349         } else {
350                 struct cli_credentials *server_credentials;
351                 struct gensec_security *gensec_security;
352                 DATA_BLOB null_data_blob = data_blob(NULL, 0);
353                 DATA_BLOB blob;
354                 const char *oid;
355                 NTSTATUS nt_status;
356                 
357                 server_credentials 
358                         = cli_credentials_init(req);
359                 if (!server_credentials) {
360                         smbsrv_terminate_connection(req->smb_conn, "Failed to init server credentials\n");
361                         return;
362                 }
363                 
364                 cli_credentials_set_conf(server_credentials, req->smb_conn->lp_ctx);
365                 nt_status = cli_credentials_set_machine_account(server_credentials, req->smb_conn->lp_ctx);
366                 if (!NT_STATUS_IS_OK(nt_status)) {
367                         DEBUG(10, ("Failed to obtain server credentials, perhaps a standalone server?: %s\n", nt_errstr(nt_status)));
368                         talloc_free(server_credentials);
369                         server_credentials = NULL;
370                 }
371
372                 nt_status = samba_server_gensec_start(req,
373                                                       req->smb_conn->connection->event.ctx,
374                                                       req->smb_conn->connection->msg_ctx,
375                                                       req->smb_conn->lp_ctx,
376                                                       server_credentials,
377                                                       "cifs",
378                                                       &gensec_security);
379
380                 if (!NT_STATUS_IS_OK(nt_status)) {
381                         DEBUG(0, ("Failed to start GENSEC: %s\n", nt_errstr(nt_status)));
382                         smbsrv_terminate_connection(req->smb_conn, "Failed to start GENSEC\n");
383                         return;
384                 }
385
386                 if (req->smb_conn->negotiate.auth_context) {
387                         smbsrv_terminate_connection(req->smb_conn, "reply_nt1: is this a secondary negprot?  auth_context is non-NULL!\n");
388                         return;
389                 }
390                 req->smb_conn->negotiate.server_credentials = talloc_reparent(req, req->smb_conn, server_credentials);
391
392                 oid = GENSEC_OID_SPNEGO;
393                 nt_status = gensec_start_mech_by_oid(gensec_security, oid);
394                 
395                 if (NT_STATUS_IS_OK(nt_status)) {
396                         /* Get and push the proposed OID list into the packets */
397                         nt_status = gensec_update(gensec_security, req, req->smb_conn->connection->event.ctx, null_data_blob, &blob);
398
399                         if (!NT_STATUS_IS_OK(nt_status) && !NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
400                                 DEBUG(1, ("Failed to get SPNEGO to give us the first token: %s\n", nt_errstr(nt_status)));
401                         }
402                 }
403
404                 if (NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
405                         DEBUG(3,("using SPNEGO\n"));
406                 } else {
407                         DEBUG(5, ("Failed to start SPNEGO, falling back to NTLMSSP only: %s\n", nt_errstr(nt_status)));
408                         oid = GENSEC_OID_NTLMSSP;
409                         nt_status = gensec_start_mech_by_oid(gensec_security, oid);
410                         
411                         if (!NT_STATUS_IS_OK(nt_status)) {
412                                 DEBUG(0, ("Failed to start SPNEGO as well as NTLMSSP fallback: %s\n", nt_errstr(nt_status)));
413                                 reply_nt1_orig(req);
414                                 return;
415                         }
416                         /* NTLMSSP is a client-first exchange */
417                         blob = data_blob(NULL, 0);
418                         DEBUG(3,("using raw-NTLMSSP\n"));
419                 }
420
421                 req->smb_conn->negotiate.oid = oid;
422         
423                 req_grow_data(req, blob.length + 16);
424                 /* a NOT very random guid, perhaps we should get it
425                  * from the credentials (kitchen sink...) */
426                 memset(req->out.ptr, '\0', 16);
427                 req->out.ptr += 16;
428
429                 memcpy(req->out.ptr, blob.data, blob.length);
430                 SCVAL(req->out.vwv+1, VWV(16), blob.length + 16);
431                 req->out.ptr += blob.length;
432         }
433         
434         smbsrv_send_reply_nosign(req);  
435 }
436
437 /****************************************************************************
438  Reply for the SMB2 2.001 protocol
439 ****************************************************************************/
440 static void reply_smb2(struct smbsrv_request *req, uint16_t choice)
441 {
442         struct smbsrv_connection *smb_conn = req->smb_conn;
443         NTSTATUS status;
444
445         talloc_free(smb_conn->sessions.idtree_vuid);
446         ZERO_STRUCT(smb_conn->sessions);
447         talloc_free(smb_conn->smb_tcons.idtree_tid);
448         ZERO_STRUCT(smb_conn->smb_tcons);
449         ZERO_STRUCT(smb_conn->signing);
450
451         /* reply with a SMB2 packet */
452         status = smbsrv_init_smb2_connection(smb_conn);
453         if (!NT_STATUS_IS_OK(status)) {
454                 smbsrv_terminate_connection(smb_conn, nt_errstr(status));
455                 talloc_free(req);
456                 return;
457         }
458         packet_set_callback(smb_conn->packet, smbsrv_recv_smb2_request);
459         smb2srv_reply_smb_negprot(req);
460         req = NULL;
461 }
462
463 /* List of supported protocols, most desired first */
464 static const struct {
465         const char *proto_name;
466         const char *short_name;
467         void (*proto_reply_fn)(struct smbsrv_request *req, uint16_t choice);
468         int protocol_level;
469 } supported_protocols[] = {
470         {"SMB 2.002",                   "SMB2",         reply_smb2,     PROTOCOL_SMB2_02},
471         {"NT LANMAN 1.0",               "NT1",          reply_nt1,      PROTOCOL_NT1},
472         {"NT LM 0.12",                  "NT1",          reply_nt1,      PROTOCOL_NT1},
473         {"LANMAN2.1",                   "LANMAN2",      reply_lanman2,  PROTOCOL_LANMAN2},
474         {"LM1.2X002",                   "LANMAN2",      reply_lanman2,  PROTOCOL_LANMAN2},
475         {"Samba",                       "LANMAN2",      reply_lanman2,  PROTOCOL_LANMAN2},
476         {"DOS LM1.2X002",               "LANMAN2",      reply_lanman2,  PROTOCOL_LANMAN2},
477         {"Windows for Workgroups 3.1a", "LANMAN1",      reply_lanman1,  PROTOCOL_LANMAN1},
478         {"LANMAN1.0",                   "LANMAN1",      reply_lanman1,  PROTOCOL_LANMAN1},
479         {"MICROSOFT NETWORKS 3.0",      "LANMAN1",      reply_lanman1,  PROTOCOL_LANMAN1},
480         {"MICROSOFT NETWORKS 1.03",     "COREPLUS",     reply_coreplus, PROTOCOL_COREPLUS},
481         {"PC NETWORK PROGRAM 1.0",      "CORE",         reply_corep,    PROTOCOL_CORE},
482         {NULL,NULL,NULL,0},
483 };
484
485 /****************************************************************************
486  Reply to a negprot.
487 ****************************************************************************/
488
489 void smbsrv_reply_negprot(struct smbsrv_request *req)
490 {
491         int protocol;
492         uint8_t *p;
493         uint32_t protos_count = 0;
494         char **protos = NULL;
495
496         if (req->smb_conn->negotiate.done_negprot) {
497                 smbsrv_terminate_connection(req->smb_conn, "multiple negprot's are not permitted");
498                 return;
499         }
500         req->smb_conn->negotiate.done_negprot = true;
501
502         p = req->in.data;
503         while (true) {
504                 size_t len;
505
506                 protos = talloc_realloc(req, protos, char *, protos_count + 1);
507                 if (!protos) {
508                         smbsrv_terminate_connection(req->smb_conn, nt_errstr(NT_STATUS_NO_MEMORY));
509                         return;
510                 }
511                 protos[protos_count] = NULL;
512                 len = req_pull_ascii4(&req->in.bufinfo, (const char **)&protos[protos_count], p, STR_ASCII|STR_TERMINATE);
513                 p += len;
514                 if (len == 0 || !protos[protos_count]) break;
515
516                 DEBUG(5,("Requested protocol [%d][%s]\n", protos_count, protos[protos_count]));
517                 protos_count++;
518         }
519
520         /* Check for protocols, most desirable first */
521         for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) {
522                 int i;
523
524                 if (supported_protocols[protocol].protocol_level > lpcfg_server_max_protocol(req->smb_conn->lp_ctx))
525                         continue;
526                 if (supported_protocols[protocol].protocol_level < lpcfg_server_min_protocol(req->smb_conn->lp_ctx))
527                         continue;
528
529                 for (i = 0; i < protos_count; i++) {
530                         if (strcmp(supported_protocols[protocol].proto_name, protos[i]) != 0) continue;
531
532                         supported_protocols[protocol].proto_reply_fn(req, i);
533                         DEBUG(3,("Selected protocol [%d][%s]\n",
534                                 i, supported_protocols[protocol].proto_name));
535                         return;
536                 }
537         }
538
539         smbsrv_terminate_connection(req->smb_conn, "No protocol supported !");
540 }