~ubuntu-branches/ubuntu/quantal/samba/quantal

« back to all changes in this revision

Viewing changes to source4/torture/rpc/spoolss.c

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-02-21 09:06:34 UTC
  • mfrom: (0.39.23 sid)
  • Revision ID: package-import@ubuntu.com-20120221090634-svd7q7m33pfz0847
Tags: 2:3.6.3-1ubuntu1
* 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/fix-samba-printer-browsing.patch: No longer needed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#define TORTURE_DRIVER_EX_ADOBE         "torture_driver_ex_adobe"
50
50
#define TORTURE_DRIVER_ADOBE_CUPSADDSMB "torture_driver_adobe_cupsaddsmb"
51
51
#define TORTURE_DRIVER_TIMESTAMPS       "torture_driver_timestamps"
 
52
#define TORTURE_DRIVER_DELETER          "torture_driver_deleter"
 
53
#define TORTURE_DRIVER_DELETERIN        "torture_driver_deleterin"
52
54
 
53
55
#define TOP_LEVEL_PRINT_KEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print"
54
56
#define TOP_LEVEL_PRINT_PRINTERS_KEY TOP_LEVEL_PRINT_KEY "\\Printers"
8922
8924
        return true;
8923
8925
}
8924
8926
 
 
8927
static bool check_printer_driver_file(struct torture_context *tctx,
 
8928
                                      struct smbcli_state *cli,
 
8929
                                      struct torture_driver_context *d,
 
8930
                                      const char *file_name)
 
8931
{
 
8932
        const char *remote_arch_dir = driver_directory_dir(d->remote.driver_directory);
 
8933
        const char *remote_name = talloc_asprintf(tctx, "%s\\%d\\%s",
 
8934
                                                  remote_arch_dir,
 
8935
                                                  d->info8.version,
 
8936
                                                  file_name);
 
8937
        int fnum;
 
8938
 
 
8939
        torture_assert(tctx, (file_name && strlen(file_name) != 0), "invalid filename");
 
8940
 
 
8941
        torture_comment(tctx, "checking for driver file at %s\n", remote_name);
 
8942
 
 
8943
        fnum = smbcli_open(cli->tree, remote_name, O_RDONLY, DENY_NONE);
 
8944
        if (fnum == -1) {
 
8945
                return false;
 
8946
        }
 
8947
 
 
8948
        torture_assert_ntstatus_ok(tctx,
 
8949
                smbcli_close(cli->tree, fnum),
 
8950
                "failed to close driver file");
 
8951
 
 
8952
        return true;
 
8953
}
 
8954
 
 
8955
static bool check_printer_driver_files(struct torture_context *tctx,
 
8956
                                       const char *server_name,
 
8957
                                       struct torture_driver_context *d,
 
8958
                                       bool expect_exist)
 
8959
{
 
8960
        struct smbcli_state *cli;
 
8961
        const char *share_name = driver_directory_share(tctx, d->remote.driver_directory);
 
8962
        int i;
 
8963
 
 
8964
        torture_assert(tctx,
 
8965
                connect_printer_driver_share(tctx, server_name, share_name, &cli),
 
8966
                "failed to connect to driver share");
 
8967
 
 
8968
        torture_comment(tctx, "checking %sexistent driver files at \\\\%s\\%s\n",
 
8969
                        (expect_exist ? "": "non-"),
 
8970
                        server_name, share_name);
 
8971
 
 
8972
        if (d->info8.driver_path && d->info8.driver_path[0]) {
 
8973
                torture_assert(tctx,
 
8974
                        check_printer_driver_file(tctx, cli, d, d->info8.driver_path) == expect_exist,
 
8975
                        "failed driver_path check");
 
8976
        }
 
8977
        if (d->info8.data_file && d->info8.data_file[0]) {
 
8978
                torture_assert(tctx,
 
8979
                        check_printer_driver_file(tctx, cli, d, d->info8.data_file) == expect_exist,
 
8980
                        "failed data_file check");
 
8981
        }
 
8982
        if (d->info8.config_file && d->info8.config_file[0]) {
 
8983
                torture_assert(tctx,
 
8984
                        check_printer_driver_file(tctx, cli, d, d->info8.config_file) == expect_exist,
 
8985
                        "failed config_file check");
 
8986
        }
 
8987
        if (d->info8.help_file && d->info8.help_file[0]) {
 
8988
                torture_assert(tctx,
 
8989
                        check_printer_driver_file(tctx, cli, d, d->info8.help_file) == expect_exist,
 
8990
                        "failed help_file check");
 
8991
        }
 
8992
        if (d->info8.dependent_files) {
 
8993
                for (i=0; d->info8.dependent_files->string && d->info8.dependent_files->string[i] != NULL; i++) {
 
8994
                        torture_assert(tctx,
 
8995
                                check_printer_driver_file(tctx, cli, d, d->info8.dependent_files->string[i]) == expect_exist,
 
8996
                                "failed dependent_files check");
 
8997
                }
 
8998
        }
 
8999
 
 
9000
        talloc_free(cli);
 
9001
 
 
9002
        return true;
 
9003
}
 
9004
 
8925
9005
static bool remove_printer_driver_file(struct torture_context *tctx,
8926
9006
                                       struct smbcli_state *cli,
8927
9007
                                       struct torture_driver_context *d,
9206
9286
{
9207
9287
        struct torture_driver_context *d;
9208
9288
 
 
9289
        if (!torture_setting_bool(tctx, "samba3", false)) {
 
9290
                torture_skip(tctx, "skipping adobe test which only works against samba3");
 
9291
        }
 
9292
 
9209
9293
        d = talloc_zero(tctx, struct torture_driver_context);
9210
9294
 
9211
9295
        d->info8.version                = SPOOLSS_DRIVER_VERSION_9X;
9371
9455
        return true;
9372
9456
}
9373
9457
 
 
9458
static bool test_del_driver_all_files(struct torture_context *tctx,
 
9459
                                      struct dcerpc_pipe *p)
 
9460
{
 
9461
        struct torture_driver_context *d;
 
9462
        struct spoolss_StringArray *a;
 
9463
        uint32_t add_flags = APD_COPY_NEW_FILES;
 
9464
        uint32_t delete_flags = DPD_DELETE_ALL_FILES;
 
9465
        struct dcerpc_binding_handle *b = p->binding_handle;
 
9466
        const char *server_name_slash = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
 
9467
 
 
9468
        d = talloc_zero(tctx, struct torture_driver_context);
 
9469
 
 
9470
        d->ex                           = true;
 
9471
        d->info8.version                = SPOOLSS_DRIVER_VERSION_200X;
 
9472
        d->info8.driver_name            = TORTURE_DRIVER_DELETER;
 
9473
        d->info8.architecture           = NULL;
 
9474
        d->info8.driver_path            = talloc_strdup(d, "pscript5.dll");
 
9475
        d->info8.data_file              = talloc_strdup(d, "cups6.ppd");
 
9476
        d->info8.config_file            = talloc_strdup(d, "cupsui6.dll");
 
9477
        d->info8.help_file              = talloc_strdup(d, "pscript.hlp");
 
9478
        d->local.environment            = talloc_strdup(d, SPOOLSS_ARCHITECTURE_x64);
 
9479
        d->local.driver_directory       = talloc_strdup(d, "/usr/share/cups/drivers/x64");
 
9480
 
 
9481
        a                               = talloc_zero(d, struct spoolss_StringArray);
 
9482
        a->string                       = talloc_zero_array(a, const char *, 3);
 
9483
        a->string[0]                    = talloc_strdup(a->string, "cups6.inf");
 
9484
        a->string[1]                    = talloc_strdup(a->string, "cups6.ini");
 
9485
 
 
9486
        d->info8.dependent_files        = a;
 
9487
        d->info8.architecture           = d->local.environment;
 
9488
 
 
9489
        torture_assert(tctx,
 
9490
                fillup_printserver_info(tctx, p, d),
 
9491
                "failed to fillup printserver info");
 
9492
 
 
9493
        if (!directory_exist(d->local.driver_directory)) {
 
9494
                torture_skip(tctx, "Skipping Printer Driver test as no local driver is available");
 
9495
        }
 
9496
 
 
9497
        torture_assert(tctx,
 
9498
                upload_printer_driver(tctx, dcerpc_server_name(p), d),
 
9499
                "failed to upload printer driver");
 
9500
 
 
9501
        torture_assert(tctx,
 
9502
                test_AddPrinterDriver_args_level_3(tctx, b, server_name_slash, &d->info8, add_flags, true, NULL),
 
9503
                "failed to add driver");
 
9504
 
 
9505
        torture_assert(tctx,
 
9506
                test_DeletePrinterDriverEx(tctx, b, server_name_slash,
 
9507
                                           d->info8.driver_name,
 
9508
                                           d->local.environment,
 
9509
                                           delete_flags,
 
9510
                                           d->info8.version),
 
9511
                "failed to delete driver");
 
9512
 
 
9513
        torture_assert(tctx,
 
9514
                check_printer_driver_files(tctx, dcerpc_server_name(p), d, false),
 
9515
                "printer driver file check failed");
 
9516
 
 
9517
        talloc_free(d);
 
9518
        return true;
 
9519
}
 
9520
 
 
9521
static bool test_del_driver_unused_files(struct torture_context *tctx,
 
9522
                                         struct dcerpc_pipe *p)
 
9523
{
 
9524
        struct torture_driver_context *d1;
 
9525
        struct torture_driver_context *d2;
 
9526
        uint32_t add_flags = APD_COPY_NEW_FILES;
 
9527
        struct dcerpc_binding_handle *b = p->binding_handle;
 
9528
        const char *server_name_slash = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p));
 
9529
 
 
9530
        d1 = talloc_zero(tctx, struct torture_driver_context);
 
9531
        d1->ex                          = true;
 
9532
        d1->info8.version               = SPOOLSS_DRIVER_VERSION_200X;
 
9533
        d1->info8.driver_name           = TORTURE_DRIVER_DELETER;
 
9534
        d1->info8.architecture          = NULL;
 
9535
        d1->info8.driver_path           = talloc_strdup(d1, "pscript5.dll");
 
9536
        d1->info8.data_file             = talloc_strdup(d1, "cups6.ppd");
 
9537
        d1->info8.config_file           = talloc_strdup(d1, "cupsui6.dll");
 
9538
        d1->info8.help_file             = talloc_strdup(d1, "pscript.hlp");
 
9539
        d1->local.environment           = talloc_strdup(d1, SPOOLSS_ARCHITECTURE_x64);
 
9540
        d1->local.driver_directory      = talloc_strdup(d1, "/usr/share/cups/drivers/x64");
 
9541
        d1->info8.architecture          = d1->local.environment;
 
9542
 
 
9543
        d2 = talloc_zero(tctx, struct torture_driver_context);
 
9544
        d2->ex                          = true;
 
9545
        d2->info8.version               = SPOOLSS_DRIVER_VERSION_200X;
 
9546
        d2->info8.driver_name           = TORTURE_DRIVER_DELETERIN;
 
9547
        d2->info8.architecture          = NULL;
 
9548
        d2->info8.driver_path           = talloc_strdup(d2, "pscript5.dll");    /* overlapping */
 
9549
        d2->info8.data_file             = talloc_strdup(d2, "cupsps6.dll");
 
9550
        d2->info8.config_file           = talloc_strdup(d2, "cups6.ini");
 
9551
        d2->info8.help_file             = talloc_strdup(d2, "pscript.hlp");     /* overlapping */
 
9552
        d2->local.environment           = talloc_strdup(d2, SPOOLSS_ARCHITECTURE_x64);
 
9553
        d2->local.driver_directory      = talloc_strdup(d2, "/usr/share/cups/drivers/x64");
 
9554
        d2->info8.architecture          = d2->local.environment;
 
9555
 
 
9556
        torture_assert(tctx,
 
9557
                fillup_printserver_info(tctx, p, d1),
 
9558
                "failed to fillup printserver info");
 
9559
        torture_assert(tctx,
 
9560
                fillup_printserver_info(tctx, p, d2),
 
9561
                "failed to fillup printserver info");
 
9562
 
 
9563
        if (!directory_exist(d1->local.driver_directory)) {
 
9564
                torture_skip(tctx, "Skipping Printer Driver test as no local driver is available");
 
9565
        }
 
9566
 
 
9567
        torture_assert(tctx,
 
9568
                upload_printer_driver(tctx, dcerpc_server_name(p), d1),
 
9569
                "failed to upload printer driver");
 
9570
        torture_assert(tctx,
 
9571
                test_AddPrinterDriver_args_level_3(tctx, b, server_name_slash, &d1->info8, add_flags, true, NULL),
 
9572
                "failed to add driver");
 
9573
 
 
9574
        torture_assert(tctx,
 
9575
                upload_printer_driver(tctx, dcerpc_server_name(p), d2),
 
9576
                "failed to upload printer driver");
 
9577
        torture_assert(tctx,
 
9578
                test_AddPrinterDriver_args_level_3(tctx, b, server_name_slash, &d2->info8, add_flags, true, NULL),
 
9579
                "failed to add driver");
 
9580
 
 
9581
        /* some files are in use by a separate driver, should fail */
 
9582
        torture_assert(tctx,
 
9583
                test_DeletePrinterDriverEx_exp(tctx, b, server_name_slash,
 
9584
                                               d1->info8.driver_name,
 
9585
                                               d1->local.environment,
 
9586
                                               DPD_DELETE_ALL_FILES,
 
9587
                                               d1->info8.version,
 
9588
                                               WERR_PRINTER_DRIVER_IN_USE),
 
9589
                "invalid delete driver response");
 
9590
 
 
9591
        /* should only delete files not in use by other driver */
 
9592
        torture_assert(tctx,
 
9593
                test_DeletePrinterDriverEx_exp(tctx, b, server_name_slash,
 
9594
                                               d1->info8.driver_name,
 
9595
                                               d1->local.environment,
 
9596
                                               DPD_DELETE_UNUSED_FILES,
 
9597
                                               d1->info8.version,
 
9598
                                               WERR_OK),
 
9599
                "failed to delete driver (unused files)");
 
9600
 
 
9601
        /* check non-overlapping were deleted */
 
9602
        d1->info8.driver_path = NULL;
 
9603
        d1->info8.help_file = NULL;
 
9604
        torture_assert(tctx,
 
9605
                check_printer_driver_files(tctx, dcerpc_server_name(p), d1, false),
 
9606
                "printer driver file check failed");
 
9607
        /* d2 files should be uneffected */
 
9608
        torture_assert(tctx,
 
9609
                check_printer_driver_files(tctx, dcerpc_server_name(p), d2, true),
 
9610
                "printer driver file check failed");
 
9611
 
 
9612
        torture_assert(tctx,
 
9613
                test_DeletePrinterDriverEx_exp(tctx, b, server_name_slash,
 
9614
                                               d2->info8.driver_name,
 
9615
                                               d2->local.environment,
 
9616
                                               DPD_DELETE_ALL_FILES,
 
9617
                                               d2->info8.version,
 
9618
                                               WERR_OK),
 
9619
                "failed to delete driver");
 
9620
 
 
9621
        torture_assert(tctx,
 
9622
                check_printer_driver_files(tctx, dcerpc_server_name(p), d2, false),
 
9623
                "printer driver file check failed");
 
9624
 
 
9625
        talloc_free(d1);
 
9626
        talloc_free(d2);
 
9627
        return true;
 
9628
}
 
9629
 
9374
9630
struct torture_suite *torture_rpc_spoolss_driver(TALLOC_CTX *mem_ctx)
9375
9631
{
9376
9632
        struct torture_suite *suite = torture_suite_create(mem_ctx, "spoolss.driver");
9391
9647
 
9392
9648
        torture_rpc_tcase_add_test(tcase, "multiple_drivers", test_multiple_drivers);
9393
9649
 
 
9650
        torture_rpc_tcase_add_test(tcase, "del_driver_all_files", test_del_driver_all_files);
 
9651
 
 
9652
        torture_rpc_tcase_add_test(tcase, "del_driver_unused_files", test_del_driver_unused_files);
 
9653
 
9394
9654
        return suite;
9395
9655
}