~lefteris-nikoltsios/+junk/samba-lp1016895

« back to all changes in this revision

Viewing changes to source4/torture/basic/misc.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2011-12-21 13:18:04 UTC
  • mfrom: (0.39.21 sid)
  • Revision ID: package-import@ubuntu.com-20111221131804-xtlr39wx6njehxxr
Tags: 2:3.6.1-3ubuntu1
* Merge from Debian testing.  Remaining changes:
  + debian/patches/VERSION.patch:
    - set SAMBA_VERSION_SUFFIX to Ubuntu.
  + debian/patches/error-trans.fix-276472:
    - Add the translation of Unix Error code -ENOTSUP to NT Error Code
    - NT_STATUS_NOT_SUPPORTED to prevent the Permission denied error.
  + debian/smb.conf:
    - add "(Samba, Ubuntu)" to server string.
    - comment out the default [homes] share, and add a comment about
      "valid users = %S" to show users how to restrict access to
      \\server\username to only username.
    - Set 'usershare allow guests', so that usershare admins are 
      allowed to create public shares in addition to authenticated
      ones.
    - add map to guest = Bad user, maps bad username to guest access.
  + debian/samba-common.config:
    - Do not change priority to high if dhclient3 is installed.
    - Use priority medium instead of high for the workgroup question.
  + debian/control:
    - Don't build against or suggest ctdb.
    - Add dependency on samba-common-bin to samba.
  + Add ufw integration:
    - Created debian/samba.ufw.profile
    - debian/rules, debian/samba.dirs, debian/samba.files: install
      profile
    - debian/control: have samba suggest ufw
  + Add apport hook:
    - Created debian/source_samba.py.
    - debian/rules, debian/samba.dirs, debian/samba-common-bin.files: install
  + Switch to upstart:
    - Add debian/samba.{nmbd,smbd}.upstart.
  + debian/samba.logrotate, debian/samba-common.dhcp, debian/samba.if-up:
    - Make them upstart compatible
  + debian/samba.postinst: 
    - Avoid scary pdbedit warnings on first import.
  + debian/samba-common.postinst: Add more informative error message for
    the case where smb.conf was manually deleted
  + debian/patches/fix-debuglevel-name-conflict.patch: don't use 'debug_level'
    as a global variable name in an NSS module 
  + Dropped:
    - debian/patches/error-trans.fix-276472
    - debian/patches/fix-debuglevel-name-conflict.patch

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include "libcli/libcli.h"
29
29
#include "lib/events/events.h"
30
30
#include "libcli/resolve/resolve.h"
31
 
#include "auth/credentials/credentials.h"
32
 
#include "librpc/gen_ndr/ndr_nbt.h"
33
31
#include "torture/smbtorture.h"
34
32
#include "torture/util.h"
35
33
#include "libcli/smb_composite/smb_composite.h"
70
68
        generate_random_buffer(buf, sizeof(buf));
71
69
 
72
70
        for (i=0;i<torture_numops;i++) {
73
 
                uint_t n = (uint_t)random()%10;
 
71
                unsigned int n = (unsigned int)random()%10;
74
72
                if (i % 10 == 0) {
75
73
                        if (torture_setting_bool(tctx, "progress", true)) {
76
74
                                torture_comment(tctx, "%d\r", i);
233
231
}
234
232
 
235
233
/*
 
234
  open a file N times on the server and just hold them open
 
235
  used for testing performance when there are N file handles
 
236
  alopenn
 
237
 */
 
238
bool torture_holdopen(struct torture_context *tctx,
 
239
                      struct smbcli_state *cli)
 
240
{
 
241
        int i, fnum;
 
242
        const char *fname = "\\holdopen.dat";
 
243
        NTSTATUS status;
 
244
 
 
245
        smbcli_unlink(cli->tree, fname);
 
246
 
 
247
        fnum = smbcli_open(cli->tree, fname, O_RDWR|O_CREAT|O_EXCL, DENY_NONE);
 
248
        if (fnum == -1) {
 
249
                torture_comment(tctx, "open of %s failed (%s)\n", fname, smbcli_errstr(cli->tree));
 
250
                return false;
 
251
        }
 
252
 
 
253
        smbcli_close(cli->tree, fnum);
 
254
 
 
255
        for (i=0;i<torture_numops;i++) {
 
256
                union smb_open op;
 
257
 
 
258
                op.generic.level = RAW_OPEN_NTCREATEX;
 
259
                op.ntcreatex.in.root_fid.fnum = 0;
 
260
                op.ntcreatex.in.flags = 0;
 
261
                op.ntcreatex.in.access_mask = SEC_FILE_WRITE_DATA;
 
262
                op.ntcreatex.in.create_options = 0;
 
263
                op.ntcreatex.in.file_attr = FILE_ATTRIBUTE_NORMAL;
 
264
                op.ntcreatex.in.share_access = NTCREATEX_SHARE_ACCESS_MASK;
 
265
                op.ntcreatex.in.alloc_size = 0;
 
266
                op.ntcreatex.in.open_disposition = NTCREATEX_DISP_OPEN;
 
267
                op.ntcreatex.in.impersonation = NTCREATEX_IMPERSONATION_ANONYMOUS;
 
268
                op.ntcreatex.in.security_flags = 0;
 
269
                op.ntcreatex.in.fname = fname;
 
270
                status = smb_raw_open(cli->tree, tctx, &op);
 
271
                if (!NT_STATUS_IS_OK(status)) {
 
272
                        torture_warning(tctx, "open %d failed\n", i);
 
273
                        continue;
 
274
                }
 
275
 
 
276
                if (torture_setting_bool(tctx, "progress", true)) {
 
277
                        torture_comment(tctx, "opened %d file\r", i);
 
278
                        fflush(stdout);
 
279
                }
 
280
        }
 
281
 
 
282
        torture_comment(tctx, "\nStarting pings\n");
 
283
 
 
284
        while (1) {
 
285
                struct smb_echo ec;
 
286
 
 
287
                status = smb_raw_echo(cli->transport, &ec);
 
288
                torture_comment(tctx, ".");
 
289
                fflush(stdout);
 
290
                sleep(15);
 
291
        }
 
292
}
 
293
 
 
294
/*
236
295
test how many open files this server supports on the one socket
237
296
*/
238
297
bool run_maxfidtest(struct torture_context *tctx, struct smbcli_state *cli, int dummy)
368
427
        torture_comment(tctx, "ioctl job info: %s\n", smbcli_errstr(cli->tree));
369
428
 
370
429
        for (device=0;device<0x100;device++) {
371
 
                torture_comment(tctx, "testing device=0x%x\n", device);
 
430
                torture_comment(tctx, "Testing device=0x%x\n", device);
372
431
                for (function=0;function<0x100;function++) {
373
432
                        parms.ioctl.in.request = (device << 16) | function;
374
433
                        status = smb_raw_ioctl(cli->tree, mem_ctx, &parms);
424
483
                unsigned int blocksize;
425
484
                unsigned int writeratio;
426
485
                int num_parallel_requests;
427
 
        } *lp_params;
 
486
        } *lpcfg_params;
428
487
};
429
488
 
430
489
/* 
431
 
        init params using lp_parm_xxx 
 
490
        init params using lpcfg_parm_xxx
432
491
        return number of unclist entries
433
492
*/
434
493
static int init_benchrw_params(struct torture_context *tctx,
443
502
        lpar->writeratio = torture_setting_int(tctx, "writeratio",5);
444
503
        lpar->num_parallel_requests = torture_setting_int(
445
504
                tctx, "parallel_requests", 5);
446
 
        lpar->workgroup = lp_workgroup(tctx->lp_ctx);
 
505
        lpar->workgroup = lpcfg_workgroup(tctx->lp_ctx);
447
506
        
448
507
        p = torture_setting_string(tctx, "unclist", NULL);
449
508
        if (p) {
558
617
        union smb_write wr;
559
618
        
560
619
        /* randomize between writes and reads*/
561
 
        if (random() % state->lp_params->writeratio == 0) {
 
620
        if (random() % state->lpcfg_params->writeratio == 0) {
562
621
                torture_comment(tctx, "Callback WRITE file:%d (%d/%d)\n",
563
622
                                state->nr,state->completed,torture_numops);
564
623
                wr.generic.level = RAW_WRITE_WRITEX  ;
566
625
                wr.writex.in.offset     = 0;
567
626
                wr.writex.in.wmode      = 0             ;
568
627
                wr.writex.in.remaining  = 0;
569
 
                wr.writex.in.count      = state->lp_params->blocksize;
 
628
                wr.writex.in.count      = state->lpcfg_params->blocksize;
570
629
                wr.writex.in.data       = state->buffer;
571
630
                state->readcnt=0;
572
631
                req = smb_raw_write_send(state->cli,&wr);
575
634
                torture_comment(tctx,
576
635
                                "Callback READ file:%d (%d/%d) Offset:%d\n",
577
636
                                state->nr,state->completed,torture_numops,
578
 
                                (state->readcnt*state->lp_params->blocksize));
 
637
                                (state->readcnt*state->lpcfg_params->blocksize));
579
638
                rd.generic.level = RAW_READ_READX;
580
639
                rd.readx.in.file.fnum   = state->fnum   ;
581
 
                rd.readx.in.offset      = state->readcnt*state->lp_params->blocksize; 
582
 
                rd.readx.in.mincnt      = state->lp_params->blocksize;
 
640
                rd.readx.in.offset      = state->readcnt*state->lpcfg_params->blocksize;
 
641
                rd.readx.in.mincnt      = state->lpcfg_params->blocksize;
583
642
                rd.readx.in.maxcnt      = rd.readx.in.mincnt;
584
643
                rd.readx.in.remaining   = 0     ;
585
644
                rd.readx.out.data       = state->buffer;
586
645
                rd.readx.in.read_for_execute = false;
587
 
                if(state->readcnt < state->lp_params->writeblocks){
 
646
                if(state->readcnt < state->lpcfg_params->writeblocks){
588
647
                        state->readcnt++;       
589
648
                }else{
590
649
                        /*start reading from beginn of file*/
622
681
        }
623
682
                
624
683
        torture_comment(tctx, "Write initial test file:%d (%d/%d)\n",state->nr,
625
 
                (state->writecnt+1)*state->lp_params->blocksize,
626
 
                (state->lp_params->writeblocks*state->lp_params->blocksize));
 
684
                (state->writecnt+1)*state->lpcfg_params->blocksize,
 
685
                (state->lpcfg_params->writeblocks*state->lpcfg_params->blocksize));
627
686
        wr.generic.level = RAW_WRITE_WRITEX  ;
628
687
        wr.writex.in.file.fnum  = state->fnum ;
629
688
        wr.writex.in.offset     = state->writecnt * 
630
 
                                        state->lp_params->blocksize;
 
689
                                        state->lpcfg_params->blocksize;
631
690
        wr.writex.in.wmode      = 0             ;
632
 
        wr.writex.in.remaining  = (state->lp_params->writeblocks *
633
 
                                                state->lp_params->blocksize)-
 
691
        wr.writex.in.remaining  = (state->lpcfg_params->writeblocks *
 
692
                                                state->lpcfg_params->blocksize)-
634
693
                                                ((state->writecnt+1)*state->
635
 
                                                lp_params->blocksize);
636
 
        wr.writex.in.count      = state->lp_params->blocksize;
 
694
                                                lpcfg_params->blocksize);
 
695
        wr.writex.in.count      = state->lpcfg_params->blocksize;
637
696
        wr.writex.in.data       = state->buffer;
638
697
        state->writecnt++;
639
 
        if(state->writecnt == state->lp_params->writeblocks){
 
698
        if(state->writecnt == state->lpcfg_params->writeblocks){
640
699
                state->mode=READ_WRITE_DATA;
641
700
        }
642
701
        req = smb_raw_write_send(state->cli,&wr);
677
736
        open_parms->openx.in.timeout = 0;
678
737
        open_parms->openx.in.fname = state->fname;
679
738
                
680
 
        writedata = talloc_size(tctx,state->lp_params->blocksize);
 
739
        writedata = talloc_size(tctx,state->lpcfg_params->blocksize);
681
740
        NT_STATUS_HAVE_NO_MEMORY(writedata);
682
 
        generate_random_buffer(writedata,state->lp_params->blocksize);
 
741
        generate_random_buffer(writedata,state->lpcfg_params->blocksize);
683
742
        state->buffer=writedata;
684
743
        state->writecnt=1;
685
744
        state->readcnt=0;
734
793
                break;
735
794
        case READ_WRITE_DATA:
736
795
                while (state->num_parallel_requests
737
 
                       < state->lp_params->num_parallel_requests) {
 
796
                       < state->lpcfg_params->num_parallel_requests) {
738
797
                        NTSTATUS status;
739
798
                        status = benchrw_readwrite(tctx,state);
740
799
                        if (!NT_STATUS_IS_OK(status)){
777
836
{
778
837
        struct benchrw_state *state = con->async.private_data;
779
838
        struct torture_context *tctx = state->tctx;
780
 
        int retry = state->lp_params->retry;
 
839
        int retry = state->lpcfg_params->retry;
781
840
                
782
841
        if (NT_STATUS_IS_OK(con->status)) {
783
842
                state->cli=((struct smb_composite_connect*)
816
875
        torture_comment(tctx, "Open Connection to %s/%s\n",host,share);
817
876
        smb->in.dest_host=talloc_strdup(mem_ctx,host);
818
877
        smb->in.service=talloc_strdup(mem_ctx,share);
819
 
        smb->in.dest_ports=lp_smb_ports(tctx->lp_ctx);
820
 
        smb->in.socket_options = lp_socket_options(tctx->lp_ctx);
 
878
        smb->in.dest_ports=lpcfg_smb_ports(tctx->lp_ctx);
 
879
        smb->in.socket_options = lpcfg_socket_options(tctx->lp_ctx);
821
880
        smb->in.called_name = strupper_talloc(mem_ctx, host);
822
881
        smb->in.service_type=NULL;
823
882
        smb->in.credentials=cmdline_credentials;
824
883
        smb->in.fallback_to_anonymous=false;
825
 
        smb->in.iconv_convenience = lp_iconv_convenience(tctx->lp_ctx);
826
 
        smb->in.gensec_settings = lp_gensec_settings(mem_ctx, tctx->lp_ctx);
 
884
        smb->in.gensec_settings = lpcfg_gensec_settings(mem_ctx, tctx->lp_ctx);
827
885
        smb->in.workgroup=workgroup;
828
 
        lp_smbcli_options(tctx->lp_ctx, &smb->in.options);
829
 
        lp_smbcli_session_options(tctx->lp_ctx, &smb->in.session_options);
 
886
        lpcfg_smbcli_options(tctx->lp_ctx, &smb->in.options);
 
887
        lpcfg_smbcli_session_options(tctx->lp_ctx, &smb->in.session_options);
830
888
        
831
889
        return smb_composite_connect_send(smb,mem_ctx,
832
 
                                          lp_resolve_context(tctx->lp_ctx),ev);
 
890
                                          lpcfg_resolve_context(tctx->lp_ctx),ev);
833
891
}
834
892
 
835
893
bool run_benchrw(struct torture_context *tctx)
855
913
        ev = tctx->ev;
856
914
        state = talloc_array(tctx, struct benchrw_state *, torture_nprocs);
857
915
 
858
 
        /* init params using lp_parm_xxx */
 
916
        /* init params using lpcfg_parm_xxx */
859
917
        num_unc_names = init_benchrw_params(tctx,&lpparams);
860
918
        
861
919
        /* init private data structs*/
864
922
                state[i]->tctx = tctx;
865
923
                state[i]->completed=0;
866
924
                state[i]->num_parallel_requests=0;
867
 
                state[i]->lp_params=&lpparams;
 
925
                state[i]->lpcfg_params=&lpparams;
868
926
                state[i]->nr=i;
869
927
                state[i]->dname=talloc_asprintf(tctx,"benchrw%d",i);
870
928
                state[i]->fname=talloc_asprintf(tctx,"%s%s",