Merge branch 'v4-0-test' of ssh://git.samba.org/data/git/samba into v4-0-gmake3
[gd/samba-autobuild/.git] / source4 / torture / locktest.c
1 /* 
2    Unix SMB/CIFS implementation.
3    randomised byte range lock tester
4    Copyright (C) Andrew Tridgell 1999
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 "lib/cmdline/popt_common.h"
22 #include "lib/events/events.h"
23 #include "system/filesys.h"
24 #include "system/time.h"
25 #include "pstring.h"
26 #include "auth/credentials/credentials.h"
27 #include "auth/gensec/gensec.h"
28 #include "libcli/libcli.h"
29 #include "param/param.h"
30 #include "dynconfig.h"
31 #include "libcli/resolve/resolve.h"
32
33 static int numops = 1000;
34 static int showall;
35 static int analyze;
36 static int hide_unlock_fails;
37 static int use_oplocks;
38 static uint_t lock_range = 100;
39 static uint_t lock_base = 0;
40 static uint_t min_length = 0;
41 static int exact_error_codes;
42 static int zero_zero;
43
44 #define FILENAME "\\locktest.dat"
45
46 #define READ_PCT 50
47 #define LOCK_PCT 45
48 #define UNLOCK_PCT 70
49 #define RANGE_MULTIPLE 1
50 #define NSERVERS 2
51 #define NCONNECTIONS 2
52 #define NFILES 2
53 #define LOCK_TIMEOUT 0
54
55 static struct cli_credentials *servers[NSERVERS];
56
57 enum lock_op {OP_LOCK, OP_UNLOCK, OP_REOPEN};
58
59 struct record {
60         enum lock_op lock_op;
61         enum brl_type lock_type;
62         char conn, f;
63         uint64_t start, len;
64         char needed;
65         uint16_t pid;
66 };
67
68 #define PRESETS 0
69
70 #if PRESETS
71 static struct record preset[] = {
72 {OP_LOCK, WRITE_LOCK, 0, 0, 2, 0, 1},
73 {OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1},
74 {OP_LOCK, WRITE_LOCK, 0, 0, 3, 0, 1},
75 {OP_UNLOCK, 0       , 0, 0, 2, 0, 1},
76 {OP_REOPEN, 0, 0, 0, 0, 0, 1},
77
78 {OP_LOCK, READ_LOCK, 0, 0, 2, 0, 1},
79 {OP_LOCK, READ_LOCK, 0, 0, 1, 1, 1},
80 {OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1},
81 {OP_REOPEN, 0, 0, 0, 0, 0, 1},
82
83 {OP_LOCK, READ_LOCK, 0, 0, 2, 0, 1},
84 {OP_LOCK, WRITE_LOCK, 0, 0, 3, 1, 1},
85 {OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1},
86 {OP_REOPEN, 0, 0, 0, 0, 0, 1},
87
88 {OP_LOCK, READ_LOCK, 0, 0, 2, 0, 1},
89 {OP_LOCK, WRITE_LOCK, 0, 0, 1, 1, 1},
90 {OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1},
91 {OP_REOPEN, 0, 0, 0, 0, 0, 1},
92
93 {OP_LOCK, WRITE_LOCK, 0, 0, 2, 0, 1},
94 {OP_LOCK, READ_LOCK, 0, 0, 1, 1, 1},
95 {OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1},
96 {OP_REOPEN, 0, 0, 0, 0, 0, 1},
97
98 {OP_LOCK, WRITE_LOCK, 0, 0, 2, 0, 1},
99 {OP_LOCK, READ_LOCK, 0, 0, 3, 1, 1},
100 {OP_LOCK, WRITE_LOCK, 0, 0, 0, 0, 1},
101 {OP_REOPEN, 0, 0, 0, 0, 0, 1},
102
103 };
104 #endif
105
106 static struct record *recorded;
107
108 /***************************************************** 
109 return a connection to a server
110 *******************************************************/
111 static struct smbcli_state *connect_one(struct event_context *ev,
112                                         struct loadparm_context *lp_ctx,
113                                         char *share, int snum, int conn)
114 {
115         struct smbcli_state *c;
116         fstring server, myname;
117         NTSTATUS status;
118         int retries = 10;
119         struct smbcli_options options;
120
121         lp_smbcli_options(lp_ctx, &options);
122
123         printf("connect_one(%s, %d, %d)\n", share, snum, conn);
124
125         fstrcpy(server,share+2);
126         share = strchr_m(server,'\\');
127         if (!share) return NULL;
128         *share = 0;
129         share++;
130
131         if (snum == 0) {
132                 char **unc_list = NULL;
133                 int num_unc_names;
134                 const char *p;
135                 p = lp_parm_string(lp_ctx, NULL, "torture", "unclist");
136                 if (p) {
137                         char *h, *s;
138                         unc_list = file_lines_load(p, &num_unc_names, NULL);
139                         if (!unc_list || num_unc_names <= 0) {
140                                 printf("Failed to load unc names list from '%s'\n", p);
141                                 exit(1);
142                         }
143
144                         if (!smbcli_parse_unc(unc_list[conn % num_unc_names],
145                                               NULL, &h, &s)) {
146                                 printf("Failed to parse UNC name %s\n",
147                                        unc_list[conn % num_unc_names]);
148                                 exit(1);
149                         }
150                         fstrcpy(server, h);
151                         fstrcpy(share, s);
152                 }
153         }
154
155
156         slprintf(myname,sizeof(myname), "lock-%u-%u", getpid(), snum);
157         cli_credentials_set_workstation(servers[snum], myname, CRED_SPECIFIED);
158
159         do {
160                 printf("\\\\%s\\%s\n", server, share);
161                 status = smbcli_full_connection(NULL, &c, 
162                                                 server, 
163                                                 lp_smb_ports(lp_ctx),
164                                                 share, NULL,
165                                                 servers[snum], 
166                                                 lp_resolve_context(lp_ctx),
167                                                 ev, &options);
168                 if (!NT_STATUS_IS_OK(status)) {
169                         sleep(2);
170                 }
171         } while (!NT_STATUS_IS_OK(status) && retries--);
172
173         if (!NT_STATUS_IS_OK(status)) {
174                 return NULL;
175         }
176
177         return c;
178 }
179
180
181 static void reconnect(struct event_context *ev,
182                       struct loadparm_context *lp_ctx,
183                       struct smbcli_state *cli[NSERVERS][NCONNECTIONS], int fnum[NSERVERS][NCONNECTIONS][NFILES],
184                       char *share[NSERVERS])
185 {
186         int server, conn, f;
187
188         for (server=0;server<NSERVERS;server++)
189         for (conn=0;conn<NCONNECTIONS;conn++) {
190                 if (cli[server][conn]) {
191                         for (f=0;f<NFILES;f++) {
192                                 if (fnum[server][conn][f] != -1) {
193                                         smbcli_close(cli[server][conn]->tree, fnum[server][conn][f]);
194                                         fnum[server][conn][f] = -1;
195                                 }
196                         }
197                         talloc_free(cli[server][conn]);
198                 }
199                 cli[server][conn] = connect_one(ev, lp_ctx, share[server], 
200                                                 server, conn);
201                 if (!cli[server][conn]) {
202                         DEBUG(0,("Failed to connect to %s\n", share[server]));
203                         exit(1);
204                 }
205         }
206 }
207
208
209
210 static bool test_one(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], 
211                      int fnum[NSERVERS][NCONNECTIONS][NFILES],
212                      struct record *rec)
213 {
214         uint_t conn = rec->conn;
215         uint_t f = rec->f;
216         uint64_t start = rec->start;
217         uint64_t len = rec->len;
218         enum brl_type op = rec->lock_type;
219         int server;
220         bool ret[NSERVERS];
221         NTSTATUS status[NSERVERS];
222
223         switch (rec->lock_op) {
224         case OP_LOCK:
225                 /* set a lock */
226                 for (server=0;server<NSERVERS;server++) {
227                         NTSTATUS res;
228                         struct smbcli_tree *tree=cli[server][conn]->tree;
229                         int fn=fnum[server][conn][f];
230
231                         if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
232                                 res=smbcli_lock(tree, fn, start, len, LOCK_TIMEOUT, rec->lock_op);
233                         } else {
234                                 union smb_lock parms;
235                                 int ltype;
236                                 struct smb_lock_entry lock[1];
237
238                                 parms.lockx.level = RAW_LOCK_LOCKX;
239                                 parms.lockx.in.file.fnum = fn;
240         
241                                 ltype = (rec->lock_op == READ_LOCK? 1 : 0);
242                                 ltype |= LOCKING_ANDX_LARGE_FILES;
243                                 parms.lockx.in.mode = ltype;
244                                 parms.lockx.in.timeout = LOCK_TIMEOUT;
245                                 parms.lockx.in.ulock_cnt = 0;
246                                 parms.lockx.in.lock_cnt = 1;
247                                 lock[0].pid = rec->pid;
248                                 lock[0].offset = start;
249                                 lock[0].count = len;
250                                 parms.lockx.in.locks = &lock[0];
251
252                                 res = smb_raw_lock(tree, &parms);
253                         }
254
255                         ret[server] = NT_STATUS_IS_OK(res); 
256                         status[server] = smbcli_nt_error(cli[server][conn]->tree);
257                         if (!exact_error_codes && 
258                             NT_STATUS_EQUAL(status[server], 
259                                             NT_STATUS_FILE_LOCK_CONFLICT)) {
260                                 status[server] = NT_STATUS_LOCK_NOT_GRANTED;
261                         }
262                 }
263                 if (showall || !NT_STATUS_EQUAL(status[0],status[1])) {
264                         printf("lock   conn=%u f=%u range=%.0f(%.0f) op=%s -> %s:%s\n",
265                                conn, f, 
266                                (double)start, (double)len,
267                                op==READ_LOCK?"READ_LOCK":"WRITE_LOCK",
268                                nt_errstr(status[0]), nt_errstr(status[1]));
269                 }
270                 if (!NT_STATUS_EQUAL(status[0],status[1])) return false;
271                 break;
272                 
273         case OP_UNLOCK:
274                 /* unset a lock */
275                 for (server=0;server<NSERVERS;server++) {
276                         NTSTATUS res;
277                         struct smbcli_tree *tree=cli[server][conn]->tree;
278                         int fn=fnum[server][conn][f];
279
280
281                         if (!(tree->session->transport->negotiate.capabilities & CAP_LARGE_FILES)) {
282                                 res=smbcli_unlock(tree, fn, start, len);
283                         } else {
284                                 union smb_lock parms;
285                                 struct smb_lock_entry lock[1];
286
287                                 parms.lockx.level = RAW_LOCK_LOCKX;
288                                 parms.lockx.in.file.fnum = fn;
289                                 parms.lockx.in.mode = LOCKING_ANDX_LARGE_FILES;
290                                 parms.lockx.in.timeout = 0;
291                                 parms.lockx.in.ulock_cnt = 1;
292                                 parms.lockx.in.lock_cnt = 0;
293                                 lock[0].pid = rec->pid;
294                                 lock[0].count = len;
295                                 lock[0].offset = start;
296                                 parms.lockx.in.locks = &lock[0];
297
298                                 res = smb_raw_lock(tree, &parms);
299                         }
300
301                         ret[server] = NT_STATUS_IS_OK(res);
302                         status[server] = smbcli_nt_error(cli[server][conn]->tree);
303                 }
304                 if (showall || 
305                     (!hide_unlock_fails && !NT_STATUS_EQUAL(status[0],status[1]))) {
306                         printf("unlock conn=%u f=%u range=%.0f(%.0f)       -> %s:%s\n",
307                                conn, f, 
308                                (double)start, (double)len,
309                                nt_errstr(status[0]), nt_errstr(status[1]));
310                 }
311                 if (!hide_unlock_fails && !NT_STATUS_EQUAL(status[0],status[1])) 
312                         return false;
313                 break;
314
315         case OP_REOPEN:
316                 /* reopen the file */
317                 for (server=0;server<NSERVERS;server++) {
318                         smbcli_close(cli[server][conn]->tree, fnum[server][conn][f]);
319                         fnum[server][conn][f] = -1;
320                 }
321                 for (server=0;server<NSERVERS;server++) {
322                         fnum[server][conn][f] = smbcli_open(cli[server][conn]->tree, FILENAME,
323                                                          O_RDWR|O_CREAT,
324                                                          DENY_NONE);
325                         if (fnum[server][conn][f] == -1) {
326                                 printf("failed to reopen on share%d\n", server);
327                                 return false;
328                         }
329                 }
330                 if (showall) {
331                         printf("reopen conn=%u f=%u\n",
332                                conn, f);
333                 }
334                 break;
335         }
336
337         return true;
338 }
339
340 static void close_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], 
341                         int fnum[NSERVERS][NCONNECTIONS][NFILES])
342 {
343         int server, conn, f; 
344
345         for (server=0;server<NSERVERS;server++)
346         for (conn=0;conn<NCONNECTIONS;conn++)
347         for (f=0;f<NFILES;f++) {
348                 if (fnum[server][conn][f] != -1) {
349                         smbcli_close(cli[server][conn]->tree, fnum[server][conn][f]);
350                         fnum[server][conn][f] = -1;
351                 }
352         }
353         for (server=0;server<NSERVERS;server++) {
354                 smbcli_unlink(cli[server][0]->tree, FILENAME);
355         }
356 }
357
358 static void open_files(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], 
359                        int fnum[NSERVERS][NCONNECTIONS][NFILES])
360 {
361         int server, conn, f; 
362
363         for (server=0;server<NSERVERS;server++)
364         for (conn=0;conn<NCONNECTIONS;conn++)
365         for (f=0;f<NFILES;f++) {
366                 fnum[server][conn][f] = smbcli_open(cli[server][conn]->tree, FILENAME,
367                                                  O_RDWR|O_CREAT,
368                                                  DENY_NONE);
369                 if (fnum[server][conn][f] == -1) {
370                         fprintf(stderr,"Failed to open fnum[%u][%u][%u]\n",
371                                 server, conn, f);
372                         exit(1);
373                 }
374         }
375 }
376
377
378 static int retest(struct smbcli_state *cli[NSERVERS][NCONNECTIONS], 
379                    int fnum[NSERVERS][NCONNECTIONS][NFILES],
380                    int n)
381 {
382         int i;
383         printf("testing %u ...\n", n);
384         for (i=0; i<n; i++) {
385                 if (i && i % 100 == 0) {
386                         printf("%u\n", i);
387                 }
388
389                 if (recorded[i].needed &&
390                     !test_one(cli, fnum, &recorded[i])) return i;
391         }
392         return n;
393 }
394
395
396 /* each server has two connections open to it. Each connection has two file
397    descriptors open on the file - 8 file descriptors in total 
398
399    we then do random locking ops in tamdem on the 4 fnums from each
400    server and ensure that the results match
401  */
402 static int test_locks(struct event_context *ev,
403                       struct loadparm_context *lp_ctx,
404                       char *share[NSERVERS])
405 {
406         struct smbcli_state *cli[NSERVERS][NCONNECTIONS];
407         int fnum[NSERVERS][NCONNECTIONS][NFILES];
408         int n, i, n1, skip, r1, r2; 
409
410         ZERO_STRUCT(fnum);
411         ZERO_STRUCT(cli);
412
413         recorded = malloc_array_p(struct record, numops);
414
415         for (n=0; n<numops; n++) {
416 #if PRESETS
417                 if (n < sizeof(preset) / sizeof(preset[0])) {
418                         recorded[n] = preset[n];
419                 } else {
420 #endif
421                         recorded[n].conn = random() % NCONNECTIONS;
422                         recorded[n].f = random() % NFILES;
423                         recorded[n].start = lock_base + ((uint_t)random() % (lock_range-1));
424                         recorded[n].len =  min_length +
425                                 random() % (lock_range-(recorded[n].start-lock_base));
426                         recorded[n].start *= RANGE_MULTIPLE;
427                         recorded[n].len *= RANGE_MULTIPLE;
428                         recorded[n].pid = random()%3;
429                         if (recorded[n].pid == 2) {
430                                 recorded[n].pid = 0xFFFF; /* see if its magic */
431                         }
432                         r1 = random() % 100;
433                         r2 = random() % 100;
434                         if (r1 < READ_PCT) {
435                                 recorded[n].lock_type = READ_LOCK;
436                         } else {
437                                 recorded[n].lock_type = WRITE_LOCK;
438                         }
439                         if (r2 < LOCK_PCT) {
440                                 recorded[n].lock_op = OP_LOCK;
441                         } else if (r2 < UNLOCK_PCT) {
442                                 recorded[n].lock_op = OP_UNLOCK;
443                         } else {
444                                 recorded[n].lock_op = OP_REOPEN;
445                         }
446                         recorded[n].needed = true;
447                         if (!zero_zero && recorded[n].start==0 && recorded[n].len==0) {
448                                 recorded[n].len = 1;
449                         }
450 #if PRESETS
451                 }
452 #endif
453         }
454
455         reconnect(ev, lp_ctx, cli, fnum, share);
456         open_files(cli, fnum);
457         n = retest(cli, fnum, numops);
458
459         if (n == numops || !analyze) {
460                 if (n != numops) {
461                         return 1;
462                 }
463                 return 0;
464         }
465         n++;
466
467         skip = n/2;
468
469         while (1) {
470                 n1 = n;
471
472                 close_files(cli, fnum);
473                 reconnect(ev, lp_ctx, cli, fnum, share);
474                 open_files(cli, fnum);
475
476                 for (i=0;i<n-skip;i+=skip) {
477                         int m, j;
478                         printf("excluding %d-%d\n", i, i+skip-1);
479                         for (j=i;j<i+skip;j++) {
480                                 recorded[j].needed = false;
481                         }
482
483                         close_files(cli, fnum);
484                         open_files(cli, fnum);
485
486                         m = retest(cli, fnum, n);
487                         if (m == n) {
488                                 for (j=i;j<i+skip;j++) {
489                                         recorded[j].needed = true;
490                                 }
491                         } else {
492                                 if (i+(skip-1) < m) {
493                                         memmove(&recorded[i], &recorded[i+skip],
494                                                 (m-(i+skip-1))*sizeof(recorded[0]));
495                                 }
496                                 n = m-(skip-1);
497                                 i--;
498                         }
499                 }
500
501                 if (skip > 1) {
502                         skip = skip/2;
503                         printf("skip=%d\n", skip);
504                         continue;
505                 }
506
507                 if (n1 == n) break;
508         }
509
510         close_files(cli, fnum);
511         reconnect(ev, lp_ctx, cli, fnum, share);
512         open_files(cli, fnum);
513         showall = true;
514         n1 = retest(cli, fnum, n);
515         if (n1 != n-1) {
516                 printf("ERROR - inconsistent result (%u %u)\n", n1, n);
517         }
518         close_files(cli, fnum);
519
520         for (i=0;i<n;i++) {
521                 printf("{%d, %d, %u, %u, %.0f, %.0f, %u},\n",
522                        recorded[i].lock_op,
523                        recorded[i].lock_type,
524                        recorded[i].conn,
525                        recorded[i].f,
526                        (double)recorded[i].start,
527                        (double)recorded[i].len,
528                        recorded[i].needed);
529         }       
530
531         return 1;
532 }
533
534
535
536 static void usage(poptContext pc)
537 {
538         printf("Usage:\n\tlocktest //server1/share1 //server2/share2 [options..]\n");
539         poptPrintUsage(pc, stdout, 0);
540 }
541
542 /****************************************************************************
543   main program
544 ****************************************************************************/
545  int main(int argc,char *argv[])
546 {
547         char *share[NSERVERS];
548         int opt;
549         int seed, server;
550         int username_count=0;
551         struct event_context *ev;
552         struct loadparm_context *lp_ctx;
553         poptContext pc;
554         int argc_new, i;
555         char **argv_new;
556         enum {OPT_UNCLIST=1000};
557         struct poptOption long_options[] = {
558                 POPT_AUTOHELP
559                 {"seed",          0, POPT_ARG_INT,  &seed,      0,      "Seed to use for randomizer",   NULL},
560                 {"num-ops",       0, POPT_ARG_INT,  &numops,    0,      "num ops",      NULL},
561                 {"lockrange",     0, POPT_ARG_INT,  &lock_range,0,      "locking range", NULL},
562                 {"lockbase",      0, POPT_ARG_INT,  &lock_base, 0,      "locking base", NULL},
563                 {"minlength",     0, POPT_ARG_INT,  &min_length,0,      "min lock length", NULL},
564                 {"hidefails",     0, POPT_ARG_NONE, &hide_unlock_fails,0,"hide unlock fails", NULL},
565                 {"oplocks",       0, POPT_ARG_NONE, &use_oplocks,0,      "use oplocks", NULL},
566                 {"showall",       0, POPT_ARG_NONE, &showall,    0,      "display all operations", NULL},
567                 {"analyse",       0, POPT_ARG_NONE, &analyze,    0,      "do backtrack analysis", NULL},
568                 {"zerozero",      0, POPT_ARG_NONE, &zero_zero,    0,      "do zero/zero lock", NULL},
569                 {"exacterrors",   0, POPT_ARG_NONE, &exact_error_codes,0,"use exact error codes", NULL},
570                 {"unclist",       0, POPT_ARG_STRING,   NULL,   OPT_UNCLIST,    "unclist",      NULL},
571                 { "user", 'U',       POPT_ARG_STRING, NULL, 'U', "Set the network username", "[DOMAIN/]USERNAME[%PASSWORD]" },
572                 POPT_COMMON_SAMBA
573                 POPT_COMMON_CONNECTION
574                 POPT_COMMON_CREDENTIALS
575                 POPT_COMMON_VERSION
576                 { NULL }
577         };
578
579         setlinebuf(stdout);
580         seed = time(NULL);
581
582         pc = poptGetContext("locktest", argc, (const char **) argv, long_options, 
583                             POPT_CONTEXT_KEEP_FIRST);
584
585         poptSetOtherOptionHelp(pc, "<unc1> <unc2>");
586
587         lp_ctx = cmdline_lp_ctx;
588         servers[0] = cli_credentials_init(talloc_autofree_context());
589         servers[1] = cli_credentials_init(talloc_autofree_context());
590         cli_credentials_guess(servers[0], lp_ctx);
591         cli_credentials_guess(servers[1], lp_ctx);
592
593         while((opt = poptGetNextOpt(pc)) != -1) {
594                 switch (opt) {
595                 case OPT_UNCLIST:
596                         lp_set_cmdline(cmdline_lp_ctx, "torture:unclist", poptGetOptArg(pc));
597                         break;
598                 case 'U':
599                         if (username_count == 2) {
600                                 usage(pc);
601                                 exit(1);
602                         }
603                         cli_credentials_parse_string(servers[username_count], poptGetOptArg(pc), CRED_SPECIFIED);
604                         username_count++;
605                         break;
606                 }
607         }
608
609         argv_new = discard_const_p(char *, poptGetArgs(pc));
610         argc_new = argc;
611         for (i=0; i<argc; i++) {
612                 if (argv_new[i] == NULL) {
613                         argc_new = i;
614                         break;
615                 }
616         }
617
618         if (!(argc_new >= 3)) {
619                 usage(pc);
620                 exit(1);
621         }
622
623         setup_logging("locktest", DEBUG_STDOUT);
624
625         for (server=0;server<NSERVERS;server++) {
626                 share[server] = argv_new[1+server];
627                 all_string_sub(share[server],"/","\\",0);
628         }
629
630         lp_ctx = cmdline_lp_ctx;
631
632         if (username_count == 0) {
633                 usage(pc);
634                 return -1;
635         }
636         if (username_count == 1) {
637                 servers[1] = servers[0];
638         }
639
640         ev = event_context_init(talloc_autofree_context());
641
642         gensec_init(lp_ctx);
643
644         DEBUG(0,("seed=%u base=%d range=%d min_length=%d\n", 
645                  seed, lock_base, lock_range, min_length));
646         srandom(seed);
647
648         return test_locks(ev, lp_ctx, share);
649 }
650