summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2010-04-26 11:56:00 -0400
committerSimo Sorce <idra@samba.org>2010-07-27 10:27:09 -0400
commit78b985ac3e38bbbb42545a722096bf53ee2821eb (patch)
treee41c98b8b5831e30fb9bca3838ef36d77a3ee6b5 /source3/rpc_server
parent375bdfc7f89d8941c006bc2afb058176d81027e3 (diff)
downloadsamba-78b985ac3e38bbbb42545a722096bf53ee2821eb.tar.gz
samba-78b985ac3e38bbbb42545a722096bf53ee2821eb.tar.bz2
samba-78b985ac3e38bbbb42545a722096bf53ee2821eb.zip
s3-spoolss: Convert do_drv_upgrade_printer() to winreg functions.
Signed-off-by: Jim McDonough <jmcd@samba.org>
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c71
1 files changed, 48 insertions, 23 deletions
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; snum<n_services; snum++)
- {
- if (lp_snum_ok(snum) && lp_print_ok(snum) )
- {
- WERROR result;
- NT_PRINTER_INFO_LEVEL *printer = NULL;
+ for (snum = 0; snum < n_services; snum++) {
+ if (!lp_snum_ok(snum) || !lp_print_ok(snum)) {
+ continue;
+ }
- result = get_a_printer(NULL, &printer, 2, lp_const_servicename(snum));
- if (!W_ERROR_IS_OK(result))
- continue;
+ result = winreg_get_printer(tmp_ctx, server_info, NULL,
+ lp_const_servicename(snum),
+ &pinfo2);
- if (printer && printer->info_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);
}
/********************************************************************