From d5bd3e1e4211b311eb20f127bfa4749c400699ef Mon Sep 17 00:00:00 2001 From: Garming Sam Date: Tue, 18 Nov 2014 12:41:30 +1300 Subject: [PATCH] spoolss: handle SetPrinter for info level 4 BUG: https://bugzilla.samba.org/show_bug.cgi?id=10770 Signed-off-by: Garming Sam --- source3/rpc_server/spoolss/srv_spoolss_nt.c | 64 +++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/source3/rpc_server/spoolss/srv_spoolss_nt.c b/source3/rpc_server/spoolss/srv_spoolss_nt.c index 115af2d..923e7e3 100644 --- a/source3/rpc_server/spoolss/srv_spoolss_nt.c +++ b/source3/rpc_server/spoolss/srv_spoolss_nt.c @@ -6993,6 +6993,70 @@ WERROR _spoolss_SetPrinter(struct pipes_struct *p, case 3: return update_printer_sec(r->in.handle, p, r->in.secdesc_ctr); + case 4: { + struct spoolss_PrinterInfo2 *old_printer; + struct spoolss_SetPrinterInfo2 *set_old_printer; + struct spoolss_SetPrinterInfoCtr *info_ctr; + struct dcerpc_binding_handle *b; + int snum; + TALLOC_CTX *tmp_ctx; + + tmp_ctx = talloc_new(p->mem_ctx); + if (tmp_ctx == NULL) { + return WERR_NOMEM; + } + + if (!get_printer_snum(p, r->in.handle, &snum, NULL)) { + TALLOC_FREE(tmp_ctx); + return WERR_BADFID; + } + + result = winreg_printer_binding_handle(tmp_ctx, + get_session_info_system(), + p->msg_ctx, + &b); + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(tmp_ctx); + return result; + } + + result = winreg_get_printer(tmp_ctx, b, + lp_const_servicename(snum), + &old_printer); + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(tmp_ctx); + return WERR_BADFID; + } + + old_printer->servername = talloc_strdup(tmp_ctx, r->in.info_ctr->info.info4->servername); + old_printer->printername = talloc_strdup(tmp_ctx, r->in.info_ctr->info.info4->printername); + old_printer->attributes = r->in.info_ctr->info.info4->attributes; + + set_old_printer = talloc_zero(tmp_ctx, struct spoolss_SetPrinterInfo2); + spoolss_printerinfo2_to_setprinterinfo2(old_printer, set_old_printer); + + info_ctr = talloc_zero(tmp_ctx, struct spoolss_SetPrinterInfoCtr); + info_ctr->level = 2; + + info_ctr->info.info2 = set_old_printer; + + result = update_printer(p, r->in.handle, + info_ctr, + r->in.devmode_ctr->devmode); + + if (!W_ERROR_IS_OK(result)) { + TALLOC_FREE(tmp_ctx); + return result; + } + + if (r->in.secdesc_ctr->sd) { + result = update_printer_sec(r->in.handle, p, + r->in.secdesc_ctr); + } + + TALLOC_FREE(tmp_ctx); + return result; + } case 7: return publish_or_unpublish_printer(p, r->in.handle, r->in.info_ctr->info.info7); -- 1.9.1