mirror of
https://github.com/samba-team/samba.git
synced 2025-01-29 21:47:30 +03:00
s3-spoolss: Convert do_drv_upgrade_printer() to winreg functions.
Signed-off-by: Jim McDonough <jmcd@samba.org>
This commit is contained in:
parent
375bdfc7f8
commit
78b985ac3e
@ -1283,47 +1283,72 @@ void do_drv_upgrade_printer(struct messaging_context *msg,
|
|||||||
struct server_id server_id,
|
struct server_id server_id,
|
||||||
DATA_BLOB *data)
|
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 snum;
|
||||||
int n_services = lp_numservices();
|
int n_services = lp_numservices();
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
||||||
len = MIN(data->length,sizeof(drivername)-1);
|
tmp_ctx = talloc_new(NULL);
|
||||||
strncpy(drivername, (const char *)data->data, len);
|
if (!tmp_ctx) return;
|
||||||
|
|
||||||
DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername ));
|
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);
|
||||||
|
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));
|
||||||
|
|
||||||
/* Iterate the printer list */
|
/* Iterate the printer list */
|
||||||
|
|
||||||
for (snum=0; snum<n_services; snum++)
|
for (snum = 0; snum < n_services; snum++) {
|
||||||
{
|
if (!lp_snum_ok(snum) || !lp_print_ok(snum)) {
|
||||||
if (lp_snum_ok(snum) && lp_print_ok(snum) )
|
continue;
|
||||||
{
|
}
|
||||||
WERROR result;
|
|
||||||
NT_PRINTER_INFO_LEVEL *printer = NULL;
|
|
||||||
|
|
||||||
result = get_a_printer(NULL, &printer, 2, lp_const_servicename(snum));
|
result = winreg_get_printer(tmp_ctx, server_info, NULL,
|
||||||
if (!W_ERROR_IS_OK(result))
|
lp_const_servicename(snum),
|
||||||
continue;
|
&pinfo2);
|
||||||
|
|
||||||
if (printer && printer->info_2 && !strcmp(drivername, printer->info_2->drivername))
|
if (!W_ERROR_IS_OK(result)) {
|
||||||
{
|
continue;
|
||||||
DEBUG(6,("Updating printer [%s]\n", printer->info_2->printername));
|
}
|
||||||
|
|
||||||
/* all we care about currently is the change_id */
|
if (strcmp(drivername, pinfo2->drivername) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
result = mod_a_printer(printer, 2);
|
DEBUG(6,("Updating printer [%s]\n", pinfo2->printername));
|
||||||
if (!W_ERROR_IS_OK(result)) {
|
|
||||||
DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n",
|
|
||||||
win_errstr(result)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
free_a_printer(&printer, 2);
|
/* all we care about currently is the change_id */
|
||||||
|
result = winreg_printer_update_changeid(tmp_ctx,
|
||||||
|
server_info,
|
||||||
|
pinfo2->printername);
|
||||||
|
|
||||||
|
if (!W_ERROR_IS_OK(result)) {
|
||||||
|
DEBUG(3, ("do_drv_upgrade_printer: "
|
||||||
|
"Failed to update changeid [%s]\n",
|
||||||
|
win_errstr(result)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* all done */
|
/* all done */
|
||||||
|
done:
|
||||||
|
talloc_free(tmp_ctx);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************
|
/********************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user