#include "../libcli/security/security.h"
#include "librpc/gen_ndr/ndr_security.h"
#include "registry.h"
-#include "registry/reg_objects.h"
#include "include/printing.h"
#include "secrets.h"
#include "../librpc/gen_ndr/netlogon.h"
#include "printing/printer_list.h"
#include "../lib/tsocket/tsocket.h"
#include "rpc_client/cli_winreg_spoolss.h"
+#include "../libcli/smb/smbXcli_base.h"
/* macros stolen from s4 spoolss server */
#define SPOOLSS_BUFFER_UNION(fn,info,level) \
/* print notify back-channel pipe handle*/
struct rpc_pipe_client *cli_pipe;
- struct dcerpc_binding_handle *binding_handle;
uint32_t active_connections;
};
/* weird if the test succeeds !!! */
if (prn_hnd->notify.cli_chan == NULL ||
+ prn_hnd->notify.cli_chan->cli_pipe == NULL ||
+ prn_hnd->notify.cli_chan->cli_pipe->binding_handle == NULL ||
prn_hnd->notify.cli_chan->active_connections == 0) {
DEBUG(0, ("Trying to close unexisting backchannel!\n"));
DLIST_REMOVE(back_channels, prn_hnd->notify.cli_chan);
}
status = dcerpc_spoolss_ReplyClosePrinter(
- prn_hnd->notify.cli_chan->binding_handle,
+ prn_hnd->notify.cli_chan->cli_pipe->binding_handle,
talloc_tos(),
&prn_hnd->notify.cli_hnd,
&result);
/* if it's the last connection, deconnect the IPC$ share */
if (prn_hnd->notify.cli_chan->active_connections == 1) {
- prn_hnd->notify.cli_chan->binding_handle = NULL;
cli_shutdown(rpc_pipe_np_smb_conn(prn_hnd->notify.cli_chan->cli_pipe));
DLIST_REMOVE(back_channels, prn_hnd->notify.cli_chan);
TALLOC_FREE(prn_hnd->notify.cli_chan);
if (prn_hnd->notify.msg_ctx != NULL) {
messaging_deregister(prn_hnd->notify.msg_ctx,
MSG_PRINTER_NOTIFY2, NULL);
-
- /*
- * Tell the serverid.tdb we're no longer
- * interested in printer notify messages.
- */
-
- serverid_register_msg_flags(
- messaging_server_id(prn_hnd->notify.msg_ctx),
- false, FLAG_MSG_PRINT_NOTIFY);
}
}
if (prn_hnd->notify.cli_chan) {
prn_hnd->notify.cli_chan->active_connections--;
+ prn_hnd->notify.cli_chan = NULL;
}
}
if (ret != 0)
return WERR_BADFID; /* What to return here? */
- /* go ahead and re-read the services immediately */
- become_root();
- reload_services(msg_ctx, -1, false);
- unbecome_root();
-
- if ( lp_servicenumber( sharename ) >= 0 )
- return WERR_ACCESS_DENIED;
-
return WERR_OK;
}
/* Is there notification on this handle? */
if (prn_hnd->notify.cli_chan == NULL ||
+ prn_hnd->notify.cli_chan->cli_pipe == NULL ||
+ prn_hnd->notify.cli_chan->cli_pipe->binding_handle == NULL ||
prn_hnd->notify.cli_chan->active_connections == 0) {
return 0;
}
info.info0 = &info0;
status = dcerpc_spoolss_RouterReplyPrinterEx(
- prn_hnd->notify.cli_chan->binding_handle,
+ prn_hnd->notify.cli_chan->cli_pipe->binding_handle,
mem_ctx,
&prn_hnd->notify.cli_hnd,
prn_hnd->notify.change, /* color */
DATA_BLOB *data)
{
TALLOC_CTX *tmp_ctx;
- struct auth_session_info *session_info = NULL;
+ const struct auth_session_info *session_info = get_session_info_system();
struct spoolss_PrinterInfo2 *pinfo2;
- NTSTATUS status;
WERROR result;
const char *drivername;
int snum;
tmp_ctx = talloc_new(NULL);
if (!tmp_ctx) return;
- status = make_session_info_system(tmp_ctx, &session_info);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("do_drv_upgrade_printer: "
- "Could not create system session_info\n"));
- goto done;
- }
-
drivername = talloc_strndup(tmp_ctx, (const char *)data->data, data->length);
if (!drivername) {
DEBUG(0, ("do_drv_upgrade_printer: Out of memoery ?!\n"));
return WERR_INVALID_PARAM;
}
+ if (!*r->in.printername) {
+ return WERR_INVALID_PARAM;
+ }
+
if (r->in.level > 3) {
return WERR_INVALID_PARAM;
}
&& (RA_WIN2K == get_remote_arch()) )
{
DEBUG(10,("_spoolss_OpenPrinterEx: Enabling LAN/WAN hack for Win2k clients.\n"));
- sys_usleep( 500000 );
+ usleep( 500000 );
}
#endif
{NULL, "", -1 }
};
+static const int drv_cversion[] = {SPOOLSS_DRIVER_VERSION_9X,
+ SPOOLSS_DRIVER_VERSION_NT35,
+ SPOOLSS_DRIVER_VERSION_NT4,
+ SPOOLSS_DRIVER_VERSION_200X,
+ -1};
+
static int get_version_id(const char *arch)
{
int i;
{
struct spoolss_DriverInfo8 *info = NULL;
- struct spoolss_DriverInfo8 *info_win2k = NULL;
int version;
WERROR status;
struct dcerpc_binding_handle *b;
TALLOC_CTX *tmp_ctx = NULL;
+ int i;
+ bool found;
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */
goto done;
}
- status = winreg_get_driver(tmp_ctx, b,
- r->in.architecture, r->in.driver,
- version, &info);
- if (!W_ERROR_IS_OK(status)) {
- /* try for Win2k driver if "Windows NT x86" */
-
- if ( version == 2 ) {
- version = 3;
-
- status = winreg_get_driver(tmp_ctx, b,
- r->in.architecture,
- r->in.driver,
- version, &info);
- if (!W_ERROR_IS_OK(status)) {
- status = WERR_UNKNOWN_PRINTER_DRIVER;
- goto done;
- }
+ for (found = false, i = 0; drv_cversion[i] >= 0; i++) {
+ status = winreg_get_driver(tmp_ctx, b,
+ r->in.architecture, r->in.driver,
+ drv_cversion[i], &info);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(5, ("skipping del of driver with version %d\n",
+ drv_cversion[i]));
+ continue;
}
- /* otherwise it was a failure */
- else {
- status = WERR_UNKNOWN_PRINTER_DRIVER;
+ found = true;
+
+ if (printer_driver_in_use(tmp_ctx, b, info)) {
+ status = WERR_PRINTER_DRIVER_IN_USE;
goto done;
}
+ status = winreg_del_driver(tmp_ctx, b, info, drv_cversion[i]);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0, ("failed del of driver with version %d\n",
+ drv_cversion[i]));
+ goto done;
+ }
+ }
+ if (found == false) {
+ DEBUG(0, ("driver %s not found for deletion\n", r->in.driver));
+ status = WERR_UNKNOWN_PRINTER_DRIVER;
+ } else {
+ status = WERR_OK;
}
- if (printer_driver_in_use(tmp_ctx,
- get_session_info_system(),
- p->msg_ctx,
- info)) {
+done:
+ talloc_free(tmp_ctx);
+
+ return status;
+}
+
+static WERROR spoolss_dpd_version(TALLOC_CTX *mem_ctx,
+ struct pipes_struct *p,
+ struct spoolss_DeletePrinterDriverEx *r,
+ struct dcerpc_binding_handle *b,
+ struct spoolss_DriverInfo8 *info)
+{
+ WERROR status;
+ bool delete_files;
+
+ if (printer_driver_in_use(mem_ctx, b, info)) {
status = WERR_PRINTER_DRIVER_IN_USE;
goto done;
}
- if (version == 2) {
- status = winreg_get_driver(tmp_ctx, b,
- r->in.architecture,
- r->in.driver, 3, &info_win2k);
- if (W_ERROR_IS_OK(status)) {
- /* if we get to here, we now have 2 driver info structures to remove */
- /* remove the Win2k driver first*/
-
- status = winreg_del_driver(tmp_ctx, b,
- info_win2k, 3);
- talloc_free(info_win2k);
-
- /* this should not have failed---if it did, report to client */
- if (!W_ERROR_IS_OK(status)) {
- goto done;
- }
+ /*
+ * we have a couple of cases to consider.
+ * (1) Are any files in use? If so and DPD_DELETE_ALL_FILES is set,
+ * then the delete should fail if **any** files overlap with
+ * other drivers
+ * (2) If DPD_DELETE_UNUSED_FILES is set, then delete all
+ * non-overlapping files
+ * (3) If neither DPD_DELETE_ALL_FILES nor DPD_DELETE_UNUSED_FILES
+ * are set, then do not delete any files
+ * Refer to MSDN docs on DeletePrinterDriverEx() for details.
+ */
+
+ delete_files = r->in.delete_flags
+ & (DPD_DELETE_ALL_FILES | DPD_DELETE_UNUSED_FILES);
+
+
+ if (delete_files) {
+ bool in_use = printer_driver_files_in_use(mem_ctx, b, info);
+ if (in_use && (r->in.delete_flags & DPD_DELETE_ALL_FILES)) {
+ status = WERR_PRINTER_DRIVER_IN_USE;
+ goto done;
}
+ /*
+ * printer_driver_files_in_use() has trimmed overlapping files
+ * from info so they are not removed on DPD_DELETE_UNUSED_FILES
+ */
}
- status = winreg_del_driver(tmp_ctx, b,
- info, version);
-done:
- talloc_free(tmp_ctx);
+ status = winreg_del_driver(mem_ctx, b, info, info->version);
+ if (!W_ERROR_IS_OK(status)) {
+ goto done;
+ }
+
+ /*
+ * now delete any associated files if delete_files is
+ * true. Even if this part failes, we return succes
+ * because the driver doesn not exist any more
+ */
+ if (delete_files) {
+ delete_driver_files(p->session_info, info);
+ }
+done:
return status;
}
WERROR _spoolss_DeletePrinterDriverEx(struct pipes_struct *p,
struct spoolss_DeletePrinterDriverEx *r)
{
- struct spoolss_DriverInfo8 *info = NULL;
- struct spoolss_DriverInfo8 *info_win2k = NULL;
- int version;
- bool delete_files;
+ struct spoolss_DriverInfo8 *info = NULL;
WERROR status;
struct dcerpc_binding_handle *b;
TALLOC_CTX *tmp_ctx = NULL;
+ int i;
+ bool found;
/* if the user is not root, doesn't have SE_PRINT_OPERATOR privilege,
and not a printer admin, then fail */
}
/* check that we have a valid driver name first */
- if ((version = get_version_id(r->in.architecture)) == -1) {
+ if (get_version_id(r->in.architecture) == -1) {
/* this is what NT returns */
return WERR_INVALID_ENVIRONMENT;
}
- if (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) {
- version = r->in.version;
- }
-
tmp_ctx = talloc_new(p->mem_ctx);
if (!tmp_ctx) {
return WERR_NOMEM;
goto done;
}
- status = winreg_get_driver(tmp_ctx, b,
- r->in.architecture,
- r->in.driver,
- version,
- &info);
- if (!W_ERROR_IS_OK(status)) {
- status = WERR_UNKNOWN_PRINTER_DRIVER;
-
- /*
- * if the client asked for a specific version,
- * or this is something other than Windows NT x86,
- * then we've failed
- */
-
- if ( (r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) || (version !=2) )
- goto done;
-
- /* try for Win2k driver if "Windows NT x86" */
+ for (found = false, i = 0; drv_cversion[i] >= 0; i++) {
+ if ((r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION)
+ && (drv_cversion[i] != r->in.version)) {
+ continue;
+ }
- version = 3;
+ /* check if a driver with this version exists before delete */
status = winreg_get_driver(tmp_ctx, b,
- r->in.architecture,
- r->in.driver,
- version, &info);
+ r->in.architecture, r->in.driver,
+ drv_cversion[i], &info);
if (!W_ERROR_IS_OK(status)) {
- status = WERR_UNKNOWN_PRINTER_DRIVER;
- goto done;
+ DEBUG(5, ("skipping del of driver with version %d\n",
+ drv_cversion[i]));
+ continue;
}
- }
-
- if (printer_driver_in_use(tmp_ctx,
- get_session_info_system(),
- p->msg_ctx,
- info)) {
- status = WERR_PRINTER_DRIVER_IN_USE;
- goto done;
- }
-
- /*
- * we have a couple of cases to consider.
- * (1) Are any files in use? If so and DPD_DELTE_ALL_FILE is set,
- * then the delete should fail if **any** files overlap with
- * other drivers
- * (2) If DPD_DELTE_UNUSED_FILES is sert, then delete all
- * non-overlapping files
- * (3) If neither DPD_DELTE_ALL_FILE nor DPD_DELTE_ALL_FILES
- * is set, the do not delete any files
- * Refer to MSDN docs on DeletePrinterDriverEx() for details.
- */
-
- delete_files = r->in.delete_flags & (DPD_DELETE_ALL_FILES|DPD_DELETE_UNUSED_FILES);
-
- /* fail if any files are in use and DPD_DELETE_ALL_FILES is set */
-
- if (delete_files &&
- (r->in.delete_flags & DPD_DELETE_ALL_FILES) &&
- printer_driver_files_in_use(tmp_ctx,
- get_session_info_system(),
- p->msg_ctx,
- info)) {
- /* no idea of the correct error here */
- status = WERR_ACCESS_DENIED;
- goto done;
- }
-
-
- /* also check for W32X86/3 if necessary; maybe we already have? */
-
- if ( (version == 2) && ((r->in.delete_flags & DPD_DELETE_SPECIFIC_VERSION) != DPD_DELETE_SPECIFIC_VERSION) ) {
- status = winreg_get_driver(tmp_ctx, b,
- r->in.architecture,
- r->in.driver, 3, &info_win2k);
- if (W_ERROR_IS_OK(status)) {
-
- if (delete_files &&
- (r->in.delete_flags & DPD_DELETE_ALL_FILES) &&
- printer_driver_files_in_use(info,
- get_session_info_system(),
- p->msg_ctx,
- info_win2k)) {
- /* no idea of the correct error here */
- talloc_free(info_win2k);
- status = WERR_ACCESS_DENIED;
- goto done;
- }
-
- /* if we get to here, we now have 2 driver info structures to remove */
- /* remove the Win2k driver first*/
-
- status = winreg_del_driver(tmp_ctx, b,
- info_win2k,
- 3);
-
- /* this should not have failed---if it did, report to client */
-
- if (!W_ERROR_IS_OK(status)) {
- goto done;
- }
+ found = true;
- /*
- * now delete any associated files if delete_files is
- * true. Even if this part failes, we return succes
- * because the driver doesn not exist any more
- */
- if (delete_files) {
- delete_driver_files(get_session_info_system(),
- info_win2k);
- }
+ status = spoolss_dpd_version(tmp_ctx, p, r, b, info);
+ if (!W_ERROR_IS_OK(status)) {
+ DEBUG(0, ("failed to delete driver with version %d\n",
+ drv_cversion[i]));
+ goto done;
}
}
-
- status = winreg_del_driver(tmp_ctx, b,
- info,
- version);
- if (!W_ERROR_IS_OK(status)) {
- goto done;
- }
-
- /*
- * now delete any associated files if delete_files is
- * true. Even if this part failes, we return succes
- * because the driver doesn not exist any more
- */
- if (delete_files) {
- delete_driver_files(get_session_info_system(), info);
+ if (found == false) {
+ DEBUG(0, ("driver %s not found for deletion\n", r->in.driver));
+ status = WERR_UNKNOWN_PRINTER_DRIVER;
+ } else {
+ status = WERR_OK;
}
done:
if (!strcasecmp_m(value, "W3SvcInstalled")) {
*type = REG_DWORD;
- data->value = 0x00;
+ SIVAL(&data->value, 0, 0x00);
return WERR_OK;
}
if (!strcasecmp_m(value, "BeepEnabled")) {
*type = REG_DWORD;
- data->value = 0x00;
+ SIVAL(&data->value, 0, 0x00);
return WERR_OK;
}
if (!strcasecmp_m(value, "EventLog")) {
*type = REG_DWORD;
/* formally was 0x1b */
- data->value = 0x00;
+ SIVAL(&data->value, 0, 0x00);
return WERR_OK;
}
if (!strcasecmp_m(value, "NetPopup")) {
*type = REG_DWORD;
- data->value = 0x00;
+ SIVAL(&data->value, 0, 0x00);
return WERR_OK;
}
-- jerry */
if (RA_WINNT == get_remote_arch()) {
- data->value = 0x02;
+ SIVAL(&data->value, 0, 0x02);
} else {
- data->value = 0x03;
+ SIVAL(&data->value, 0, 0x03);
}
return WERR_OK;
if (!strcasecmp_m(value, "MinorVersion")) {
*type = REG_DWORD;
- data->value = 0x00;
+ SIVAL(&data->value, 0, 0x00);
return WERR_OK;
}
member of a AD domain */
if (lp_security() == SEC_ADS) {
- data->value = 0x01;
+ SIVAL(&data->value, 0, 0x01);
} else {
- data->value = 0x00;
+ SIVAL(&data->value, 0, 0x00);
}
return WERR_OK;
}
return false;
}
- if ( the_cli->protocol != PROTOCOL_NT1 ) {
+ if ( smbXcli_conn_protocol(the_cli->conn) != PROTOCOL_NT1 ) {
DEBUG(0,("spoolss_connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine));
cli_shutdown(the_cli);
return false;
/* the +2 is to strip the leading 2 backslashs */
fstrcpy(unix_printer, printer + 2);
- chan = talloc_zero(back_channels, struct notify_back_channel);
+ chan = talloc_zero(NULL, struct notify_back_channel);
if (!chan) {
return false;
}
TALLOC_FREE(chan);
return false;
}
- chan->binding_handle = chan->cli_pipe->binding_handle;
DLIST_ADD(back_channels, chan);
messaging_register(msg_ctx, NULL, MSG_PRINTER_NOTIFY2,
receive_notify2_message_list);
- /* Tell the connections db we're now interested in printer
- * notify messages. */
- serverid_register_msg_flags(messaging_server_id(msg_ctx),
- true, FLAG_MSG_PRINT_NOTIFY);
+ }
+
+ if (chan->cli_pipe == NULL ||
+ chan->cli_pipe->binding_handle == NULL) {
+ DEBUG(0, ("srv_spoolss_replyopenprinter: error - "
+ "NULL %s for printer %s\n",
+ chan->cli_pipe == NULL ?
+ "chan->cli_pipe" : "chan->cli_pipe->binding_handle",
+ printer));
+ return false;
}
/*
printer));
}
- status = dcerpc_spoolss_ReplyOpenPrinter(chan->binding_handle,
+ status = dcerpc_spoolss_ReplyOpenPrinter(chan->cli_pipe->binding_handle,
talloc_tos(),
printer,
localprinter,
int snum = -1;
struct spoolss_NotifyOption *option = r->in.notify_options;
struct sockaddr_storage client_ss;
- socklen_t client_len;
+ ssize_t client_len;
/* store the notify value in the printer struct */
struct spoolss_PrinterInfo2 *pinfo2,
TALLOC_CTX *mem_ctx)
{
- SETUP_SPOOLSS_NOTIFY_DATA_INTEGER(data, queue->job);
+ SETUP_SPOOLSS_NOTIFY_DATA_INTEGER(data, queue->sysjob);
}
/*******************************************************************
return WERR_BADFID;
}
+ /*
+ * When sending a PRINTER_NOTIFY_FIELD_SERVER_NAME we should send the
+ * correct servername.
+ */
+ pinfo2->servername = talloc_strdup(pinfo2, Printer->servername);
+ if (pinfo2->servername == NULL) {
+ return WERR_NOMEM;
+ }
+
for (i=0; i<option->count; i++) {
option_type = option->types[i];
&queue[j], info,
pinfo2, snum,
&option_type,
- queue[j].job,
+ queue[j].sysjob,
mem_ctx);
}
struct spoolss_PrinterInfo7 *r,
int snum)
{
- struct auth_session_info *session_info;
+ const struct auth_session_info *session_info = get_session_info_system();
struct GUID guid;
- NTSTATUS status;
-
- status = make_session_info_system(mem_ctx, &session_info);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(0, ("construct_printer_info7: "
- "Could not create system session_info\n"));
- return WERR_NOMEM;
- }
if (is_printer_published(mem_ctx, session_info, msg_ctx,
servername,
}
W_ERROR_HAVE_NO_MEMORY(r->guid);
- TALLOC_FREE(session_info);
return WERR_OK;
}
result = WERR_UNKNOWN_LEVEL;
break;
}
+ TALLOC_FREE(info2);
out:
if (!W_ERROR_IS_OK(result)) {
/****************************************************************************
****************************************************************************/
+static bool spoolss_conn_snum_used(struct smbd_server_connection *sconn,
+ int snum)
+{
+ /*
+ * As we do not know if we are embedded in the file server process
+ * or not, we have to pretend that all shares are in use.
+ */
+ return true;
+}
+
static bool add_printer_hook(TALLOC_CTX *ctx, struct security_token *token,
struct spoolss_SetPrinterInfo2 *info2,
const char *remote_machine,
/* reload our services immediately */
become_root();
- reload_services(msg_ctx, -1, false);
+ reload_services(NULL, spoolss_conn_snum_used, false);
unbecome_root();
numlines = 0;
WERROR result = WERR_OK;
struct dcerpc_binding_handle *b;
TALLOC_CTX *tmp_ctx;
+ bool ok;
tmp_ctx = talloc_new(mem_ctx);
if (!tmp_ctx) {
goto done;
}
- if (force_update || !strequal(printer->drivername, old_printer->drivername)) {
- push_reg_sz(tmp_ctx, &buffer, printer->drivername);
- winreg_set_printer_dataex(tmp_ctx, b,
+ if (printer->drivername != NULL &&
+ (force_update ||
+ !strequal(printer->drivername, old_printer->drivername))) {
+ ok = push_reg_sz(tmp_ctx, &buffer, printer->drivername);
+ if (!ok) {
+ DEBUG(0, ("%s data corrupted\n", SPOOL_REG_DRIVERNAME));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_DRIVERNAME,
REG_SZ,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_DRIVERNAME));
+ goto done;
+ }
if (!force_update) {
DEBUG(10,("update_printer: changing driver [%s]! Sending event!\n",
}
}
- if (force_update || !strequal(printer->comment, old_printer->comment)) {
- push_reg_sz(tmp_ctx, &buffer, printer->comment);
- winreg_set_printer_dataex(tmp_ctx, b,
+ if (printer->comment != NULL &&
+ (force_update ||
+ !strequal(printer->comment, old_printer->comment))) {
+ ok = push_reg_sz(tmp_ctx, &buffer, printer->comment);
+ if (!ok) {
+ DEBUG(0, ("comment data corrupted\n"));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_DESCRIPTION,
REG_SZ,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_DESCRIPTION));
+ goto done;
+ }
if (!force_update) {
notify_printer_comment(server_event_context(), msg_ctx,
}
}
- if (force_update || !strequal(printer->sharename, old_printer->sharename)) {
- push_reg_sz(tmp_ctx, &buffer, printer->sharename);
- winreg_set_printer_dataex(tmp_ctx, b,
+ if (printer->sharename != NULL &&
+ (force_update ||
+ !strequal(printer->sharename, old_printer->sharename))) {
+ ok = push_reg_sz(tmp_ctx, &buffer, printer->sharename);
+ if (!ok) {
+ DEBUG(0, ("sharename data corrupted\n"));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTSHARENAME,
REG_SZ,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_PRINTSHARENAME));
+ goto done;
+ }
if (!force_update) {
notify_printer_sharename(server_event_context(),
}
}
- if (force_update || !strequal(printer->printername, old_printer->printername)) {
+ if (printer->printername != NULL &&
+ (force_update ||
+ !strequal(printer->printername, old_printer->printername))) {
const char *p;
p = strrchr(printer->printername, '\\' );
p = printer->printername;
}
- push_reg_sz(tmp_ctx, &buffer, p);
- winreg_set_printer_dataex(tmp_ctx, b,
+ ok = push_reg_sz(tmp_ctx, &buffer, p);
+ if (!ok) {
+ DEBUG(0, ("printername data corrupted\n"));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTERNAME,
REG_SZ,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_PRINTSHARENAME));
+ goto done;
+ }
if (!force_update) {
notify_printer_printername(server_event_context(),
}
}
- if (force_update || !strequal(printer->portname, old_printer->portname)) {
- push_reg_sz(tmp_ctx, &buffer, printer->portname);
- winreg_set_printer_dataex(tmp_ctx, b,
+ if (printer->portname != NULL &&
+ (force_update ||
+ !strequal(printer->portname, old_printer->portname))) {
+ ok = push_reg_sz(tmp_ctx, &buffer, printer->portname);
+ if (!ok) {
+ DEBUG(0, ("portname data corrupted\n"));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PORTNAME,
REG_SZ,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_PORTNAME));
+ goto done;
+ }
if (!force_update) {
notify_printer_port(server_event_context(),
}
}
- if (force_update || !strequal(printer->location, old_printer->location)) {
- push_reg_sz(tmp_ctx, &buffer, printer->location);
- winreg_set_printer_dataex(tmp_ctx, b,
+ if (printer->location != NULL &&
+ (force_update ||
+ !strequal(printer->location, old_printer->location))) {
+ ok = push_reg_sz(tmp_ctx, &buffer, printer->location);
+ if (!ok) {
+ DEBUG(0, ("location data corrupted\n"));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_LOCATION,
REG_SZ,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_LOCATION));
+ goto done;
+ }
if (!force_update) {
notify_printer_location(server_event_context(),
}
}
- if (force_update || !strequal(printer->sepfile, old_printer->sepfile)) {
- push_reg_sz(tmp_ctx, &buffer, printer->sepfile);
- winreg_set_printer_dataex(tmp_ctx, b,
+ if (printer->sepfile != NULL &&
+ (force_update ||
+ !strequal(printer->sepfile, old_printer->sepfile))) {
+ ok = push_reg_sz(tmp_ctx, &buffer, printer->sepfile);
+ if (!ok) {
+ DEBUG(0, ("sepfile data corrupted\n"));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTSEPARATORFILE,
REG_SZ,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_PRINTSEPARATORFILE));
+ goto done;
+ }
if (!force_update) {
notify_printer_sepfile(server_event_context(),
}
}
- if (force_update || printer->starttime != old_printer->starttime) {
+ if (printer->starttime != 0 &&
+ (force_update ||
+ printer->starttime != old_printer->starttime)) {
buffer = data_blob_talloc(tmp_ctx, NULL, 4);
SIVAL(buffer.data, 0, printer->starttime);
- winreg_set_printer_dataex(tmp_ctx, b,
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTSTARTTIME,
REG_DWORD,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_PRINTSTARTTIME));
+ goto done;
+ }
}
- if (force_update || printer->untiltime != old_printer->untiltime) {
+ if (printer->untiltime != 0 &&
+ (force_update ||
+ printer->untiltime != old_printer->untiltime)) {
buffer = data_blob_talloc(tmp_ctx, NULL, 4);
SIVAL(buffer.data, 0, printer->untiltime);
- winreg_set_printer_dataex(tmp_ctx, b,
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTENDTIME,
REG_DWORD,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_PRINTENDTIME));
+ goto done;
+ }
}
if (force_update || printer->priority != old_printer->priority) {
buffer = data_blob_talloc(tmp_ctx, NULL, 4);
SIVAL(buffer.data, 0, printer->priority);
- winreg_set_printer_dataex(tmp_ctx, b,
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRIORITY,
REG_DWORD,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_PRINTENDTIME));
+ goto done;
+ }
}
if (force_update || printer->attributes != old_printer->attributes) {
buffer = data_blob_talloc(tmp_ctx, NULL, 4);
SIVAL(buffer.data, 0, (printer->attributes &
PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS));
- winreg_set_printer_dataex(tmp_ctx, b,
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_PRINTKEEPPRINTEDJOBS,
REG_DWORD,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_PRINTENDTIME));
+ goto done;
+ }
switch (printer->attributes & 0x3) {
case 0:
default:
spooling = "unknown";
}
- push_reg_sz(tmp_ctx, &buffer, spooling);
+ ok = push_reg_sz(tmp_ctx, &buffer, spooling);
+ if (!ok) {
+ DEBUG(0, ("printSpooling data corrupted\n"));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
buffer.length);
}
- push_reg_sz(tmp_ctx, &buffer, lp_netbios_name());
- winreg_set_printer_dataex(tmp_ctx, b,
+ ok = push_reg_sz(tmp_ctx, &buffer, lp_netbios_name());
+ if (!ok) {
+ DEBUG(0, ("shortServerName data corrupted\n"));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_SHORTSERVERNAME,
REG_SZ,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_SHORTSERVERNAME));
+ goto done;
+ }
dnsdomname = get_mydnsfullname();
if (dnsdomname != NULL && dnsdomname[0] != '\0') {
goto done;
}
- push_reg_sz(tmp_ctx, &buffer, longname);
- winreg_set_printer_dataex(tmp_ctx, b,
- printer->sharename,
- SPOOL_DSSPOOLER_KEY,
- SPOOL_REG_SERVERNAME,
- REG_SZ,
- buffer.data,
- buffer.length);
+ ok = push_reg_sz(tmp_ctx, &buffer, longname);
+ if (!ok) {
+ DEBUG(0, ("longname data corrupted\n"));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
+ result = winreg_set_printer_dataex(tmp_ctx, b,
+ printer->sharename,
+ SPOOL_DSSPOOLER_KEY,
+ SPOOL_REG_SERVERNAME,
+ REG_SZ,
+ buffer.data,
+ buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_SERVERNAME));
+ goto done;
+ }
uncname = talloc_asprintf(tmp_ctx, "\\\\%s\\%s",
lp_netbios_name(), printer->sharename);
- push_reg_sz(tmp_ctx, &buffer, uncname);
- winreg_set_printer_dataex(tmp_ctx, b,
+ ok = push_reg_sz(tmp_ctx, &buffer, uncname);
+ if (!ok) {
+ DEBUG(0, ("uncName data corrupted\n"));
+ result = WERR_INVALID_DATA;
+ goto done;
+ }
+ result = winreg_set_printer_dataex(tmp_ctx, b,
printer->sharename,
SPOOL_DSSPOOLER_KEY,
SPOOL_REG_UNCNAME,
REG_SZ,
buffer.data,
buffer.length);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(0, ("Failed to set %s\n", SPOOL_REG_UNCNAME));
+ goto done;
+ }
done:
talloc_free(tmp_ctx);
}
}
- update_dsspooler(tmp_ctx,
- get_session_info_system(),
- p->msg_ctx,
- snum,
- printer,
- old_printer);
+ result = update_dsspooler(tmp_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ snum,
+ printer,
+ old_printer);
+ if (!W_ERROR_IS_OK(result)) {
+ goto done;
+ }
printer_mask &= ~SPOOLSS_PRINTER_INFO_SECDESC;
t = gmtime(&queue->time);
- r->job_id = queue->job;
+ r->job_id = queue->sysjob;
r->printer_name = talloc_strdup(mem_ctx, lp_servicename(snum));
W_ERROR_HAVE_NO_MEMORY(r->printer_name);
t = gmtime(&queue->time);
- r->job_id = queue->job;
+ r->job_id = queue->sysjob;
r->printer_name = talloc_strdup(mem_ctx, lp_servicename(snum));
W_ERROR_HAVE_NO_MEMORY(r->printer_name);
int position, int snum,
struct spoolss_PrinterInfo2 *pinfo2)
{
- r->job_id = queue->job;
+ r->job_id = queue->sysjob;
r->next_job_id = 0;
if (next_queue) {
- r->next_job_id = next_queue->job;
+ r->next_job_id = next_queue->sysjob;
}
r->reserved = 0;
}
break;
case SPOOLSS_JOB_CONTROL_PAUSE:
- if (print_job_pause(session_info, p->msg_ctx,
- snum, r->in.job_id, &errcode)) {
- errcode = WERR_OK;
- }
+ errcode = print_job_pause(session_info, p->msg_ctx,
+ snum, r->in.job_id);
break;
case SPOOLSS_JOB_CONTROL_RESTART:
case SPOOLSS_JOB_CONTROL_RESUME:
- if (print_job_resume(session_info, p->msg_ctx,
- snum, r->in.job_id, &errcode)) {
- errcode = WERR_OK;
- }
+ errcode = print_job_resume(session_info, p->msg_ctx,
+ snum, r->in.job_id);
break;
case 0:
errcode = WERR_OK;
info2_mask = ~SPOOLSS_PRINTER_INFO_DEVMODE;
}
- update_dsspooler(p->mem_ctx,
- get_session_info_system(),
- p->msg_ctx,
- 0,
- info2,
- NULL);
+ err = update_dsspooler(p->mem_ctx,
+ get_session_info_system(),
+ p->msg_ctx,
+ 0,
+ info2,
+ NULL);
+ if (!W_ERROR_IS_OK(err)) {
+ return err;
+ }
err = winreg_update_printer_internal(p->mem_ctx,
get_session_info_system(),
bool found = false;
for (i=0; i<count; i++) {
- if (queue[i].job == (int)jobid) {
+ if (queue[i].sysjob == (int)jobid) {
found = true;
break;
}
WERROR result;
for (i=0; i<count; i++) {
- if (queue[i].job == (int)jobid) {
+ if (queue[i].sysjob == (int)jobid) {
found = true;
break;
}