656da4df201e8ca63ede285eb341ae2608758e47
[samba.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 = (lpcfg_readraw(req->smb_conn->lp_ctx)?1:0) | (lpcfg_writeraw(req->smb_conn->lp_ctx)?2:0);
92
93         smbsrv_setup_reply(req, 13, 0);
94
95         /* Reply, SMBlockread, SMBwritelock supported. */
96         SCVAL(req->out.hdr,HDR_FLG,
97               CVAL(req->out.hdr, HDR_FLG) | FLAG_SUPPORT_LOCKREAD);
98
99         SSVAL(req->out.vwv, VWV(0), choice);
100         SSVAL(req->out.vwv, VWV(1), 0x1); /* user level security, don't encrypt */      
101
102         /* tell redirector we support
103            readbraw and writebraw (possibly) */
104         SSVAL(req->out.vwv, VWV(5), raw); 
105
106         req->smb_conn->negotiate.protocol = PROTOCOL_COREPLUS;
107
108         if (req->smb_conn->signing.mandatory_signing) {
109                 smbsrv_terminate_connection(req->smb_conn, 
110                                             "COREPLUS does not support SMB signing, and it is mandatory\n");
111                 return;
112         }
113
114         smbsrv_send_reply(req);
115 }
116
117 /****************************************************************************
118  Reply for the lanman 1.0 protocol.
119 ****************************************************************************/
120 static void reply_lanman1(struct smbsrv_request *req, uint16_t choice)
121 {
122         int raw = (lpcfg_readraw(req->smb_conn->lp_ctx)?1:0) | (lpcfg_writeraw(req->smb_conn->lp_ctx)?2:0);
123         int secword=0;
124         time_t t = req->request_time.tv_sec;
125
126         req->smb_conn->negotiate.encrypted_passwords = lpcfg_encrypted_passwords(req->smb_conn->lp_ctx);
127
128         if (lpcfg_security(req->smb_conn->lp_ctx) != SEC_SHARE)
129                 secword |= NEGOTIATE_SECURITY_USER_LEVEL;
130
131         if (req->smb_conn->negotiate.encrypted_passwords)
132                 secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE;
133
134         req->smb_conn->negotiate.protocol = PROTOCOL_LANMAN1;
135
136         smbsrv_setup_reply(req, 13, req->smb_conn->negotiate.encrypted_passwords ? 8 : 0);
137
138         /* SMBlockread, SMBwritelock supported. */
139         SCVAL(req->out.hdr,HDR_FLG,
140               CVAL(req->out.hdr, HDR_FLG) | FLAG_SUPPORT_LOCKREAD);
141
142         SSVAL(req->out.vwv, VWV(0), choice);
143         SSVAL(req->out.vwv, VWV(1), secword); 
144         SSVAL(req->out.vwv, VWV(2), req->smb_conn->negotiate.max_recv);
145         SSVAL(req->out.vwv, VWV(3), lpcfg_maxmux(req->smb_conn->lp_ctx));
146         SSVAL(req->out.vwv, VWV(4), 1);
147         SSVAL(req->out.vwv, VWV(5), raw); 
148         SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.id);
149         srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t);
150         SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60);
151         SIVAL(req->out.vwv, VWV(11), 0); /* reserved */
152
153         /* Create a token value and add it to the outgoing packet. */
154         if (req->smb_conn->negotiate.encrypted_passwords) {
155                 NTSTATUS nt_status;
156
157                 SSVAL(req->out.vwv, VWV(11), 8);
158
159                 nt_status = get_challenge(req->smb_conn, req->out.data);
160                 if (!NT_STATUS_IS_OK(nt_status)) {
161                         smbsrv_terminate_connection(req->smb_conn, "LANMAN1 get_challenge failed\n");
162                         return;
163                 }
164         }
165
166         if (req->smb_conn->signing.mandatory_signing) {
167                 smbsrv_terminate_connection(req->smb_conn, 
168                                             "LANMAN1 does not support SMB signing, and it is mandatory\n");
169                 return;
170         }
171
172         smbsrv_send_reply(req); 
173 }
174
175 /****************************************************************************
176  Reply for the lanman 2.0 protocol.
177 ****************************************************************************/
178 static void reply_lanman2(struct smbsrv_request *req, uint16_t choice)
179 {
180         int raw = (lpcfg_readraw(req->smb_conn->lp_ctx)?1:0) | (lpcfg_writeraw(req->smb_conn->lp_ctx)?2:0);
181         int secword=0;
182         time_t t = req->request_time.tv_sec;
183
184         req->smb_conn->negotiate.encrypted_passwords = lpcfg_encrypted_passwords(req->smb_conn->lp_ctx);
185   
186         if (lpcfg_security(req->smb_conn->lp_ctx) != SEC_SHARE)
187                 secword |= NEGOTIATE_SECURITY_USER_LEVEL;
188
189         if (req->smb_conn->negotiate.encrypted_passwords)
190                 secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE;
191
192         req->smb_conn->negotiate.protocol = PROTOCOL_LANMAN2;
193
194         smbsrv_setup_reply(req, 13, 0);
195
196         SSVAL(req->out.vwv, VWV(0), choice);
197         SSVAL(req->out.vwv, VWV(1), secword); 
198         SSVAL(req->out.vwv, VWV(2), req->smb_conn->negotiate.max_recv);
199         SSVAL(req->out.vwv, VWV(3), lpcfg_maxmux(req->smb_conn->lp_ctx));
200         SSVAL(req->out.vwv, VWV(4), 1);
201         SSVAL(req->out.vwv, VWV(5), raw); 
202         SIVAL(req->out.vwv, VWV(6), req->smb_conn->connection->server_id.id);
203         srv_push_dos_date(req->smb_conn, req->out.vwv, VWV(8), t);
204         SSVAL(req->out.vwv, VWV(10), req->smb_conn->negotiate.zone_offset/60);
205         SIVAL(req->out.vwv, VWV(11), 0);
206
207         /* Create a token value and add it to the outgoing packet. */
208         if (req->smb_conn->negotiate.encrypted_passwords) {
209                 SSVAL(req->out.vwv, VWV(11), 8);
210                 req_grow_data(req, 8);
211                 get_challenge(req->smb_conn, req->out.data);
212         }
213
214         req_push_str(req, NULL, lpcfg_workgroup(req->smb_conn->lp_ctx), -1, STR_TERMINATE);
215
216         if (req->smb_conn->signing.mandatory_signing) {
217                 smbsrv_terminate_connection(req->smb_conn, 
218                                             "LANMAN2 does not support SMB signing, and it is mandatory\n");
219                 return;
220         }
221
222         smbsrv_send_reply(req);
223 }
224
225 static void reply_nt1_orig(struct smbsrv_request *req)
226 {
227         /* Create a token value and add it to the outgoing packet. */
228         if (req->smb_conn->negotiate.encrypted_passwords) {
229                 req_grow_data(req, 8);
230                 /* note that we do not send a challenge at all if
231                    we are using plaintext */
232                 get_challenge(req->smb_conn, req->out.ptr);
233                 req->out.ptr += 8;
234                 SCVAL(req->out.vwv+1, VWV(16), 8);
235         }
236         req_push_str(req, NULL, lpcfg_workgroup(req->smb_conn->lp_ctx), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
237         req_push_str(req, NULL, lpcfg_netbios_name(req->smb_conn->lp_ctx), -1, STR_UNICODE|STR_TERMINATE|STR_NOALIGN);
238         DEBUG(3,("not using extended security (SPNEGO or NTLMSSP)\n"));
239 }
240
241 /****************************************************************************
242  Reply for the nt protocol.
243 ****************************************************************************/
244 static void reply_nt1(struct smbsrv_request *req, uint16_t choice)
245 {
246         /* dual names + lock_and_read + nt SMBs + remote API calls */
247         int capabilities;
248         int secword=0;
249         time_t t = req->request_time.tv_sec;
250         NTTIME nttime;
251         bool negotiate_spnego = false;
252         char *large_test_path;
253
254         unix_to_nt_time(&nttime, t);
255
256         capabilities = 
257                 CAP_NT_FIND | CAP_LOCK_AND_READ | 
258                 CAP_LEVEL_II_OPLOCKS | CAP_NT_SMBS | CAP_RPC_REMOTE_APIS;
259
260         req->smb_conn->negotiate.encrypted_passwords = lpcfg_encrypted_passwords(req->smb_conn->lp_ctx);
261
262         /* do spnego in user level security if the client
263            supports it and we can do encrypted passwords */
264         
265         if (req->smb_conn->negotiate.encrypted_passwords && 
266             (lpcfg_security(req->smb_conn->lp_ctx) != SEC_SHARE) &&
267             lpcfg_use_spnego(req->smb_conn->lp_ctx) &&
268             (req->flags2 & FLAGS2_EXTENDED_SECURITY)) {
269                 negotiate_spnego = true; 
270                 capabilities |= CAP_EXTENDED_SECURITY;
271         }
272         
273         if (lpcfg_unix_extensions(req->smb_conn->lp_ctx)) {
274                 capabilities |= CAP_UNIX;
275         }
276         
277         if (lpcfg_large_readwrite(req->smb_conn->lp_ctx)) {
278                 capabilities |= CAP_LARGE_READX | CAP_LARGE_WRITEX | CAP_W2K_SMBS;
279         }
280
281         large_test_path = lock_path(req, req->smb_conn->lp_ctx, "large_test.dat");
282         if (large_file_support(large_test_path)) {
283                 capabilities |= CAP_LARGE_FILES;
284         }
285
286         if (lpcfg_readraw(req->smb_conn->lp_ctx) &&
287             lpcfg_writeraw(req->smb_conn->lp_ctx)) {
288                 capabilities |= CAP_RAW_MODE;
289         }
290         
291         /* allow for disabling unicode */
292         if (lpcfg_unicode(req->smb_conn->lp_ctx)) {
293                 capabilities |= CAP_UNICODE;
294         }
295
296         if (lpcfg_nt_status_support(req->smb_conn->lp_ctx)) {
297                 capabilities |= CAP_STATUS32;
298         }
299         
300         if (lpcfg_host_msdfs(req->smb_conn->lp_ctx)) {
301                 capabilities |= CAP_DFS;
302         }
303         
304         if (lpcfg_security(req->smb_conn->lp_ctx) != SEC_SHARE) {
305                 secword |= NEGOTIATE_SECURITY_USER_LEVEL;
306         }
307
308         if (req->smb_conn->negotiate.encrypted_passwords) {
309                 secword |= NEGOTIATE_SECURITY_CHALLENGE_RESPONSE;
310         }
311
312         if (req->smb_conn->signing.allow_smb_signing) {
313                 secword |= NEGOTIATE_SECURITY_SIGNATURES_ENABLED;
314         }
315
316         if (req->smb_conn->signing.mandatory_signing) {
317                 secword |= NEGOTIATE_SECURITY_SIGNATURES_REQUIRED;
318         }
319         
320         req->smb_conn->negotiate.protocol = PROTOCOL_NT1;
321
322         smbsrv_setup_reply(req, 17, 0);
323         
324         SSVAL(req->out.vwv, VWV(0), choice);
325         SCVAL(req->out.vwv, VWV(1), secword);
326
327         /* notice the strange +1 on vwv here? That's because
328            this is the one and only SMB packet that is malformed in
329            the specification - all the command words after the secword
330            are offset by 1 byte */
331         SSVAL(req->out.vwv+1, VWV(1), lpcfg_maxmux(req->smb_conn->lp_ctx));
332         SSVAL(req->out.vwv+1, VWV(2), 1); /* num vcs */
333         SIVAL(req->out.vwv+1, VWV(3), req->smb_conn->negotiate.max_recv);
334         SIVAL(req->out.vwv+1, VWV(5), 0x10000); /* raw size. full 64k */
335         SIVAL(req->out.vwv+1, VWV(7), req->smb_conn->connection->server_id.id); /* session key */
336         SIVAL(req->out.vwv+1, VWV(9), capabilities);
337         push_nttime(req->out.vwv+1, VWV(11), nttime);
338         SSVALS(req->out.vwv+1,VWV(15), req->smb_conn->negotiate.zone_offset/60);
339         
340         if (!negotiate_spnego) {
341                 reply_nt1_orig(req);
342         } else {
343                 struct cli_credentials *server_credentials;
344                 struct gensec_security *gensec_security;
345                 DATA_BLOB null_data_blob = data_blob(NULL, 0);
346                 DATA_BLOB blob;
347                 const char *oid;
348                 NTSTATUS nt_status;
349                 
350                 server_credentials 
351                         = cli_credentials_init(req);
352                 if (!server_credentials) {
353                         smbsrv_terminate_connection(req->smb_conn, "Failed to init server credentials\n");
354                         return;
355                 }
356                 
357                 cli_credentials_set_conf(server_credentials, req->smb_conn->lp_ctx);
358                 nt_status = cli_credentials_set_machine_account(server_credentials, req->smb_conn->lp_ctx);
359                 if (!NT_STATUS_IS_OK(nt_status)) {
360                         DEBUG(10, ("Failed to obtain server credentials, perhaps a standalone server?: %s\n", nt_errstr(nt_status)));
361                         talloc_free(server_credentials);
362                         server_credentials = NULL;
363                 }
364
365                 nt_status = samba_server_gensec_start(req,
366                                                       req->smb_conn->connection->event.ctx,
367                                                       req->smb_conn->connection->msg_ctx,
368                                                       req->smb_conn->lp_ctx,
369                                                       server_credentials,
370                                                       "cifs",
371                                                       &gensec_security);
372
373                 if (!NT_STATUS_IS_OK(nt_status)) {
374                         DEBUG(0, ("Failed to start GENSEC: %s\n", nt_errstr(nt_status)));
375                         smbsrv_terminate_connection(req->smb_conn, "Failed to start GENSEC\n");
376                         return;
377                 }
378
379                 if (req->smb_conn->negotiate.auth_context) {
380                         smbsrv_terminate_connection(req->smb_conn, "reply_nt1: is this a secondary negprot?  auth_context is non-NULL!\n");
381                         return;
382                 }
383                 req->smb_conn->negotiate.server_credentials = talloc_reparent(req, req->smb_conn, server_credentials);
384
385                 gensec_set_target_service(gensec_security, "cifs");
386
387                 gensec_set_credentials(gensec_security, server_credentials);
388
389                 oid = GENSEC_OID_SPNEGO;
390                 nt_status = gensec_start_mech_by_oid(gensec_security, oid);
391                 
392                 if (NT_STATUS_IS_OK(nt_status)) {
393                         /* Get and push the proposed OID list into the packets */
394                         nt_status = gensec_update(gensec_security, req, null_data_blob, &blob);
395
396                         if (!NT_STATUS_IS_OK(nt_status) && !NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
397                                 DEBUG(1, ("Failed to get SPNEGO to give us the first token: %s\n", nt_errstr(nt_status)));
398                         }
399                 }
400
401                 if (NT_STATUS_EQUAL(nt_status, NT_STATUS_MORE_PROCESSING_REQUIRED)) {
402                         DEBUG(3,("using SPNEGO\n"));
403                 } else {
404                         DEBUG(5, ("Failed to start SPNEGO, falling back to NTLMSSP only: %s\n", nt_errstr(nt_status)));
405                         oid = GENSEC_OID_NTLMSSP;
406                         nt_status = gensec_start_mech_by_oid(gensec_security, oid);
407                         
408                         if (!NT_STATUS_IS_OK(nt_status)) {
409                                 DEBUG(0, ("Failed to start SPNEGO as well as NTLMSSP fallback: %s\n", nt_errstr(nt_status)));
410                                 reply_nt1_orig(req);
411                                 return;
412                         }
413                         /* NTLMSSP is a client-first exchange */
414                         blob = data_blob(NULL, 0);
415                         DEBUG(3,("using raw-NTLMSSP\n"));
416                 }
417
418                 req->smb_conn->negotiate.oid = oid;
419         
420                 req_grow_data(req, blob.length + 16);
421                 /* a NOT very random guid, perhaps we should get it
422                  * from the credentials (kitchen sink...) */
423                 memset(req->out.ptr, '\0', 16);
424                 req->out.ptr += 16;
425
426                 memcpy(req->out.ptr, blob.data, blob.length);
427                 SCVAL(req->out.vwv+1, VWV(16), blob.length + 16);
428                 req->out.ptr += blob.length;
429         }
430         
431         smbsrv_send_reply_nosign(req);  
432 }
433
434 /****************************************************************************
435  Reply for the SMB2 2.001 protocol
436 ****************************************************************************/
437 static void reply_smb2(struct smbsrv_request *req, uint16_t choice)
438 {
439         struct smbsrv_connection *smb_conn = req->smb_conn;
440         NTSTATUS status;
441
442         talloc_free(smb_conn->sessions.idtree_vuid);
443         ZERO_STRUCT(smb_conn->sessions);
444         talloc_free(smb_conn->smb_tcons.idtree_tid);
445         ZERO_STRUCT(smb_conn->smb_tcons);
446         ZERO_STRUCT(smb_conn->signing);
447
448         /* reply with a SMB2 packet */
449         status = smbsrv_init_smb2_connection(smb_conn);
450         if (!NT_STATUS_IS_OK(status)) {
451                 smbsrv_terminate_connection(smb_conn, nt_errstr(status));
452                 talloc_free(req);
453                 return;
454         }
455         packet_set_callback(smb_conn->packet, smbsrv_recv_smb2_request);
456         smb2srv_reply_smb_negprot(req);
457         req = NULL;
458 }
459
460 /* List of supported protocols, most desired first */
461 static const struct {
462         const char *proto_name;
463         const char *short_name;
464         void (*proto_reply_fn)(struct smbsrv_request *req, uint16_t choice);
465         int protocol_level;
466 } supported_protocols[] = {
467         {"SMB 2.002",                   "SMB2",         reply_smb2,     PROTOCOL_SMB2},
468         {"NT LANMAN 1.0",               "NT1",          reply_nt1,      PROTOCOL_NT1},
469         {"NT LM 0.12",                  "NT1",          reply_nt1,      PROTOCOL_NT1},
470         {"LANMAN2.1",                   "LANMAN2",      reply_lanman2,  PROTOCOL_LANMAN2},
471         {"LM1.2X002",                   "LANMAN2",      reply_lanman2,  PROTOCOL_LANMAN2},
472         {"Samba",                       "LANMAN2",      reply_lanman2,  PROTOCOL_LANMAN2},
473         {"DOS LM1.2X002",               "LANMAN2",      reply_lanman2,  PROTOCOL_LANMAN2},
474         {"Windows for Workgroups 3.1a", "LANMAN1",      reply_lanman1,  PROTOCOL_LANMAN1},
475         {"LANMAN1.0",                   "LANMAN1",      reply_lanman1,  PROTOCOL_LANMAN1},
476         {"MICROSOFT NETWORKS 3.0",      "LANMAN1",      reply_lanman1,  PROTOCOL_LANMAN1},
477         {"MICROSOFT NETWORKS 1.03",     "COREPLUS",     reply_coreplus, PROTOCOL_COREPLUS},
478         {"PC NETWORK PROGRAM 1.0",      "CORE",         reply_corep,    PROTOCOL_CORE},
479         {NULL,NULL,NULL,0},
480 };
481
482 /****************************************************************************
483  Reply to a negprot.
484 ****************************************************************************/
485
486 void smbsrv_reply_negprot(struct smbsrv_request *req)
487 {
488         int protocol;
489         uint8_t *p;
490         uint32_t protos_count = 0;
491         char **protos = NULL;
492
493         if (req->smb_conn->negotiate.done_negprot) {
494                 smbsrv_terminate_connection(req->smb_conn, "multiple negprot's are not permitted");
495                 return;
496         }
497         req->smb_conn->negotiate.done_negprot = true;
498
499         p = req->in.data;
500         while (true) {
501                 size_t len;
502
503                 protos = talloc_realloc(req, protos, char *, protos_count + 1);
504                 if (!protos) {
505                         smbsrv_terminate_connection(req->smb_conn, nt_errstr(NT_STATUS_NO_MEMORY));
506                         return;
507                 }
508                 protos[protos_count] = NULL;
509                 len = req_pull_ascii4(&req->in.bufinfo, (const char **)&protos[protos_count], p, STR_ASCII|STR_TERMINATE);
510                 p += len;
511                 if (len == 0 || !protos[protos_count]) break;
512
513                 DEBUG(5,("Requested protocol [%d][%s]\n", protos_count, protos[protos_count]));
514                 protos_count++;
515         }
516
517         /* Check for protocols, most desirable first */
518         for (protocol = 0; supported_protocols[protocol].proto_name; protocol++) {
519                 int i;
520
521                 if (supported_protocols[protocol].protocol_level > lpcfg_srv_maxprotocol(req->smb_conn->lp_ctx))
522                         continue;
523                 if (supported_protocols[protocol].protocol_level < lpcfg_srv_minprotocol(req->smb_conn->lp_ctx))
524                         continue;
525
526                 for (i = 0; i < protos_count; i++) {
527                         if (strcmp(supported_protocols[protocol].proto_name, protos[i]) != 0) continue;
528
529                         supported_protocols[protocol].proto_reply_fn(req, i);
530                         DEBUG(3,("Selected protocol [%d][%s]\n",
531                                 i, supported_protocols[protocol].proto_name));
532                         return;
533                 }
534         }
535
536         smbsrv_terminate_connection(req->smb_conn, "No protocol supported !");
537 }