From 78b985ac3e38bbbb42545a722096bf53ee2821eb Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 26 Apr 2010 11:56:00 -0400 Subject: s3-spoolss: Convert do_drv_upgrade_printer() to winreg functions. Signed-off-by: Jim McDonough --- source3/rpc_server/srv_spoolss_nt.c | 71 +++++++++++++++++++++++++------------ 1 file changed, 48 insertions(+), 23 deletions(-) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c index 05bbdd9a88..1a699c2503 100644 --- a/source3/rpc_server/srv_spoolss_nt.c +++ b/source3/rpc_server/srv_spoolss_nt.c @@ -1283,47 +1283,72 @@ void do_drv_upgrade_printer(struct messaging_context *msg, struct server_id server_id, DATA_BLOB *data) { - fstring drivername; + TALLOC_CTX *tmp_ctx; + struct auth_serversupplied_info *server_info = NULL; + struct spoolss_PrinterInfo2 *pinfo2; + NTSTATUS status; + WERROR result; + const char *drivername; int snum; int n_services = lp_numservices(); size_t len; + tmp_ctx = talloc_new(NULL); + if (!tmp_ctx) return; + + status = make_server_info_system(tmp_ctx, &server_info); + if (!NT_STATUS_IS_OK(status)) { + DEBUG(0, ("do_drv_upgrade_printer: " + "Could not create system server_info\n")); + goto done; + } + len = MIN(data->length,sizeof(drivername)-1); - strncpy(drivername, (const char *)data->data, len); + drivername = talloc_strndup(tmp_ctx, (const char *)data->data, len); + if (!drivername) { + DEBUG(0, ("do_drv_upgrade_printer: Out of memoery ?!\n")); + goto done; + } - DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername )); + DEBUG(10, ("do_drv_upgrade_printer: " + "Got message for new driver [%s]\n", drivername)); /* Iterate the printer list */ - for (snum=0; snuminfo_2 && !strcmp(drivername, printer->info_2->drivername)) - { - DEBUG(6,("Updating printer [%s]\n", printer->info_2->printername)); + if (!W_ERROR_IS_OK(result)) { + continue; + } + + if (strcmp(drivername, pinfo2->drivername) != 0) { + continue; + } - /* all we care about currently is the change_id */ + DEBUG(6,("Updating printer [%s]\n", pinfo2->printername)); - result = mod_a_printer(printer, 2); - if (!W_ERROR_IS_OK(result)) { - DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n", - win_errstr(result))); - } - } + /* all we care about currently is the change_id */ + result = winreg_printer_update_changeid(tmp_ctx, + server_info, + pinfo2->printername); - free_a_printer(&printer, 2); + if (!W_ERROR_IS_OK(result)) { + DEBUG(3, ("do_drv_upgrade_printer: " + "Failed to update changeid [%s]\n", + win_errstr(result))); } } /* all done */ +done: + talloc_free(tmp_ctx); } /******************************************************************** -- cgit