/* print notify back-channel pipe handle*/
struct rpc_pipe_client *cli_pipe;
+ struct cli_state *cli;
uint32_t active_connections;
};
/* if it's the last connection, deconnect the IPC$ share */
if (prn_hnd->notify.cli_chan->active_connections == 1) {
- cli_shutdown(rpc_pipe_np_smb_conn(prn_hnd->notify.cli_chan->cli_pipe));
+ cli_shutdown(prn_hnd->notify.cli_chan->cli);
DLIST_REMOVE(back_channels, prn_hnd->notify.cli_chan);
TALLOC_FREE(prn_hnd->notify.cli_chan);
const char *sharename,
struct messaging_context *msg_ctx)
{
- char *cmd = lp_deleteprinter_cmd(talloc_tos());
+ char *cmd = lp_deleteprinter_command(talloc_tos());
char *command = NULL;
int ret;
bool is_print_op = false;
cache_key = talloc_asprintf(talloc_tos(), "PRINTERNAME/%s",
aprinter);
- if ((cache_key != NULL) && gencache_get(cache_key, &tmp, NULL)) {
+ if ((cache_key != NULL) &&
+ gencache_get(cache_key, talloc_tos(), &tmp, NULL)) {
found = (strcmp(tmp, printer_not_found) != 0);
if (!found) {
DEBUG(4, ("Printer %s not found\n", aprinter));
- SAFE_FREE(tmp);
+ TALLOC_FREE(tmp);
return WERR_INVALID_PRINTER_NAME;
}
fstrcpy(sname, tmp);
- SAFE_FREE(tmp);
+ TALLOC_FREE(tmp);
}
/* Search all sharenames first as this is easier than pulling
const char *printer = lp_const_servicename(snum);
/* no point going on if this is not a printer */
- if (!(lp_snum_ok(snum) && lp_print_ok(snum))) {
+ if (!(lp_snum_ok(snum) && lp_printable(snum))) {
continue;
}
#define SETUP_SPOOLSS_NOTIFY_DATA_DEVMODE(_data, _devmode) \
_data->data.devmode.devmode = _devmode;
-#define SETUP_SPOOLSS_NOTIFY_DATA_SECDESC(_data, _sd) \
- _data->data.sd.sd = dup_sec_desc(mem_ctx, _sd); \
- if (!_data->data.sd.sd) { \
- _data->data.sd.sd_size = 0; \
- } \
- _data->data.sd.sd_size = \
- ndr_size_security_descriptor(_data->data.sd.sd, 0);
-
static void init_systemtime_buffer(TALLOC_CTX *mem_ctx,
struct tm *t,
const char **pp,
/**********************************************************************
callback to receive a MSG_PRINTER_DRVUPGRADE message and interate
over all printers, upgrading ones as necessary
+ This is now *ONLY* called inside the background lpq updater. JRA.
**********************************************************************/
void do_drv_upgrade_printer(struct messaging_context *msg,
/* Iterate the printer list */
for (snum = 0; snum < n_services; snum++) {
- if (!lp_snum_ok(snum) || !lp_print_ok(snum)) {
+ if (!lp_snum_ok(snum) || !lp_printable(snum)) {
continue;
}
return WERR_INVALID_PARAM;
}
+ /*
+ * The printcap printer share inventory is updated on client
+ * enumeration. For clients that do not perform enumeration prior to
+ * access, such as cupssmbadd, we reinitialise the printer share
+ * inventory on open as well.
+ */
+ become_root();
+ delete_and_reload_printers(server_event_context(), p->msg_ctx);
+ unbecome_root();
+
/* some sanity check because you can open a printer or a print server */
/* aka: \\server\printer or \\server */
result = open_printer_hnd(p, r->out.handle, r->in.printername, 0);
if (!W_ERROR_IS_OK(result)) {
- DEBUG(0,("_spoolss_OpenPrinterEx: Cannot open a printer handle "
+ DEBUG(3,("_spoolss_OpenPrinterEx: Cannot open a printer handle "
"for printer %s\n", r->in.printername));
ZERO_STRUCTP(r->out.handle);
return result;
if ( r->in.access_mask & SERVER_ACCESS_ADMINISTER )
{
- if (!lp_ms_add_printer_wizard()) {
+ if (!lp_show_add_printer_wizard()) {
close_printer_handle(p, r->out.handle);
ZERO_STRUCTP(r->out.handle);
return WERR_ACCESS_DENIED;
rhost = raddr;
}
- if (!allow_access(lp_hostsdeny(snum), lp_hostsallow(snum),
+ if (!allow_access(lp_hosts_deny(snum), lp_hosts_allow(snum),
rhost, raddr)) {
DEBUG(3, ("access DENIED (hosts allow/deny) for printer open\n"));
ZERO_STRUCTP(r->out.handle);
if (!user_ok_token(uidtoname(p->session_info->unix_token->uid), NULL,
p->session_info->security_token, snum) ||
- !print_access_check(p->session_info,
- p->msg_ctx,
- snum,
- r->in.access_mask)) {
+ !W_ERROR_IS_OK(print_access_check(p->session_info,
+ p->msg_ctx,
+ snum,
+ r->in.access_mask))) {
DEBUG(3, ("access DENIED for printer open\n"));
close_printer_handle(p, r->out.handle);
ZERO_STRUCTP(r->out.handle);
enum ndr_err_code ndr_err;
struct spoolss_OSVersion os;
- os.major = 5; /* Windows 2000 == 5.0 */
- os.minor = 0;
- os.build = 2195; /* build */
+ os.major = lp_parm_int(GLOBAL_SECTION_SNUM,
+ "spoolss", "os_major", 5);
+ /* Windows 2000 == 5.0 */
+ os.minor = lp_parm_int(GLOBAL_SECTION_SNUM,
+ "spoolss", "os_minor", 0);
+ os.build = lp_parm_int(GLOBAL_SECTION_SNUM,
+ "spoolss", "os_build", 2195);
os.extra_string = ""; /* leave extra string empty */
ndr_err = ndr_push_struct_blob(&blob, mem_ctx, &os,
return WERR_GENERAL_FAILURE;
}
+ if (DEBUGLEVEL >= 10) {
+ NDR_PRINT_DEBUG(spoolss_OSVersion, &os);
+ }
+
*type = REG_BINARY;
data->binary = blob;
Connect to the client machine.
**********************************************************/
-static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe,
- struct sockaddr_storage *client_ss, const char *remote_machine)
+static bool spoolss_connect_to_client(struct rpc_pipe_client **pp_pipe, struct cli_state **pp_cli,
+ struct sockaddr_storage *client_ss, const char *remote_machine)
{
NTSTATUS ret;
- struct cli_state *the_cli;
struct sockaddr_storage rm_addr;
char addr[INET6_ADDRSTRLEN];
}
/* setup the connection */
- ret = cli_full_connection( &the_cli, lp_netbios_name(), remote_machine,
+ ret = cli_full_connection( pp_cli, lp_netbios_name(), remote_machine,
&rm_addr, 0, "IPC$", "IPC",
"", /* username */
"", /* domain */
return false;
}
- if ( smbXcli_conn_protocol(the_cli->conn) != PROTOCOL_NT1 ) {
+ if ( smbXcli_conn_protocol((*pp_cli)->conn) != PROTOCOL_NT1 ) {
DEBUG(0,("spoolss_connect_to_client: machine %s didn't negotiate NT protocol.\n", remote_machine));
- cli_shutdown(the_cli);
+ cli_shutdown(*pp_cli);
return false;
}
* Now start the NT Domain stuff :-).
*/
- ret = cli_rpc_pipe_open_noauth(the_cli, &ndr_table_spoolss.syntax_id, pp_pipe);
+ ret = cli_rpc_pipe_open_noauth(*pp_cli, &ndr_table_spoolss, pp_pipe);
if (!NT_STATUS_IS_OK(ret)) {
DEBUG(2,("spoolss_connect_to_client: unable to open the spoolss pipe on machine %s. Error was : %s.\n",
remote_machine, nt_errstr(ret)));
- cli_shutdown(the_cli);
+ cli_shutdown(*pp_cli);
return false;
}
}
chan->client_address = *client_ss;
- if (!spoolss_connect_to_client(&chan->cli_pipe, client_ss, unix_printer)) {
+ if (!spoolss_connect_to_client(&chan->cli_pipe, &chan->cli, client_ss, unix_printer)) {
TALLOC_FREE(chan);
return false;
}
struct spoolss_PrinterInfo2 *pinfo2,
TALLOC_CTX *mem_ctx)
{
- SETUP_SPOOLSS_NOTIFY_DATA_SECDESC(data, pinfo2->secdesc);
+ if (pinfo2->secdesc == NULL) {
+ data->data.sd.sd = NULL;
+ } else {
+ data->data.sd.sd = security_descriptor_copy(mem_ctx,
+ pinfo2->secdesc);
+ }
+ data->data.sd.sd_size = ndr_size_security_descriptor(data->data.sd.sd,
+ 0);
}
/*******************************************************************
for (snum = 0; snum < n_services; snum++) {
if (!lp_browseable(snum) ||
!lp_snum_ok(snum) ||
- !lp_print_ok(snum)) {
+ !lp_printable(snum)) {
continue; /* skip */
}
print_status_struct status;
struct spoolss_PrinterInfo2 *pinfo2 = NULL;
WERROR result;
+ struct tdb_print_db *pdb;
DEBUG(4,("printer_notify_info\n"));
return WERR_BADFID;
}
+ pdb = get_print_db_byname(Printer->sharename);
+ if (pdb == NULL) {
+ return WERR_BADFID;
+ }
+
/* Maybe we should use the SYSTEM session_info here... */
result = winreg_get_printer_internal(mem_ctx,
get_session_info_system(),
p->msg_ctx,
lp_servicename(talloc_tos(), snum), &pinfo2);
if (!W_ERROR_IS_OK(result)) {
- return WERR_BADFID;
+ result = WERR_BADFID;
+ goto err_pdb_drop;
}
/*
*/
pinfo2->servername = talloc_strdup(pinfo2, Printer->servername);
if (pinfo2->servername == NULL) {
- return WERR_NOMEM;
+ result = WERR_NOMEM;
+ goto err_pdb_drop;
}
- for (i=0; i<option->count; i++) {
+ for (i = 0; i < option->count; i++) {
option_type = option->types[i];
switch (option_type.type) {
count = print_queue_status(p->msg_ctx, snum, &queue,
&status);
- for (j=0; j<count; j++) {
+ for (j = 0; j < count; j++) {
+ uint32_t jobid;
+ jobid = sysjob_to_jobid_pdb(pdb,
+ queue[j].sysjob);
+ if (jobid == (uint32_t)-1) {
+ DEBUG(2, ("ignoring untracked job %d\n",
+ queue[j].sysjob));
+ continue;
+ }
+ /* FIXME check return value */
construct_notify_jobs_info(p->msg_ctx,
&queue[j], info,
pinfo2, snum,
&option_type,
- queue[j].sysjob,
+ jobid,
mem_ctx);
}
*/
talloc_free(pinfo2);
- return WERR_OK;
+ result = WERR_OK;
+err_pdb_drop:
+ release_print_db(pdb);
+ return result;
}
/****************************************************************
/* don't use talloc_steal() here unless you do a deep steal of all
the SEC_DESC members */
- r->secdesc = dup_sec_desc(mem_ctx, info2->secdesc);
+ r->secdesc = security_descriptor_copy(mem_ctx, info2->secdesc);
+ if (r->secdesc == NULL) {
+ return WERR_NOMEM;
+ }
}
return WERR_OK;
/* don't use talloc_steal() here unless you do a deep steal of all
the SEC_DESC members */
- r->secdesc = dup_sec_desc(mem_ctx, info2->secdesc);
- W_ERROR_HAVE_NO_MEMORY(r->secdesc);
+ r->secdesc = security_descriptor_copy(mem_ctx, info2->secdesc);
+ if (r->secdesc == NULL) {
+ return WERR_NOMEM;
+ }
}
return WERR_OK;
struct spoolss_PrinterInfo7 *r,
int snum)
{
- const struct auth_session_info *session_info = get_session_info_system();
- struct GUID guid;
+ const struct auth_session_info *session_info;
+ char *printer;
+ WERROR werr;
+ TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
+ if (tmp_ctx == NULL) {
+ return WERR_NOMEM;
+ }
+
+ session_info = get_session_info_system();
+ SMB_ASSERT(session_info != NULL);
- if (is_printer_published(mem_ctx, session_info, msg_ctx,
- servername,
- lp_servicename(talloc_tos(), snum), &guid, NULL)) {
+ printer = lp_servicename(tmp_ctx, snum);
+ if (printer == NULL) {
+ DEBUG(0, ("invalid printer snum %d\n", snum));
+ werr = WERR_INVALID_PARAM;
+ goto out_tmp_free;
+ }
+
+ if (is_printer_published(tmp_ctx, session_info, msg_ctx,
+ servername, printer, NULL)) {
+ struct GUID guid;
+ werr = nt_printer_guid_get(tmp_ctx, session_info, msg_ctx,
+ printer, &guid);
+ if (!W_ERROR_IS_OK(werr)) {
+ goto out_tmp_free;
+ }
r->guid = talloc_strdup_upper(mem_ctx, GUID_string2(mem_ctx, &guid));
r->action = DSPRINT_PUBLISH;
} else {
r->guid = talloc_strdup(mem_ctx, "");
r->action = DSPRINT_UNPUBLISH;
}
- W_ERROR_HAVE_NO_MEMORY(r->guid);
+ if (r->guid == NULL) {
+ werr = WERR_NOMEM;
+ goto out_tmp_free;
+ }
- return WERR_OK;
+ werr = WERR_OK;
+out_tmp_free:
+ talloc_free(tmp_ctx);
+ return werr;
}
/********************************************************************
return WERR_OK;
}
-
-/********************************************************************
-********************************************************************/
-
-static bool snum_is_shared_printer(int snum)
-{
- return (lp_browseable(snum) && lp_snum_ok(snum) && lp_print_ok(snum));
-}
-
/********************************************************************
Spoolss_enumprinters.
********************************************************************/
uint32_t *count_p)
{
int snum;
- int n_services = lp_numservices();
+ int n_services;
union spoolss_PrinterInfo *info = NULL;
uint32_t count = 0;
WERROR result = WERR_OK;
return WERR_NOMEM;
}
+ /*
+ * printer shares are updated on client enumeration. The background
+ * printer process updates printer_list.tdb at regular intervals.
+ */
+ become_root();
+ delete_and_reload_printers(server_event_context(), msg_ctx);
+ unbecome_root();
+
+ n_services = lp_numservices();
*count_p = 0;
*info_p = NULL;
listed. Windows responds to this call with a
WERR_CAN_NOT_COMPLETE so we should do the same. */
- if (servername[0] == '\\' && servername[1] == '\\') {
+ if (servername != NULL &&
+ (servername[0] == '\\') && (servername[1] == '\\')) {
s = servername + 2;
}
const char *arch,
int version)
{
- int i, num_strings = 0;
+ int i;
+ size_t num_strings = 0;
const char **array = NULL;
if (string_array == NULL) {
&array, &num_strings);
}
- if (presult) {
+ if (presult != NULL) {
*presult = array;
+ } else {
+ talloc_free(array);
}
return WERR_OK;
{
struct printer_handle *printer;
WERROR result;
+ uint32_t version = r->in.client_major_version;
int snum;
/* that's an [in out] buffer */
if (!r->in.buffer && (r->in.offered != 0)) {
- return WERR_INVALID_PARAM;
+ result = WERR_INVALID_PARAM;
+ goto err_info_free;
}
DEBUG(4,("_spoolss_GetPrinterDriver2\n"));
if (!(printer = find_printer_index_by_hnd(p, r->in.handle))) {
DEBUG(0,("_spoolss_GetPrinterDriver2: invalid printer handle!\n"));
- return WERR_INVALID_PRINTER_NAME;
+ result = WERR_INVALID_PRINTER_NAME;
+ goto err_info_free;
}
*r->out.needed = 0;
*r->out.server_minor_version = 0;
if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
- return WERR_BADFID;
+ result = WERR_BADFID;
+ goto err_info_free;
+ }
+
+ if (r->in.client_major_version == SPOOLSS_DRIVER_VERSION_2012) {
+ DEBUG(3,("_spoolss_GetPrinterDriver2: v4 driver requested, "
+ "downgrading to v3\n"));
+ version = SPOOLSS_DRIVER_VERSION_200X;
}
result = construct_printer_driver_info_level(p->mem_ctx,
r->in.level, r->out.info,
snum, printer->servername,
r->in.architecture,
- r->in.client_major_version);
+ version);
if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(r->out.info);
- return result;
+ goto err_info_free;
}
*r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_DriverInfo,
r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
+
+err_info_free:
+ TALLOC_FREE(r->out.info);
+ return result;
}
return WERR_INVALID_HANDLE;
}
- if (r->in.level != 1) {
+ if (r->in.info_ctr->level != 1) {
return WERR_UNKNOWN_LEVEL;
}
- info_1 = r->in.info.info1;
+ info_1 = r->in.info_ctr->info.info1;
/*
* a nice thing with NT is it doesn't listen to what you tell it.
*/
if (info_1->datatype) {
- if (strcmp(info_1->datatype, "RAW") != 0) {
+ /*
+ * The v4 driver model used in Windows 8 declares print jobs
+ * intended to bypass the XPS processing layer by setting
+ * datatype to "XPS_PASS" instead of "RAW".
+ */
+ if ((strcmp(info_1->datatype, "RAW") != 0)
+ && (strcmp(info_1->datatype, "XPS_PASS") != 0)) {
*r->out.job_id = 0;
return WERR_INVALID_DATATYPE;
}
static WERROR add_port_hook(TALLOC_CTX *ctx, struct security_token *token, const char *portname, const char *uri)
{
- char *cmd = lp_addport_cmd(talloc_tos());
+ char *cmd = lp_addport_command(talloc_tos());
char *command = NULL;
int ret;
bool is_print_op = false;
const char *remote_machine,
struct messaging_context *msg_ctx)
{
- char *cmd = lp_addprinter_cmd(talloc_tos());
+ char *cmd = lp_addprinter_command(talloc_tos());
char **qlines;
char *command = NULL;
int numlines;
/* Call addprinter hook */
/* Check changes to see if this is really needed */
- if (*lp_addprinter_cmd(talloc_tos()) &&
+ if (*lp_addprinter_command(talloc_tos()) &&
(!strequal(printer->drivername, old_printer->drivername) ||
!strequal(printer->comment, old_printer->comment) ||
!strequal(printer->portname, old_printer->portname) ||
static WERROR fill_job_info1(TALLOC_CTX *mem_ctx,
struct spoolss_JobInfo1 *r,
const print_queue_struct *queue,
+ uint32_t jobid,
int position, int snum,
struct spoolss_PrinterInfo2 *pinfo2)
{
t = gmtime(&queue->time);
- r->job_id = queue->sysjob;
+ r->job_id = jobid;
r->printer_name = lp_servicename(mem_ctx, snum);
W_ERROR_HAVE_NO_MEMORY(r->printer_name);
static WERROR fill_job_info2(TALLOC_CTX *mem_ctx,
struct spoolss_JobInfo2 *r,
const print_queue_struct *queue,
+ uint32_t jobid,
int position, int snum,
struct spoolss_PrinterInfo2 *pinfo2,
struct spoolss_DeviceMode *devmode)
t = gmtime(&queue->time);
- r->job_id = queue->sysjob;
+ r->job_id = jobid;
r->printer_name = lp_servicename(mem_ctx, snum);
W_ERROR_HAVE_NO_MEMORY(r->printer_name);
return WERR_OK;
}
-/****************************************************************************
-fill_job_info3
-****************************************************************************/
-
-static WERROR fill_job_info3(TALLOC_CTX *mem_ctx,
- struct spoolss_JobInfo3 *r,
- const print_queue_struct *queue,
- const print_queue_struct *next_queue,
- int position, int snum,
- struct spoolss_PrinterInfo2 *pinfo2)
-{
- r->job_id = queue->sysjob;
- r->next_job_id = 0;
- if (next_queue) {
- r->next_job_id = next_queue->sysjob;
- }
- r->reserved = 0;
-
- return WERR_OK;
-}
-
/****************************************************************************
Enumjobs at level 1.
****************************************************************************/
union spoolss_JobInfo *info;
int i;
WERROR result = WERR_OK;
+ uint32_t num_filled;
+ struct tdb_print_db *pdb;
info = talloc_array(mem_ctx, union spoolss_JobInfo, num_queues);
- W_ERROR_HAVE_NO_MEMORY(info);
+ if (info == NULL) {
+ result = WERR_NOMEM;
+ goto err_out;
+ }
+
+ pdb = get_print_db_byname(pinfo2->sharename);
+ if (pdb == NULL) {
+ result = WERR_INVALID_PARAM;
+ goto err_info_free;
+ }
- *count = num_queues;
+ num_filled = 0;
+ for (i = 0; i < num_queues; i++) {
+ uint32_t jobid = sysjob_to_jobid_pdb(pdb, queue[i].sysjob);
+ if (jobid == (uint32_t)-1) {
+ DEBUG(4, ("skipping sysjob %d\n", queue[i].sysjob));
+ continue;
+ }
- for (i=0; i<*count; i++) {
result = fill_job_info1(info,
- &info[i].info1,
+ &info[num_filled].info1,
&queue[i],
+ jobid,
i,
snum,
pinfo2);
if (!W_ERROR_IS_OK(result)) {
- goto out;
+ goto err_pdb_drop;
}
- }
- out:
- if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(info);
- *count = 0;
- return result;
+ num_filled++;
}
+ release_print_db(pdb);
*info_p = info;
+ *count = num_filled;
return WERR_OK;
+
+err_pdb_drop:
+ release_print_db(pdb);
+err_info_free:
+ TALLOC_FREE(info);
+err_out:
+ *count = 0;
+ return result;
}
/****************************************************************************
union spoolss_JobInfo *info;
int i;
WERROR result = WERR_OK;
+ uint32_t num_filled;
+ struct tdb_print_db *pdb;
info = talloc_array(mem_ctx, union spoolss_JobInfo, num_queues);
- W_ERROR_HAVE_NO_MEMORY(info);
+ if (info == NULL) {
+ result = WERR_NOMEM;
+ goto err_out;
+ }
- *count = num_queues;
+ pdb = get_print_db_byname(pinfo2->sharename);
+ if (pdb == NULL) {
+ result = WERR_INVALID_PARAM;
+ goto err_info_free;
+ }
- for (i=0; i<*count; i++) {
+ num_filled = 0;
+ for (i = 0; i< num_queues; i++) {
struct spoolss_DeviceMode *devmode;
+ uint32_t jobid = sysjob_to_jobid_pdb(pdb, queue[i].sysjob);
+ if (jobid == (uint32_t)-1) {
+ DEBUG(4, ("skipping sysjob %d\n", queue[i].sysjob));
+ continue;
+ }
result = spoolss_create_default_devmode(info,
pinfo2->printername,
&devmode);
if (!W_ERROR_IS_OK(result)) {
DEBUG(3, ("Can't proceed w/o a devmode!"));
- goto out;
+ goto err_pdb_drop;
}
result = fill_job_info2(info,
- &info[i].info2,
+ &info[num_filled].info2,
&queue[i],
+ jobid,
i,
snum,
pinfo2,
devmode);
if (!W_ERROR_IS_OK(result)) {
- goto out;
+ goto err_pdb_drop;
}
+ num_filled++;
}
- out:
- if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(info);
- *count = 0;
- return result;
- }
-
+ release_print_db(pdb);
*info_p = info;
+ *count = num_filled;
return WERR_OK;
+
+err_pdb_drop:
+ release_print_db(pdb);
+err_info_free:
+ TALLOC_FREE(info);
+err_out:
+ *count = 0;
+ return result;
}
/****************************************************************************
union spoolss_JobInfo *info;
int i;
WERROR result = WERR_OK;
+ uint32_t num_filled;
+ struct tdb_print_db *pdb;
info = talloc_array(mem_ctx, union spoolss_JobInfo, num_queues);
- W_ERROR_HAVE_NO_MEMORY(info);
-
- *count = num_queues;
+ if (info == NULL) {
+ result = WERR_NOMEM;
+ goto err_out;
+ }
- for (i=0; i<*count; i++) {
- const print_queue_struct *next_queue = NULL;
+ pdb = get_print_db_byname(pinfo2->sharename);
+ if (pdb == NULL) {
+ result = WERR_INVALID_PARAM;
+ goto err_info_free;
+ }
- if (i+1 < *count) {
- next_queue = &queue[i+1];
+ num_filled = 0;
+ for (i = 0; i < num_queues; i++) {
+ uint32_t jobid = sysjob_to_jobid_pdb(pdb, queue[i].sysjob);
+ if (jobid == (uint32_t)-1) {
+ DEBUG(4, ("skipping sysjob %d\n", queue[i].sysjob));
+ continue;
}
- result = fill_job_info3(info,
- &info[i].info3,
- &queue[i],
- next_queue,
- i,
- snum,
- pinfo2);
- if (!W_ERROR_IS_OK(result)) {
- goto out;
- }
- }
+ info[num_filled].info3.job_id = jobid;
+ /* next_job_id is overwritten on next iteration */
+ info[num_filled].info3.next_job_id = 0;
+ info[num_filled].info3.reserved = 0;
- out:
- if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(info);
- *count = 0;
- return result;
+ if (num_filled > 0) {
+ info[num_filled - 1].info3.next_job_id = jobid;
+ }
+ num_filled++;
}
+ release_print_db(pdb);
*info_p = info;
+ *count = num_filled;
return WERR_OK;
+
+err_info_free:
+ TALLOC_FREE(info);
+err_out:
+ *count = 0;
+ return result;
}
/****************************************************************
return WERR_INVALID_PARAM;
}
+ if ((r->in.level != 1) && (r->in.level != 2) && (r->in.level != 3)) {
+ DEBUG(4, ("EnumJobs level %d not supported\n", r->in.level));
+ return WERR_UNKNOWN_LEVEL;
+ }
+
DEBUG(4,("_spoolss_EnumJobs\n"));
*r->out.needed = 0;
pinfo2, r->out.info, r->out.count);
break;
default:
- result = WERR_UNKNOWN_LEVEL;
+ SMB_ASSERT(false); /* level checked on entry */
break;
}
/* that's an [in out] buffer */
if (!r->in.buffer && (r->in.offered != 0)) {
+ TALLOC_FREE(r->out.info);
return WERR_INVALID_PARAM;
}
static WERROR enumports_hook(TALLOC_CTX *ctx, int *count, char ***lines)
{
- char *cmd = lp_enumports_cmd(talloc_tos());
+ char *cmd = lp_enumports_command(talloc_tos());
char **qlines = NULL;
char *command = NULL;
int numlines;
/* FIXME!!! smbd should check to see if the driver is installed before
trying to add a printer like this --jerry */
- if (*lp_addprinter_cmd(talloc_tos()) ) {
+ if (*lp_addprinter_command(talloc_tos()) ) {
char *raddr;
raddr = tsocket_address_inet_addr_string(p->remote_address,
}
/* you must be a printer admin to add a new printer */
- if (!print_access_check(p->session_info,
- p->msg_ctx,
- snum,
- PRINTER_ACCESS_ADMINISTER)) {
+ if (!W_ERROR_IS_OK(print_access_check(p->session_info,
+ p->msg_ctx,
+ snum,
+ PRINTER_ACCESS_ADMINISTER))) {
return WERR_ACCESS_DENIED;
}
char **path)
{
const char *pservername = NULL;
- const char *long_archi = SPOOLSS_ARCHITECTURE_NT_X86;
+ const char *long_archi;
const char *short_archi;
*path = NULL;
/* environment may be empty */
if (environment && strlen(environment)) {
long_archi = environment;
+ } else {
+ long_archi = lp_parm_const_string(GLOBAL_SECTION_SNUM,
+ "spoolss", "architecture",
+ SPOOLSS_ARCHITECTURE_NT_X86);
}
/* servername may be empty */
WERROR _spoolss_AddForm(struct pipes_struct *p,
struct spoolss_AddForm *r)
{
- struct spoolss_AddFormInfo1 *form = r->in.info.info1;
+ struct spoolss_AddFormInfo1 *form;
int snum = -1;
WERROR status = WERR_OK;
struct printer_handle *Printer = find_printer_index_by_hnd(p, r->in.handle);
return WERR_ACCESS_DENIED;
}
+ if (r->in.info_ctr->level != 1) {
+ return WERR_INVALID_LEVEL;
+ }
+
+ form = r->in.info_ctr->info.info1;
+ if (!form) {
+ return WERR_INVALID_PARAM;
+ }
+
switch (form->flags) {
case SPOOLSS_FORM_USER:
case SPOOLSS_FORM_BUILTIN:
WERROR _spoolss_SetForm(struct pipes_struct *p,
struct spoolss_SetForm *r)
{
- struct spoolss_AddFormInfo1 *form = r->in.info.info1;
+ struct spoolss_AddFormInfo1 *form;
const char *form_name = r->in.form_name;
int snum = -1;
WERROR status = WERR_OK;
return WERR_ACCESS_DENIED;
}
+ if (r->in.info_ctr->level != 1) {
+ return WERR_INVALID_LEVEL;
+ }
+
+ form = r->in.info_ctr->info.info1;
+ if (!form) {
+ return WERR_INVALID_PARAM;
+ }
+
tmp_ctx = talloc_new(p->mem_ctx);
if (!tmp_ctx) {
return WERR_NOMEM;
int count, int snum,
struct spoolss_PrinterInfo2 *pinfo2,
uint32_t jobid,
+ int sysjob,
struct spoolss_JobInfo1 *r)
{
int i = 0;
bool found = false;
for (i=0; i<count; i++) {
- if (queue[i].sysjob == (int)jobid) {
+ if (queue[i].sysjob == sysjob) {
found = true;
break;
}
return fill_job_info1(mem_ctx,
r,
&queue[i],
+ jobid,
i,
snum,
pinfo2);
int count, int snum,
struct spoolss_PrinterInfo2 *pinfo2,
uint32_t jobid,
+ int sysjob,
struct spoolss_JobInfo2 *r)
{
int i = 0;
WERROR result;
for (i=0; i<count; i++) {
- if (queue[i].sysjob == (int)jobid) {
+ if (queue[i].sysjob == sysjob) {
found = true;
break;
}
return fill_job_info2(mem_ctx,
r,
&queue[i],
+ jobid,
i,
snum,
pinfo2,
{
WERROR result = WERR_OK;
struct spoolss_PrinterInfo2 *pinfo2 = NULL;
+ const char *svc_name;
+ int sysjob;
int snum;
int count;
+ struct tdb_print_db *pdb;
print_queue_struct *queue = NULL;
print_status_struct prt_status;
/* that's an [in out] buffer */
if (!r->in.buffer && (r->in.offered != 0)) {
- return WERR_INVALID_PARAM;
+ result = WERR_INVALID_PARAM;
+ goto err_jinfo_free;
}
DEBUG(5,("_spoolss_GetJob\n"));
*r->out.needed = 0;
if (!get_printer_snum(p, r->in.handle, &snum, NULL)) {
- return WERR_BADFID;
+ result = WERR_BADFID;
+ goto err_jinfo_free;
+ }
+
+ svc_name = lp_const_servicename(snum);
+ if (svc_name == NULL) {
+ result = WERR_INVALID_PARAM;
+ goto err_jinfo_free;
}
result = winreg_get_printer_internal(p->mem_ctx,
get_session_info_system(),
p->msg_ctx,
- lp_const_servicename(snum),
+ svc_name,
&pinfo2);
if (!W_ERROR_IS_OK(result)) {
- return result;
+ goto err_jinfo_free;
+ }
+
+ pdb = get_print_db_byname(svc_name);
+ if (pdb == NULL) {
+ DEBUG(3, ("failed to get print db for svc %s\n", svc_name));
+ result = WERR_INVALID_PARAM;
+ goto err_pinfo_free;
+ }
+
+ sysjob = jobid_to_sysjob_pdb(pdb, r->in.job_id);
+ release_print_db(pdb);
+ if (sysjob == -1) {
+ DEBUG(3, ("no sysjob for spoolss jobid %u\n", r->in.job_id));
+ result = WERR_INVALID_PARAM;
+ goto err_pinfo_free;
}
count = print_queue_status(p->msg_ctx, snum, &queue, &prt_status);
case 1:
result = getjob_level_1(p->mem_ctx,
queue, count, snum, pinfo2,
- r->in.job_id, &r->out.info->info1);
+ r->in.job_id, sysjob,
+ &r->out.info->info1);
break;
case 2:
result = getjob_level_2(p->mem_ctx,
queue, count, snum, pinfo2,
- r->in.job_id, &r->out.info->info2);
+ r->in.job_id, sysjob,
+ &r->out.info->info2);
break;
default:
result = WERR_UNKNOWN_LEVEL;
TALLOC_FREE(pinfo2);
if (!W_ERROR_IS_OK(result)) {
- TALLOC_FREE(r->out.info);
- return result;
+ goto err_jinfo_free;
}
*r->out.needed = SPOOLSS_BUFFER_UNION(spoolss_JobInfo, r->out.info,
r->out.info = SPOOLSS_BUFFER_OK(r->out.info, NULL);
return SPOOLSS_BUFFER_OK(WERR_OK, WERR_INSUFFICIENT_BUFFER);
+
+err_pinfo_free:
+ TALLOC_FREE(pinfo2);
+err_jinfo_free:
+ TALLOC_FREE(r->out.info);
+ return result;
}
/****************************************************************
}
/****************************************************************
- _spoolss_61
+ _spoolss_RpcSendRecvBidiData
****************************************************************/
-WERROR _spoolss_61(struct pipes_struct *p,
- struct spoolss_61 *r)
+WERROR _spoolss_RpcSendRecvBidiData(struct pipes_struct *p,
+ struct spoolss_RpcSendRecvBidiData *r)
{
p->fault_state = DCERPC_FAULT_OP_RNG_ERROR;
return WERR_NOT_SUPPORTED;