summaryrefslogtreecommitdiff
path: root/source3/printing
diff options
context:
space:
mode:
Diffstat (limited to 'source3/printing')
-rw-r--r--source3/printing/notify.c30
-rw-r--r--source3/printing/nt_printing.c63
-rw-r--r--source3/printing/printing.c82
3 files changed, 62 insertions, 113 deletions
diff --git a/source3/printing/notify.c b/source3/printing/notify.c
index e19212eea8..756a6c23b9 100644
--- a/source3/printing/notify.c
+++ b/source3/printing/notify.c
@@ -273,8 +273,8 @@ static void send_spoolss_notify2_msg(SPOOLSS_NOTIFY_MSG *msg)
*/
if ((num_messages < 100) && (msg->type == JOB_NOTIFY_TYPE)
- && (msg->field == JOB_NOTIFY_TOTAL_BYTES
- || msg->field == JOB_NOTIFY_TOTAL_PAGES ))
+ && (msg->field == JOB_NOTIFY_FIELD_TOTAL_BYTES
+ || msg->field == JOB_NOTIFY_FIELD_TOTAL_PAGES ))
{
for (tmp_ptr = notify_queue_head; tmp_ptr; tmp_ptr = tmp_ptr->next)
@@ -400,7 +400,7 @@ void notify_printer_status_byname(const char *sharename, uint32 status)
int snum = print_queue_snum(sharename);
send_notify_field_values(sharename, PRINTER_NOTIFY_TYPE,
- PRINTER_NOTIFY_STATUS, snum,
+ PRINTER_NOTIFY_FIELD_STATUS, snum,
status, 0, 0);
}
@@ -418,7 +418,7 @@ void notify_job_status_byname(const char *sharename, uint32 jobid, uint32 status
/* Job id stored in id field, status in value1 */
send_notify_field_values(sharename, JOB_NOTIFY_TYPE,
- JOB_NOTIFY_STATUS, jobid,
+ JOB_NOTIFY_FIELD_STATUS, jobid,
status, 0, flags);
}
@@ -433,7 +433,7 @@ void notify_job_total_bytes(const char *sharename, uint32 jobid,
/* Job id stored in id field, status in value1 */
send_notify_field_values(sharename, JOB_NOTIFY_TYPE,
- JOB_NOTIFY_TOTAL_BYTES, jobid,
+ JOB_NOTIFY_FIELD_TOTAL_BYTES, jobid,
size, 0, 0);
}
@@ -443,21 +443,21 @@ void notify_job_total_pages(const char *sharename, uint32 jobid,
/* Job id stored in id field, status in value1 */
send_notify_field_values(sharename, JOB_NOTIFY_TYPE,
- JOB_NOTIFY_TOTAL_PAGES, jobid,
+ JOB_NOTIFY_FIELD_TOTAL_PAGES, jobid,
pages, 0, 0);
}
void notify_job_username(const char *sharename, uint32 jobid, char *name)
{
send_notify_field_buffer(
- sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_USER_NAME,
+ sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_FIELD_USER_NAME,
jobid, strlen(name) + 1, name);
}
void notify_job_name(const char *sharename, uint32 jobid, char *name)
{
send_notify_field_buffer(
- sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_DOCUMENT,
+ sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_FIELD_DOCUMENT,
jobid, strlen(name) + 1, name);
}
@@ -465,7 +465,7 @@ void notify_job_submitted(const char *sharename, uint32 jobid,
time_t submitted)
{
send_notify_field_buffer(
- sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_SUBMITTED,
+ sharename, JOB_NOTIFY_TYPE, JOB_NOTIFY_FIELD_SUBMITTED,
jobid, sizeof(submitted), (char *)&submitted);
}
@@ -474,7 +474,7 @@ void notify_printer_driver(int snum, char *driver_name)
const char *sharename = SERVICE(snum);
send_notify_field_buffer(
- sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_DRIVER_NAME,
+ sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_DRIVER_NAME,
snum, strlen(driver_name) + 1, driver_name);
}
@@ -483,7 +483,7 @@ void notify_printer_comment(int snum, char *comment)
const char *sharename = SERVICE(snum);
send_notify_field_buffer(
- sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_COMMENT,
+ sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_COMMENT,
snum, strlen(comment) + 1, comment);
}
@@ -492,7 +492,7 @@ void notify_printer_sharename(int snum, char *share_name)
const char *sharename = SERVICE(snum);
send_notify_field_buffer(
- sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_SHARE_NAME,
+ sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_SHARE_NAME,
snum, strlen(share_name) + 1, share_name);
}
@@ -501,7 +501,7 @@ void notify_printer_printername(int snum, char *printername)
const char *sharename = SERVICE(snum);
send_notify_field_buffer(
- sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PRINTER_NAME,
+ sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_PRINTER_NAME,
snum, strlen(printername) + 1, printername);
}
@@ -510,7 +510,7 @@ void notify_printer_port(int snum, char *port_name)
const char *sharename = SERVICE(snum);
send_notify_field_buffer(
- sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_PORT_NAME,
+ sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_PORT_NAME,
snum, strlen(port_name) + 1, port_name);
}
@@ -519,7 +519,7 @@ void notify_printer_location(int snum, char *location)
const char *sharename = SERVICE(snum);
send_notify_field_buffer(
- sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_LOCATION,
+ sharename, PRINTER_NOTIFY_TYPE, PRINTER_NOTIFY_FIELD_LOCATION,
snum, strlen(location) + 1, location);
}
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index d8658e9280..8e6fe1f364 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -343,7 +343,7 @@ static bool upgrade_to_version_3(void)
static int sec_desc_upg_fn( TDB_CONTEXT *the_tdb, TDB_DATA key,
TDB_DATA data, void *state )
{
- prs_struct ps;
+ NTSTATUS status;
SEC_DESC_BUF *sd_orig = NULL;
SEC_DESC_BUF *sd_new, *sd_store;
SEC_DESC *sec, *new_sec;
@@ -362,22 +362,16 @@ static int sec_desc_upg_fn( TDB_CONTEXT *the_tdb, TDB_DATA key,
/* upgrade the security descriptor */
- ZERO_STRUCT( ps );
-
- prs_init_empty( &ps, ctx, UNMARSHALL );
- prs_give_memory( &ps, (char *)data.dptr, data.dsize, False );
-
- if ( !sec_io_desc_buf( "sec_desc_upg_fn", &sd_orig, &ps, 1 ) ) {
+ status = unmarshall_sec_desc_buf(ctx, data.dptr, data.dsize, &sd_orig);
+ if (!NT_STATUS_IS_OK(status)) {
/* delete bad entries */
DEBUG(0,("sec_desc_upg_fn: Failed to parse original sec_desc for %si. Deleting....\n",
(const char *)key.dptr ));
tdb_delete( tdb_printers, key );
- prs_mem_free( &ps );
return 0;
}
if (!sd_orig) {
- prs_mem_free( &ps );
return 0;
}
sec = sd_orig->sd;
@@ -385,7 +379,6 @@ static int sec_desc_upg_fn( TDB_CONTEXT *the_tdb, TDB_DATA key,
/* is this even valid? */
if ( !sec->dacl ) {
- prs_mem_free( &ps );
return 0;
}
@@ -416,45 +409,31 @@ static int sec_desc_upg_fn( TDB_CONTEXT *the_tdb, TDB_DATA key,
&global_sid_Builtin_Administrators,
NULL, NULL, &size_new_sec );
if (!new_sec) {
- prs_mem_free( &ps );
return 0;
}
sd_new = make_sec_desc_buf( ctx, size_new_sec, new_sec );
if (!sd_new) {
- prs_mem_free( &ps );
return 0;
}
if ( !(sd_store = sec_desc_merge( ctx, sd_new, sd_orig )) ) {
DEBUG(0,("sec_desc_upg_fn: Failed to update sec_desc for %s\n", key.dptr ));
- prs_mem_free( &ps );
return 0;
}
- prs_mem_free( &ps );
-
/* store it back */
sd_size = ndr_size_security_descriptor(sd_store->sd, NULL, 0)
+ sizeof(SEC_DESC_BUF);
- if ( !prs_init(&ps, sd_size, ctx, MARSHALL) ) {
- DEBUG(0,("sec_desc_upg_fn: Failed to allocate prs memory for %s\n", key.dptr ));
- return 0;
- }
- if ( !sec_io_desc_buf( "sec_desc_upg_fn", &sd_store, &ps, 1 ) ) {
+ status = marshall_sec_desc_buf(ctx, sd_store, &data.dptr, &data.dsize);
+ if (!NT_STATUS_IS_OK(status)) {
DEBUG(0,("sec_desc_upg_fn: Failed to parse new sec_desc for %s\n", key.dptr ));
- prs_mem_free( &ps );
return 0;
}
- data.dptr = (uint8 *)prs_data_p( &ps );
- data.dsize = sd_size;
-
result = tdb_store( tdb_printers, key, data, TDB_REPLACE );
- prs_mem_free( &ps );
-
/* 0 to continue and non-zero to stop traversal */
return (result == -1);
@@ -789,13 +768,6 @@ bool get_a_builtin_ntform_by_string(const char *form_name, nt_forms_struct *form
return (i !=count);
}
-bool get_a_builtin_ntform(UNISTR2 *uni_formname,nt_forms_struct *form)
-{
- fstring form_name;
- unistr2_to_ascii(form_name, uni_formname, sizeof(form_name));
- return get_a_builtin_ntform_by_string(form_name, form);
-}
-
/****************************************************************************
get a form struct list.
****************************************************************************/
@@ -4590,24 +4562,25 @@ static uint32 update_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level)
got to keep the endians happy :).
****************************************************************************/
-static bool convert_driver_init( TALLOC_CTX *ctx, NT_DEVICEMODE *nt_devmode, uint8 *data, uint32 data_len )
+static bool convert_driver_init(TALLOC_CTX *mem_ctx, NT_DEVICEMODE *nt_devmode,
+ const uint8_t *data, uint32_t data_len)
{
- bool result = False;
- prs_struct ps;
- DEVICEMODE devmode;
+ struct spoolss_DeviceMode devmode;
+ enum ndr_err_code ndr_err;
+ DATA_BLOB blob;
ZERO_STRUCT(devmode);
- prs_init_empty(&ps, ctx, UNMARSHALL);
- ps.data_p = (char *)data;
- ps.buffer_size = data_len;
+ blob = data_blob_const(data, data_len);
- if (spoolss_io_devmode("phantom DEVMODE", &ps, 0, &devmode))
- result = convert_devicemode("", &devmode, &nt_devmode);
- else
- DEBUG(10,("convert_driver_init: error parsing DEVMODE\n"));
+ ndr_err = ndr_pull_struct_blob(&blob, mem_ctx, NULL, &devmode,
+ (ndr_pull_flags_fn_t)ndr_pull_spoolss_DeviceMode);
+ if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
+ DEBUG(10,("convert_driver_init: error parsing spoolss_DeviceMode\n"));
+ return false;
+ }
- return result;
+ return convert_devicemode("", &devmode, &nt_devmode);
}
/****************************************************************************
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 71c634442b..8524cfb2bd 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1387,6 +1387,18 @@ static void print_queue_receive(struct messaging_context *msg,
return;
}
+static void printing_pause_fd_handler(struct tevent_context *ev,
+ struct tevent_fd *fde,
+ uint16_t flags,
+ void *private_data)
+{
+ /*
+ * If pause_pipe[1] is closed it means the parent smbd
+ * and children exited or aborted.
+ */
+ exit_server_cleanly(NULL);
+}
+
static pid_t background_lpq_updater_pid = -1;
/****************************************************************************
@@ -1415,6 +1427,9 @@ void start_background_queue(void)
}
if(background_lpq_updater_pid == 0) {
+ struct tevent_fd *fde;
+ int ret;
+
/* Child. */
DEBUG(5,("start_background_queue: background LPQ thread started\n"));
@@ -1440,60 +1455,21 @@ void start_background_queue(void)
messaging_register(smbd_messaging_context(), NULL,
MSG_PRINTER_UPDATE, print_queue_receive);
- DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n"));
- while (1) {
- fd_set r_fds, w_fds;
- int ret;
- struct timeval to;
- int maxfd = 0;
-
- /* Process a signal and timed events now... */
- if (run_events(smbd_event_context(), 0, NULL, NULL)) {
- continue;
- }
-
- to.tv_sec = SMBD_SELECT_TIMEOUT;
- to.tv_usec = 0;
-
- /*
- * Setup the select fd sets.
- */
-
- FD_ZERO(&r_fds);
- FD_ZERO(&w_fds);
-
- /*
- * Are there any timed events waiting ? If so, ensure we don't
- * select for longer than it would take to wait for them.
- */
-
- {
- struct timeval now;
- GetTimeOfDay(&now);
-
- event_add_to_select_args(smbd_event_context(), &now,
- &r_fds, &w_fds, &to, &maxfd);
- }
-
- FD_SET(pause_pipe[1], &r_fds);
- maxfd = MAX(pause_pipe[1], maxfd);
-
- ret = sys_select(maxfd, &r_fds, &w_fds, NULL, &to);
-
- /*
- * If pause_pipe[1] is closed it means the parent smbd
- * and children exited or aborted. If sys_select()
- * failed, then something more sinister is wrong
- */
- if ((ret < 0) ||
- (ret == 1 && FD_ISSET(pause_pipe[1], &r_fds))) {
- exit_server_cleanly(NULL);
- }
-
- if (run_events(smbd_event_context(), ret, &r_fds, &w_fds)) {
- continue;
- }
+ fde = tevent_add_fd(smbd_event_context(), smbd_event_context(),
+ pause_pipe[1], TEVENT_FD_READ,
+ printing_pause_fd_handler,
+ NULL);
+ if (!fde) {
+ DEBUG(0,("tevent_add_fd() failed for pause_pipe\n"));
+ smb_panic("tevent_add_fd() failed for pause_pipe");
}
+
+ DEBUG(5,("start_background_queue: background LPQ thread waiting for messages\n"));
+ ret = tevent_loop_wait(smbd_event_context());
+ /* should not be reached */
+ DEBUG(0,("background_queue: tevent_loop_wait() exited with %d - %s\n",
+ ret, (ret == 0) ? "out of events" : strerror(errno)));
+ exit(1);
}
close(pause_pipe[1]);