Changeset 752 for trunk/server/source4/torture/rpc
- Timestamp:
- Nov 29, 2012, 2:06:31 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 746,748
- Property svn:mergeinfo changed
-
trunk/server/source4/torture/rpc/samba3rpc.c
r745 r752 775 775 DATA_BLOB confounded_session_key = data_blob_talloc( 776 776 mem_ctx, NULL, 16); 777 struct MD5Contextctx;777 MD5_CTX ctx; 778 778 uint8_t confounder[16]; 779 779 -
trunk/server/source4/torture/rpc/samlogon.c
r745 r752 1076 1076 uint8_t client_chall[8]; 1077 1077 1078 struct MD5Contextmd5_session_nonce_ctx;1078 MD5_CTX md5_session_nonce_ctx; 1079 1079 HMACMD5Context hmac_ctx; 1080 1080 -
trunk/server/source4/torture/rpc/samr.c
r745 r752 772 772 char *newpass; 773 773 struct dcerpc_binding_handle *b = p->binding_handle; 774 struct MD5Contextctx;774 MD5_CTX ctx; 775 775 struct samr_GetUserPwInfo pwp; 776 776 struct samr_PwInfo info; … … 857 857 DATA_BLOB session_key; 858 858 DATA_BLOB confounded_session_key = data_blob_talloc(tctx, NULL, 16); 859 struct MD5Contextctx;859 MD5_CTX ctx; 860 860 uint8_t confounder[16]; 861 861 char *newpass; … … 1141 1141 DATA_BLOB session_key; 1142 1142 DATA_BLOB confounded_session_key = data_blob_talloc(tctx, NULL, 16); 1143 struct MD5Contextctx;1143 MD5_CTX ctx; 1144 1144 uint8_t confounder[16]; 1145 1145 char *newpass; … … 2459 2459 DATA_BLOB confounded_session_key = data_blob_talloc(tctx, NULL, 16); 2460 2460 uint8_t confounder[16]; 2461 struct MD5Contextctx;2461 MD5_CTX ctx; 2462 2462 2463 2463 bool ret = true; -
trunk/server/source4/torture/rpc/spoolss.c
r745 r752 36 36 #include "libcli/raw/raw_proto.h" 37 37 #include "libcli/resolve/resolve.h" 38 #include "libcli/smb2/smb2.h" 39 #include "libcli/smb2/smb2_calls.h" 38 40 #include "lib/cmdline/popt_common.h" 39 41 #include "system/filesys.h" 40 42 #include "torture/ndr/ndr.h" 43 #include "torture/smb2/proto.h" 41 44 42 45 #define TORTURE_WELLKNOWN_PRINTER "torture_wkn_printer" … … 50 53 #define TORTURE_DRIVER_ADOBE_CUPSADDSMB "torture_driver_adobe_cupsaddsmb" 51 54 #define TORTURE_DRIVER_TIMESTAMPS "torture_driver_timestamps" 55 #define TORTURE_DRIVER_DELETER "torture_driver_deleter" 56 #define TORTURE_DRIVER_DELETERIN "torture_driver_deleterin" 57 #define TORTURE_PRINTER_STATIC1 "print1" 52 58 53 59 #define TOP_LEVEL_PRINT_KEY "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print" … … 5498 5504 TEST_SET_SZ("description", comment, "newval"); 5499 5505 TEST_SET_SZ("location", location, "newval"); 5506 TEST_SET_SZ("driverName", drivername, "newval"); 5500 5507 /* TEST_SET_DWORD("priority", priority, 25); */ 5501 5508 … … 7724 7731 } 7725 7732 7726 static bool test_printer_sd(struct torture_context *tctx, 7727 void *private_data) 7733 /* use smbd file IO to spool a print job */ 7734 static bool test_print_test_smbd(struct torture_context *tctx, 7735 void *private_data) 7728 7736 { 7729 7737 struct torture_printer_context *t = … … 7731 7739 struct dcerpc_pipe *p = t->spoolss_pipe; 7732 7740 struct dcerpc_binding_handle *b = p->binding_handle; 7733 7734 torture_assert(tctx, 7735 test_PrinterInfo_SD(tctx, b, &t->handle), 7736 "failed to test security descriptors"); 7737 7738 return true; 7739 } 7740 7741 static bool test_printer_dm(struct torture_context *tctx, 7741 NTSTATUS status; 7742 uint32_t count; 7743 union spoolss_JobInfo *info = NULL; 7744 int i; 7745 7746 struct smb2_tree *tree; 7747 struct smb2_handle job_h; 7748 struct cli_credentials *credentials = cmdline_credentials; 7749 struct smbcli_options options; 7750 TALLOC_CTX *mem_ctx = talloc_new(tctx); 7751 /* 7752 * Do not test against the dynamically added printers, printing via 7753 * smbd means that a different spoolss process may handle the 7754 * OpenPrinter request to the one that handled the AddPrinter request. 7755 * This currently leads to an ugly race condition where one process 7756 * sees the new printer and one doesn't. 7757 */ 7758 const char *share = TORTURE_PRINTER_STATIC1; 7759 7760 torture_comment(tctx, "Testing smbd job spooling\n"); 7761 lpcfg_smbcli_options(tctx->lp_ctx, &options); 7762 7763 status = smb2_connect(tctx, 7764 torture_setting_string(tctx, "host", NULL), 7765 lpcfg_smb_ports(tctx->lp_ctx), 7766 share, 7767 lpcfg_resolve_context(tctx->lp_ctx), 7768 credentials, 7769 &tree, 7770 tctx->ev, 7771 &options, 7772 lpcfg_socket_options(tctx->lp_ctx), 7773 lpcfg_gensec_settings(tctx, tctx->lp_ctx)); 7774 if (!NT_STATUS_IS_OK(status)) { 7775 printf("Failed to connect to SMB2 printer %s - %s\n", 7776 share, nt_errstr(status)); 7777 return false; 7778 } 7779 7780 status = torture_smb2_testfile(tree, "smbd_spooler_job", &job_h); 7781 torture_assert_ntstatus_ok(tctx, status, "smbd spool job create"); 7782 7783 status = smb2_util_write(tree, job_h, "exciting print job data", 0, 7784 sizeof("exciting print job data")); 7785 torture_assert_ntstatus_ok(tctx, status, "smbd spool job write"); 7786 7787 /* check back end spoolss job was created */ 7788 torture_assert(tctx, 7789 test_EnumJobs_args(tctx, b, &t->handle, 1, &count, &info), 7790 "EnumJobs level 1 failed"); 7791 7792 for (i = 0; i < count; i++) { 7793 if (!strcmp(info[i].info1.document_name, "smbd_spooler_job")) { 7794 break; 7795 } 7796 } 7797 torture_assert(tctx, (i != count), "smbd_spooler_job not found"); 7798 7799 status = smb2_util_close(tree, job_h); 7800 torture_assert_ntstatus_ok(tctx, status, "smbd spool job close"); 7801 7802 /* disconnect from printer share */ 7803 talloc_free(mem_ctx); 7804 7805 return true; 7806 } 7807 7808 static bool test_printer_sd(struct torture_context *tctx, 7742 7809 void *private_data) 7743 {7744 struct torture_printer_context *t =7745 (struct torture_printer_context *)talloc_get_type_abort(private_data, struct torture_printer_context);7746 struct dcerpc_pipe *p = t->spoolss_pipe;7747 7748 torture_assert(tctx,7749 test_PrinterInfo_DevMode(tctx, p, &t->handle, t->info2.printername, t->devmode),7750 "failed to test devicemodes");7751 7752 return true;7753 }7754 7755 static bool test_printer_info_winreg(struct torture_context *tctx,7756 void *private_data)7757 {7758 struct torture_printer_context *t =7759 (struct torture_printer_context *)talloc_get_type_abort(private_data, struct torture_printer_context);7760 struct dcerpc_pipe *p = t->spoolss_pipe;7761 7762 torture_assert(tctx,7763 test_PrinterInfo_winreg(tctx, p, &t->handle, t->info2.printername),7764 "failed to test printer info winreg");7765 7766 return true;7767 }7768 7769 static bool test_printer_change_id(struct torture_context *tctx,7770 void *private_data)7771 {7772 struct torture_printer_context *t =7773 (struct torture_printer_context *)talloc_get_type_abort(private_data, struct torture_printer_context);7774 struct dcerpc_pipe *p = t->spoolss_pipe;7775 7776 torture_assert(tctx,7777 test_ChangeID(tctx, p, &t->handle),7778 "failed to test change id");7779 7780 return true;7781 }7782 7783 static bool test_printer_keys(struct torture_context *tctx,7784 void *private_data)7785 7810 { 7786 7811 struct torture_printer_context *t = … … 7790 7815 7791 7816 torture_assert(tctx, 7817 test_PrinterInfo_SD(tctx, b, &t->handle), 7818 "failed to test security descriptors"); 7819 7820 return true; 7821 } 7822 7823 static bool test_printer_dm(struct torture_context *tctx, 7824 void *private_data) 7825 { 7826 struct torture_printer_context *t = 7827 (struct torture_printer_context *)talloc_get_type_abort(private_data, struct torture_printer_context); 7828 struct dcerpc_pipe *p = t->spoolss_pipe; 7829 7830 torture_assert(tctx, 7831 test_PrinterInfo_DevMode(tctx, p, &t->handle, t->info2.printername, t->devmode), 7832 "failed to test devicemodes"); 7833 7834 return true; 7835 } 7836 7837 static bool test_printer_info_winreg(struct torture_context *tctx, 7838 void *private_data) 7839 { 7840 struct torture_printer_context *t = 7841 (struct torture_printer_context *)talloc_get_type_abort(private_data, struct torture_printer_context); 7842 struct dcerpc_pipe *p = t->spoolss_pipe; 7843 7844 torture_assert(tctx, 7845 test_PrinterInfo_winreg(tctx, p, &t->handle, t->info2.printername), 7846 "failed to test printer info winreg"); 7847 7848 return true; 7849 } 7850 7851 static bool test_printer_change_id(struct torture_context *tctx, 7852 void *private_data) 7853 { 7854 struct torture_printer_context *t = 7855 (struct torture_printer_context *)talloc_get_type_abort(private_data, struct torture_printer_context); 7856 struct dcerpc_pipe *p = t->spoolss_pipe; 7857 7858 torture_assert(tctx, 7859 test_ChangeID(tctx, p, &t->handle), 7860 "failed to test change id"); 7861 7862 return true; 7863 } 7864 7865 static bool test_printer_keys(struct torture_context *tctx, 7866 void *private_data) 7867 { 7868 struct torture_printer_context *t = 7869 (struct torture_printer_context *)talloc_get_type_abort(private_data, struct torture_printer_context); 7870 struct dcerpc_pipe *p = t->spoolss_pipe; 7871 struct dcerpc_binding_handle *b = p->binding_handle; 7872 7873 torture_assert(tctx, 7792 7874 test_printer_all_keys(tctx, b, &t->handle), 7793 7875 "failed to test printer keys"); … … 7905 7987 torture_tcase_add_simple_test(tcase, "print_test", test_print_test); 7906 7988 torture_tcase_add_simple_test(tcase, "print_test_extended", test_print_test_extended); 7989 torture_tcase_add_simple_test(tcase, "print_test_smbd", test_print_test_smbd); 7907 7990 torture_tcase_add_simple_test(tcase, "printer_info", test_printer_info); 7908 7991 torture_tcase_add_simple_test(tcase, "sd", test_printer_sd); … … 8923 9006 } 8924 9007 9008 static bool check_printer_driver_file(struct torture_context *tctx, 9009 struct smbcli_state *cli, 9010 struct torture_driver_context *d, 9011 const char *file_name) 9012 { 9013 const char *remote_arch_dir = driver_directory_dir(d->remote.driver_directory); 9014 const char *remote_name = talloc_asprintf(tctx, "%s\\%d\\%s", 9015 remote_arch_dir, 9016 d->info8.version, 9017 file_name); 9018 int fnum; 9019 9020 torture_assert(tctx, (file_name && strlen(file_name) != 0), "invalid filename"); 9021 9022 torture_comment(tctx, "checking for driver file at %s\n", remote_name); 9023 9024 fnum = smbcli_open(cli->tree, remote_name, O_RDONLY, DENY_NONE); 9025 if (fnum == -1) { 9026 return false; 9027 } 9028 9029 torture_assert_ntstatus_ok(tctx, 9030 smbcli_close(cli->tree, fnum), 9031 "failed to close driver file"); 9032 9033 return true; 9034 } 9035 9036 static bool check_printer_driver_files(struct torture_context *tctx, 9037 const char *server_name, 9038 struct torture_driver_context *d, 9039 bool expect_exist) 9040 { 9041 struct smbcli_state *cli; 9042 const char *share_name = driver_directory_share(tctx, d->remote.driver_directory); 9043 int i; 9044 9045 torture_assert(tctx, 9046 connect_printer_driver_share(tctx, server_name, share_name, &cli), 9047 "failed to connect to driver share"); 9048 9049 torture_comment(tctx, "checking %sexistent driver files at \\\\%s\\%s\n", 9050 (expect_exist ? "": "non-"), 9051 server_name, share_name); 9052 9053 if (d->info8.driver_path && d->info8.driver_path[0]) { 9054 torture_assert(tctx, 9055 check_printer_driver_file(tctx, cli, d, d->info8.driver_path) == expect_exist, 9056 "failed driver_path check"); 9057 } 9058 if (d->info8.data_file && d->info8.data_file[0]) { 9059 torture_assert(tctx, 9060 check_printer_driver_file(tctx, cli, d, d->info8.data_file) == expect_exist, 9061 "failed data_file check"); 9062 } 9063 if (d->info8.config_file && d->info8.config_file[0]) { 9064 torture_assert(tctx, 9065 check_printer_driver_file(tctx, cli, d, d->info8.config_file) == expect_exist, 9066 "failed config_file check"); 9067 } 9068 if (d->info8.help_file && d->info8.help_file[0]) { 9069 torture_assert(tctx, 9070 check_printer_driver_file(tctx, cli, d, d->info8.help_file) == expect_exist, 9071 "failed help_file check"); 9072 } 9073 if (d->info8.dependent_files) { 9074 for (i=0; d->info8.dependent_files->string && d->info8.dependent_files->string[i] != NULL; i++) { 9075 torture_assert(tctx, 9076 check_printer_driver_file(tctx, cli, d, d->info8.dependent_files->string[i]) == expect_exist, 9077 "failed dependent_files check"); 9078 } 9079 } 9080 9081 talloc_free(cli); 9082 9083 return true; 9084 } 9085 8925 9086 static bool remove_printer_driver_file(struct torture_context *tctx, 8926 9087 struct smbcli_state *cli, … … 9207 9368 struct torture_driver_context *d; 9208 9369 9370 if (!torture_setting_bool(tctx, "samba3", false)) { 9371 torture_skip(tctx, "skipping adobe test which only works against samba3"); 9372 } 9373 9209 9374 d = talloc_zero(tctx, struct torture_driver_context); 9210 9375 … … 9372 9537 } 9373 9538 9539 static bool test_del_driver_all_files(struct torture_context *tctx, 9540 struct dcerpc_pipe *p) 9541 { 9542 struct torture_driver_context *d; 9543 struct spoolss_StringArray *a; 9544 uint32_t add_flags = APD_COPY_NEW_FILES; 9545 uint32_t delete_flags = DPD_DELETE_ALL_FILES; 9546 struct dcerpc_binding_handle *b = p->binding_handle; 9547 const char *server_name_slash = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); 9548 9549 d = talloc_zero(tctx, struct torture_driver_context); 9550 9551 d->ex = true; 9552 d->info8.version = SPOOLSS_DRIVER_VERSION_200X; 9553 d->info8.driver_name = TORTURE_DRIVER_DELETER; 9554 d->info8.architecture = NULL; 9555 d->info8.driver_path = talloc_strdup(d, "pscript5.dll"); 9556 d->info8.data_file = talloc_strdup(d, "cups6.ppd"); 9557 d->info8.config_file = talloc_strdup(d, "cupsui6.dll"); 9558 d->info8.help_file = talloc_strdup(d, "pscript.hlp"); 9559 d->local.environment = talloc_strdup(d, SPOOLSS_ARCHITECTURE_x64); 9560 d->local.driver_directory = talloc_strdup(d, "/usr/share/cups/drivers/x64"); 9561 9562 a = talloc_zero(d, struct spoolss_StringArray); 9563 a->string = talloc_zero_array(a, const char *, 3); 9564 a->string[0] = talloc_strdup(a->string, "cups6.inf"); 9565 a->string[1] = talloc_strdup(a->string, "cups6.ini"); 9566 9567 d->info8.dependent_files = a; 9568 d->info8.architecture = d->local.environment; 9569 9570 torture_assert(tctx, 9571 fillup_printserver_info(tctx, p, d), 9572 "failed to fillup printserver info"); 9573 9574 if (!directory_exist(d->local.driver_directory)) { 9575 torture_skip(tctx, "Skipping Printer Driver test as no local driver is available"); 9576 } 9577 9578 torture_assert(tctx, 9579 upload_printer_driver(tctx, dcerpc_server_name(p), d), 9580 "failed to upload printer driver"); 9581 9582 torture_assert(tctx, 9583 test_AddPrinterDriver_args_level_3(tctx, b, server_name_slash, &d->info8, add_flags, true, NULL), 9584 "failed to add driver"); 9585 9586 torture_assert(tctx, 9587 test_DeletePrinterDriverEx(tctx, b, server_name_slash, 9588 d->info8.driver_name, 9589 d->local.environment, 9590 delete_flags, 9591 d->info8.version), 9592 "failed to delete driver"); 9593 9594 torture_assert(tctx, 9595 check_printer_driver_files(tctx, dcerpc_server_name(p), d, false), 9596 "printer driver file check failed"); 9597 9598 talloc_free(d); 9599 return true; 9600 } 9601 9602 static bool test_del_driver_unused_files(struct torture_context *tctx, 9603 struct dcerpc_pipe *p) 9604 { 9605 struct torture_driver_context *d1; 9606 struct torture_driver_context *d2; 9607 uint32_t add_flags = APD_COPY_NEW_FILES; 9608 struct dcerpc_binding_handle *b = p->binding_handle; 9609 const char *server_name_slash = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); 9610 9611 d1 = talloc_zero(tctx, struct torture_driver_context); 9612 d1->ex = true; 9613 d1->info8.version = SPOOLSS_DRIVER_VERSION_200X; 9614 d1->info8.driver_name = TORTURE_DRIVER_DELETER; 9615 d1->info8.architecture = NULL; 9616 d1->info8.driver_path = talloc_strdup(d1, "pscript5.dll"); 9617 d1->info8.data_file = talloc_strdup(d1, "cups6.ppd"); 9618 d1->info8.config_file = talloc_strdup(d1, "cupsui6.dll"); 9619 d1->info8.help_file = talloc_strdup(d1, "pscript.hlp"); 9620 d1->local.environment = talloc_strdup(d1, SPOOLSS_ARCHITECTURE_x64); 9621 d1->local.driver_directory = talloc_strdup(d1, "/usr/share/cups/drivers/x64"); 9622 d1->info8.architecture = d1->local.environment; 9623 9624 d2 = talloc_zero(tctx, struct torture_driver_context); 9625 d2->ex = true; 9626 d2->info8.version = SPOOLSS_DRIVER_VERSION_200X; 9627 d2->info8.driver_name = TORTURE_DRIVER_DELETERIN; 9628 d2->info8.architecture = NULL; 9629 d2->info8.driver_path = talloc_strdup(d2, "pscript5.dll"); /* overlapping */ 9630 d2->info8.data_file = talloc_strdup(d2, "cupsps6.dll"); 9631 d2->info8.config_file = talloc_strdup(d2, "cups6.ini"); 9632 d2->info8.help_file = talloc_strdup(d2, "pscript.hlp"); /* overlapping */ 9633 d2->local.environment = talloc_strdup(d2, SPOOLSS_ARCHITECTURE_x64); 9634 d2->local.driver_directory = talloc_strdup(d2, "/usr/share/cups/drivers/x64"); 9635 d2->info8.architecture = d2->local.environment; 9636 9637 torture_assert(tctx, 9638 fillup_printserver_info(tctx, p, d1), 9639 "failed to fillup printserver info"); 9640 torture_assert(tctx, 9641 fillup_printserver_info(tctx, p, d2), 9642 "failed to fillup printserver info"); 9643 9644 if (!directory_exist(d1->local.driver_directory)) { 9645 torture_skip(tctx, "Skipping Printer Driver test as no local driver is available"); 9646 } 9647 9648 torture_assert(tctx, 9649 upload_printer_driver(tctx, dcerpc_server_name(p), d1), 9650 "failed to upload printer driver"); 9651 torture_assert(tctx, 9652 test_AddPrinterDriver_args_level_3(tctx, b, server_name_slash, &d1->info8, add_flags, true, NULL), 9653 "failed to add driver"); 9654 9655 torture_assert(tctx, 9656 upload_printer_driver(tctx, dcerpc_server_name(p), d2), 9657 "failed to upload printer driver"); 9658 torture_assert(tctx, 9659 test_AddPrinterDriver_args_level_3(tctx, b, server_name_slash, &d2->info8, add_flags, true, NULL), 9660 "failed to add driver"); 9661 9662 /* some files are in use by a separate driver, should fail */ 9663 torture_assert(tctx, 9664 test_DeletePrinterDriverEx_exp(tctx, b, server_name_slash, 9665 d1->info8.driver_name, 9666 d1->local.environment, 9667 DPD_DELETE_ALL_FILES, 9668 d1->info8.version, 9669 WERR_PRINTER_DRIVER_IN_USE), 9670 "invalid delete driver response"); 9671 9672 /* should only delete files not in use by other driver */ 9673 torture_assert(tctx, 9674 test_DeletePrinterDriverEx_exp(tctx, b, server_name_slash, 9675 d1->info8.driver_name, 9676 d1->local.environment, 9677 DPD_DELETE_UNUSED_FILES, 9678 d1->info8.version, 9679 WERR_OK), 9680 "failed to delete driver (unused files)"); 9681 9682 /* check non-overlapping were deleted */ 9683 d1->info8.driver_path = NULL; 9684 d1->info8.help_file = NULL; 9685 torture_assert(tctx, 9686 check_printer_driver_files(tctx, dcerpc_server_name(p), d1, false), 9687 "printer driver file check failed"); 9688 /* d2 files should be uneffected */ 9689 torture_assert(tctx, 9690 check_printer_driver_files(tctx, dcerpc_server_name(p), d2, true), 9691 "printer driver file check failed"); 9692 9693 torture_assert(tctx, 9694 test_DeletePrinterDriverEx_exp(tctx, b, server_name_slash, 9695 d2->info8.driver_name, 9696 d2->local.environment, 9697 DPD_DELETE_ALL_FILES, 9698 d2->info8.version, 9699 WERR_OK), 9700 "failed to delete driver"); 9701 9702 torture_assert(tctx, 9703 check_printer_driver_files(tctx, dcerpc_server_name(p), d2, false), 9704 "printer driver file check failed"); 9705 9706 talloc_free(d1); 9707 talloc_free(d2); 9708 return true; 9709 } 9710 9374 9711 struct torture_suite *torture_rpc_spoolss_driver(TALLOC_CTX *mem_ctx) 9375 9712 { … … 9392 9729 torture_rpc_tcase_add_test(tcase, "multiple_drivers", test_multiple_drivers); 9393 9730 9731 torture_rpc_tcase_add_test(tcase, "del_driver_all_files", test_del_driver_all_files); 9732 9733 torture_rpc_tcase_add_test(tcase, "del_driver_unused_files", test_del_driver_unused_files); 9734 9394 9735 return suite; 9395 9736 }
Note:
See TracChangeset
for help on using the changeset viewer.