The branch, master has been updated via b5d4726... s4-smbtorture: test wbcResolveWinsByName/wbcResolveWinsByIP in WINBIND-WBCLIENT testsuite. via e16e75a... s4-smbtorture: add test for wbcPingDc to WINBIND-WBCLIENT testsuite. via 5dfec4f... s4-smbtorture: split spoolss_RemoteFindFirstPrinterChangeNotifyEx test into smaller parts. via 818fb00... testprogs: print all driver info levels in spoolss testsuite. from 4eb1523... s3-libsmbclient: Add smbc_setOptionUseCCache()
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master - Log ----------------------------------------------------------------- commit b5d47263162856c423f484df44914271b76b1e53 Author: Günther Deschner <g...@samba.org> Date: Fri Jan 22 16:27:39 2010 +0100 s4-smbtorture: test wbcResolveWinsByName/wbcResolveWinsByIP in WINBIND-WBCLIENT testsuite. Guenther commit e16e75a4f0e8887b1cce35384d1157743270439e Author: Günther Deschner <g...@samba.org> Date: Fri Jan 22 15:06:50 2010 +0100 s4-smbtorture: add test for wbcPingDc to WINBIND-WBCLIENT testsuite. Volker, please check, you know best how this interface is designed :-) Guenther commit 5dfec4f36b90f0343e6ef4d457f67dccbfee8480 Author: Günther Deschner <g...@samba.org> Date: Tue Jan 19 22:18:24 2010 +0100 s4-smbtorture: split spoolss_RemoteFindFirstPrinterChangeNotifyEx test into smaller parts. Guenther commit 818fb00381c4f89d4375f2f41f6fcbb42999d871 Author: Günther Deschner <g...@samba.org> Date: Wed Jan 20 00:44:16 2010 +0100 testprogs: print all driver info levels in spoolss testsuite. Guenther ----------------------------------------------------------------------- Summary of changes: nsswitch/libwbclient/tests/wbclient.c | 48 ++++++++- source4/torture/rpc/spoolss_notify.c | 181 ++++++++++++++++++------------ testprogs/win32/spoolss/printlib.c | 161 ++++++++++++++++++++++++++ testprogs/win32/spoolss/printlib_proto.h | 3 + testprogs/win32/spoolss/spoolss.c | 8 ++ 5 files changed, 327 insertions(+), 74 deletions(-) Changeset truncated at 500 lines: diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c index 23fad63..9e4c348 100644 --- a/nsswitch/libwbclient/tests/wbclient.c +++ b/nsswitch/libwbclient/tests/wbclient.c @@ -1,7 +1,7 @@ /* Unix SMB/CIFS implementation. SMB torture tester - Copyright (C) Guenther Deschner 2009 + Copyright (C) Guenther Deschner 2009-2010 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -43,6 +43,16 @@ static bool test_wbc_ping(struct torture_context *tctx) return true; } +static bool test_wbc_pingdc(struct torture_context *tctx) +{ + torture_assert_wbc_equal(tctx, wbcPingDc("random_string", NULL), WBC_ERR_NOT_IMPLEMENTED, + "wbcPingDc failed"); + torture_assert_wbc_ok(tctx, wbcPingDc(NULL, NULL), + "wbcPingDc failed"); + + return true; +} + static bool test_wbc_library_details(struct torture_context *tctx) { struct wbcLibraryDetails *details; @@ -304,12 +314,46 @@ static bool test_wbc_lookupdcex(struct torture_context *tctx) return true; } +static bool test_wbc_resolve_winsbyname(struct torture_context *tctx) +{ + const char *name; + char *ip; + wbcErr ret; + + name = torture_setting_string(tctx, "host", NULL); + + ret = wbcResolveWinsByName(name, &ip); + + if (is_ipaddress(name)) { + torture_assert_wbc_equal(tctx, ret, WBC_ERR_DOMAIN_NOT_FOUND, "wbcResolveWinsByName failed"); + } else { + torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByName failed"); + } + + return true; +} + +static bool test_wbc_resolve_winsbyip(struct torture_context *tctx) +{ + const char *ip; + char *name; + wbcErr ret; + + ip = torture_setting_string(tctx, "host", NULL); + + ret = wbcResolveWinsByIP(ip, &name); + + torture_assert_wbc_ok(tctx, ret, "wbcResolveWinsByIP failed"); + + return true; +} struct torture_suite *torture_wbclient(void) { struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "WBCLIENT"); torture_suite_add_simple_test(suite, "wbcPing", test_wbc_ping); + torture_suite_add_simple_test(suite, "wbcPingDc", test_wbc_pingdc); torture_suite_add_simple_test(suite, "wbcLibraryDetails", test_wbc_library_details); torture_suite_add_simple_test(suite, "wbcInterfaceDetails", test_wbc_interface_details); torture_suite_add_simple_test(suite, "wbcSidTypeString", test_wbc_sidtypestring); @@ -321,6 +365,8 @@ struct torture_suite *torture_wbclient(void) torture_suite_add_simple_test(suite, "wbcListTrusts", test_wbc_trusts); torture_suite_add_simple_test(suite, "wbcLookupDomainController", test_wbc_lookupdc); torture_suite_add_simple_test(suite, "wbcLookupDomainControllerEx", test_wbc_lookupdcex); + torture_suite_add_simple_test(suite, "wbcResolveWinsByName", test_wbc_resolve_winsbyname); + torture_suite_add_simple_test(suite, "wbcResolveWinsByIP", test_wbc_resolve_winsbyip); return suite; } diff --git a/source4/torture/rpc/spoolss_notify.c b/source4/torture/rpc/spoolss_notify.c index bce85ca..e5e52d6 100644 --- a/source4/torture/rpc/spoolss_notify.c +++ b/source4/torture/rpc/spoolss_notify.c @@ -3,6 +3,7 @@ test suite for spoolss rpc notify operations Copyright (C) Jelmer Vernooij 2007 + Copyright (C) Guenther Deschner 2010 This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -219,45 +220,100 @@ static NTSTATUS spoolss__op_init_server(struct dcesrv_context *dce_ctx, const st return NT_STATUS_OK; } -static bool test_RFFPCNEx(struct torture_context *tctx, - struct dcerpc_pipe *p) +static bool test_OpenPrinter(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) +{ + struct spoolss_OpenPrinter r; + + ZERO_STRUCT(r); + + r.in.printername = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); + r.in.datatype = NULL; + r.in.devmode_ctr.devmode= NULL; + r.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; + r.out.handle = handle; + + torture_comment(tctx, "Testing OpenPrinter(%s)\n", r.in.printername); + + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_OpenPrinter(p, tctx, &r), "OpenPrinter failed"); + torture_assert_werr_ok(tctx, r.out.result, "OpenPrinter failed"); + + return true; +} + +static bool test_RemoteFindFirstPrinterChangeNotifyEx(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle, + const char *address) { - struct spoolss_OpenPrinter q; struct spoolss_RemoteFindFirstPrinterChangeNotifyEx r; - struct dcesrv_endpoint_server ep_server; - NTSTATUS status; - struct dcesrv_context *dce_ctx; - const char *endpoints[] = { "spoolss", NULL }; - struct dcesrv_endpoint *e; struct spoolss_NotifyOption t1; - struct spoolss_ClosePrinter cp; - struct received_packet *rp; - struct policy_handle handle; - const char *address; - struct interface *ifaces; + torture_comment(tctx, "Testing RemoteFindFirstPrinterChangeNotifyEx\n"); - received_packets = NULL; + t1.version = 2; + t1.flags = 0; + t1.count = 2; + t1.types = talloc_zero_array(tctx, struct spoolss_NotifyOptionType, 2); + t1.types[0].type = PRINTER_NOTIFY_TYPE; + t1.types[0].count = 1; + t1.types[0].fields = talloc_array(t1.types, union spoolss_Field, 1); + t1.types[0].fields[0].field = PRINTER_NOTIFY_FIELD_SERVER_NAME; - ntvfs_init(tctx->lp_ctx); + t1.types[1].type = JOB_NOTIFY_TYPE; + t1.types[1].count = 1; + t1.types[1].fields = talloc_array(t1.types, union spoolss_Field, 1); + t1.types[1].fields[0].field = PRINTER_NOTIFY_FIELD_PRINTER_NAME; + + r.in.flags = 0; + r.in.local_machine = talloc_asprintf(tctx, "\\\\%s", address); + r.in.options = 0; + r.in.printer_local = 123; + r.in.notify_options = &t1; + r.in.handle = handle; - ZERO_STRUCT(q); + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx(p, tctx, &r), + "RemoteFindFirstPrinterChangeNotifyEx failed"); + torture_assert_werr_ok(tctx, r.out.result, + "error return code for RemoteFindFirstPrinterChangeNotifyEx"); - q.in.printername = talloc_asprintf(tctx, "\\\\%s", dcerpc_server_name(p)); - q.in.datatype = NULL; - q.in.devmode_ctr.devmode= NULL; - q.in.access_mask = SEC_FLAG_MAXIMUM_ALLOWED; - q.out.handle = &handle; + return true; +} - torture_comment(tctx, "Testing OpenPrinter(%s)\n", q.in.printername); +static bool test_ClosePrinter(struct torture_context *tctx, + struct dcerpc_pipe *p, + struct policy_handle *handle) +{ + struct spoolss_ClosePrinter r; - status = dcerpc_spoolss_OpenPrinter(p, tctx, &q); + r.in.handle = handle; + r.out.handle = handle; - torture_assert_ntstatus_ok(tctx, status, "OpenPrinter failed"); + torture_comment(tctx, "Testing ClosePrinter\n"); - torture_assert_werr_ok(tctx, q.out.result, "OpenPrinter failed"); + torture_assert_ntstatus_ok(tctx, dcerpc_spoolss_ClosePrinter(p, tctx, &r), + "ClosePrinter failed"); + torture_assert_werr_ok(tctx, r.out.result, + "ClosePrinter failed"); - /* Start DCE/RPC server */ + return true; +} + +static bool test_start_dcerpc_server(struct torture_context *tctx, + struct tevent_context *event_ctx, + struct dcesrv_context **dce_ctx_p, + const char **address_p) +{ + struct dcesrv_endpoint_server ep_server; + NTSTATUS status; + struct dcesrv_context *dce_ctx; + const char *endpoints[] = { "spoolss", NULL }; + struct dcesrv_endpoint *e; + const char *address; + struct interface *ifaces; + + ntvfs_init(tctx->lp_ctx); /* fill in our name */ ep_server.name = "spoolss"; @@ -275,8 +331,10 @@ static bool test_RFFPCNEx(struct torture_context *tctx, load_interfaces(tctx, lp_interfaces(tctx->lp_ctx), &ifaces); address = iface_n_ip(ifaces, 0); + torture_comment(tctx, "Listening for callbacks on %s\n", address); - status = smbsrv_add_socket(p->conn->event_ctx, tctx->lp_ctx, &single_ops, address); + + status = smbsrv_add_socket(event_ctx, tctx->lp_ctx, &single_ops, address); torture_assert_ntstatus_ok(tctx, status, "starting smb server"); status = dcesrv_init_context(tctx, tctx->lp_ctx, endpoints, &dce_ctx); @@ -290,56 +348,33 @@ static bool test_RFFPCNEx(struct torture_context *tctx, "unable listen on dcerpc endpoint server"); } - r.in.flags = 0; - r.in.local_machine = talloc_asprintf(tctx, "\\\\%s", address); - r.in.options = 0; - r.in.printer_local = 123; - t1.version = 2; - t1.flags = 0; - t1.count = 2; - t1.types = talloc_zero_array(tctx, struct spoolss_NotifyOptionType, 2); - t1.types[0].type = PRINTER_NOTIFY_TYPE; - t1.types[0].count = 1; - t1.types[0].fields = talloc_array(t1.types, union spoolss_Field, 1); - t1.types[0].fields[0].field = PRINTER_NOTIFY_FIELD_SERVER_NAME; - - t1.types[1].type = JOB_NOTIFY_TYPE; - t1.types[1].count = 1; - t1.types[1].fields = talloc_array(t1.types, union spoolss_Field, 1); - t1.types[1].fields[0].field = PRINTER_NOTIFY_FIELD_PRINTER_NAME; - - r.in.notify_options = &t1; - r.in.handle = &handle; - - status = dcerpc_spoolss_RemoteFindFirstPrinterChangeNotifyEx(p, tctx, &r); - - torture_assert_ntstatus_ok(tctx, status, "FFPCNEx failed"); - - torture_assert_werr_ok(tctx, r.out.result, "error return code for FFPCNEx"); - - cp.in.handle = &handle; - cp.out.handle = &handle; - - torture_comment(tctx, "Testing ClosePrinter\n"); + *dce_ctx_p = dce_ctx; + *address_p = address; - status = dcerpc_spoolss_ClosePrinter(p, tctx, &cp); - torture_assert_ntstatus_ok(tctx, status, "ClosePrinter failed"); + return true; +} - /* We should've had an incoming packet 58 (ReplyOpenPrinter) or 60 - * (ReplyClosePrinter) */ +static bool test_RFFPCNEx(struct torture_context *tctx, + struct dcerpc_pipe *p) +{ + struct dcesrv_context *dce_ctx; + struct policy_handle handle; + const char *address; - torture_assert(tctx, received_packets != NULL, "no packets received"); + received_packets = NULL; - for (rp = received_packets; rp; rp = rp->next) { - switch (rp->opnum) { - case 58: - case 60: - continue; - default: - torture_fail(tctx, - talloc_asprintf(tctx, "unexpected packet opnum %d received", rp->opnum)); - } - } + /* Start DCE/RPC server */ + torture_assert(tctx, test_start_dcerpc_server(tctx, p->conn->event_ctx, &dce_ctx, &address), ""); + + torture_assert(tctx, test_OpenPrinter(tctx, p, &handle), ""); + torture_assert(tctx, test_RemoteFindFirstPrinterChangeNotifyEx(tctx, p, &handle, address), ""); + torture_assert(tctx, received_packets, "no packets received"); + torture_assert_int_equal(tctx, received_packets->opnum, NDR_SPOOLSS_REPLYOPENPRINTER, + "no ReplyOpenPrinter packet after RemoteFindFirstPrinterChangeNotifyEx"); + torture_assert(tctx, test_ClosePrinter(tctx, p, &handle), ""); + torture_assert(tctx, received_packets, "no packets received"); + torture_assert_int_equal(tctx, received_packets->opnum, NDR_SPOOLSS_REPLYCLOSEPRINTER, + "no ReplyClosePrinter packet after ClosePrinter"); /* Shut down DCE/RPC server */ talloc_free(dce_ctx); diff --git a/testprogs/win32/spoolss/printlib.c b/testprogs/win32/spoolss/printlib.c index e458e14..8480e30 100644 --- a/testprogs/win32/spoolss/printlib.c +++ b/testprogs/win32/spoolss/printlib.c @@ -532,6 +532,21 @@ void print_driver_info_4(PDRIVER_INFO_4 info) return; } +void print_driver_info_5(PDRIVER_INFO_5 info) +{ + printf("\tDriver Name\t= %s\n", info->pName); + printf("\tEnvironment\t= %s\n", info->pEnvironment); + printf("\tVersion\t\t= %d\n", info->cVersion); + printf("\tDriver Path\t= %s\n", info->pDriverPath); + printf("\tData File\t= %s\n", info->pDataFile); + printf("\tConfig File\t= %s\n", info->pConfigFile); + printf("\tDriver Attributes\t= %d\n", info->dwDriverAttributes); + printf("\tConfig Version\t= %d\n", info->dwConfigVersion); + printf("\tDriver Version\t= %d\n", info->dwDriverVersion); + + return; +} + void print_driver_info_6(PDRIVER_INFO_6 info) { char *ptr = NULL; @@ -581,6 +596,152 @@ void print_driver_info_6(PDRIVER_INFO_6 info) return; } +static void print_multi_sz(LPSTR multisz) +{ + char *ptr = NULL; + + ptr = (char *)multisz; + + if (!ptr) { + printf("(null)\n"); + return; + } + + while (*ptr != '\0') { + printf("%s\n", ptr); + for (; *ptr != '\0'; ptr++) { + /* printf("%s\n", ptr); */ + ; + } + ptr++; + } +} + +void print_driver_info_8(PDRIVER_INFO_8 info) +{ + printf("\tDriver Name\t= %s\n", info->pName); + printf("\tEnvironment\t= %s\n", info->pEnvironment); + printf("\tVersion\t\t= %d\n", info->cVersion); + printf("\tDriver Path\t= %s\n", info->pDriverPath); + printf("\tData File\t= %s\n", info->pDataFile); + printf("\tConfig File\t= %s\n", info->pConfigFile); + printf("\tHelp Path\t= %s\n", info->pHelpFile); + printf("\tMonitor Name\t= %s\n", info->pMonitorName); + printf("\tData Type\t= %s\n", info->pDefaultDataType); + printf("\tPrevious Names\t=\n"); + print_multi_sz(info->pszzPreviousNames); + printf("\tDependent Files\t=\n"); + print_multi_sz(info->pDependentFiles); + printf("\tDriver Date\t= %d\n", info->ftDriverDate); + printf("\tDriver Version\t= %d\n", info->dwlDriverVersion); + printf("\tManufacture Name = %s\n", info->pszMfgName); + printf("\tOEM URL\t\t= %s\n", info->pszOEMUrl); + printf("\tHardware ID\t= %s\n", info->pszHardwareID); + printf("\tProvider\t= %s\n", info->pszProvider); + printf("\tPrint Processor\t= %s\n", info->pszPrintProcessor); + printf("\tVendor Setup\t= %s\n", info->pszVendorSetup); + printf("\tColor Profiles\t=\n"); + print_multi_sz(info->pszzColorProfiles); + printf("\tInf Path\t= %s\n", info->pszInfPath); + printf("\tPrinter Driver Attributes = %d\n", info->dwPrinterDriverAttributes); + printf("\tCore Driver Dependencies\t=\n"); + print_multi_sz(info->pszzCoreDriverDependencies); + printf("\tMin Inbox Driver VerDate\t= %d\n", info->ftMinInboxDriverVerDate); + printf("\tMin Inbox Driver VerVersion\t= %d\n", info->dwlMinInboxDriverVerVersion); + return; +} + +void print_driver_info_bylevel(DWORD level, LPBYTE buffer, DWORD count) +{ + DWORD i; + PDRIVER_INFO_1 buffer1 = NULL; + PDRIVER_INFO_2 buffer2 = NULL; + PDRIVER_INFO_3 buffer3 = NULL; + PDRIVER_INFO_4 buffer4 = NULL; + PDRIVER_INFO_5 buffer5 = NULL; + PDRIVER_INFO_6 buffer6 = NULL; + PDRIVER_INFO_8 buffer8 = NULL; + + if (!buffer) { + return; + } + + switch (level) { + case 1: + buffer1 = (PDRIVER_INFO_1)buffer; + break; + case 2: + buffer2 = (PDRIVER_INFO_2)buffer; + break; + case 3: + buffer3 = (PDRIVER_INFO_3)buffer; + break; + case 4: + buffer4 = (PDRIVER_INFO_4)buffer; + break; + case 5: + buffer5 = (PDRIVER_INFO_5)buffer; + break; + case 6: + buffer6 = (PDRIVER_INFO_6)buffer; + break; + case 8: + buffer8 = (PDRIVER_INFO_8)buffer; + break; + default: + break; + } + + printf("Driver Info Level %d:\n", level); + + switch (level) { + case 1: + for (i=0; i<count; i++) { + print_driver_info_1(&buffer1[i]); + printf("\n"); + } + break; + case 2: + for (i=0; i<count; i++) { + print_driver_info_2(&buffer2[i]); + printf("\n"); + } + break; + case 3: + for (i=0; i<count; i++) { + print_driver_info_3(&buffer3[i]); + printf("\n"); + } + break; + case 4: + for (i=0; i<count; i++) { + print_driver_info_4(&buffer4[i]); + printf("\n"); + } + break; + case 5: + for (i=0; i<count; i++) { + print_driver_info_5(&buffer5[i]); + printf("\n"); + } + break; + case 6: + for (i=0; i<count; i++) { + print_driver_info_6(&buffer6[i]); + printf("\n"); + } + break; + case 8: + for (i=0; i<count; i++) { + print_driver_info_8(&buffer8[i]); + printf("\n"); + } + break; + default: + break; + } +} + void print_doc_info_1(PDOC_INFO_1 info) { printf("\tDocument Name\t= %s\n", info->pDocName); diff --git a/testprogs/win32/spoolss/printlib_proto.h b/testprogs/win32/spoolss/printlib_proto.h index 44cadbc..21f003c 100644 --- a/testprogs/win32/spoolss/printlib_proto.h +++ b/testprogs/win32/spoolss/printlib_proto.h -- Samba Shared Repository