summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-11-07 02:38:42 +0000
committerJeremy Allison <jra@samba.org>2002-11-07 02:38:42 +0000
commit47955b2f6cd10ac690705d322a8862c23f18072c (patch)
tree457151a2a3cc4ac3598c7cb45850b6dd598de03a
parentbcf0c11e3d4477eb029a0259ed17db9ddbe706d5 (diff)
downloadsamba-47955b2f6cd10ac690705d322a8862c23f18072c.tar.gz
samba-47955b2f6cd10ac690705d322a8862c23f18072c.tar.bz2
samba-47955b2f6cd10ac690705d322a8862c23f18072c.zip
Merge of scalable printing code fix... Needs testing.
Also tidied up some of Richard's code (I don't think he uses the compiler flags -g -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith -Wcast-qual like I do :-) :-). Jeremy. (This used to be commit 10024ed06e9d91f24fdc78d59eef2f76bf395438)
-rw-r--r--source3/Makefile.in2
-rw-r--r--source3/libsmb/cliconnect.c2
-rw-r--r--source3/passdb/secrets.c15
-rw-r--r--source3/printing/notify.c89
-rw-r--r--source3/printing/printing.c248
-rw-r--r--source3/rpc_client/cli_spoolss_notify.c4
-rw-r--r--source3/rpc_parse/parse_spoolss.c2
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c38
-rw-r--r--source3/rpcclient/display_sec.c2
-rw-r--r--source3/tdb/tdb.c3
-rw-r--r--source3/tdb/tdbutil.c19
-rw-r--r--source3/utils/profiles.c10
-rw-r--r--source3/utils/smbcontrol.c3
13 files changed, 370 insertions, 67 deletions
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 28965ae4d1..8d0add9b7a 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -330,7 +330,7 @@ STATUS_OBJ = utils/status.o $(LOCKING_OBJ) $(PARAM_OBJ) \
$(UBIQX_OBJ) $(PROFILE_OBJ) $(LIB_OBJ) $(POPT_LIB_OBJ)
SMBCONTROL_OBJ = utils/smbcontrol.o $(LOCKING_OBJ) $(PARAM_OBJ) \
- $(UBIQX_OBJ) $(PROFILE_OBJ) $(LIB_OBJ) printing/notify.o
+ $(UBIQX_OBJ) $(PROFILE_OBJ) $(LIB_OBJ)
SMBTREE_OBJ = utils/smbtree.o $(LOCKING_OBJ) $(PARAM_OBJ) \
$(UBIQX_OBJ) $(PROFILE_OBJ) $(LIB_OBJ) $(LIBSMB_OBJ)
diff --git a/source3/libsmb/cliconnect.c b/source3/libsmb/cliconnect.c
index 6a21121f43..a404928a93 100644
--- a/source3/libsmb/cliconnect.c
+++ b/source3/libsmb/cliconnect.c
@@ -1277,7 +1277,7 @@ again:
Attempt a NetBIOS session request, falling back to *SMBSERVER if needed.
****************************************************************************/
-BOOL attempt_netbios_session_request(struct cli_state *cli, char *srchost, char *desthost,
+BOOL attempt_netbios_session_request(struct cli_state *cli, const char *srchost, const char *desthost,
struct in_addr *pdest_ip)
{
struct nmb_name calling, called;
diff --git a/source3/passdb/secrets.c b/source3/passdb/secrets.c
index ad56fcedd1..29afaddea3 100644
--- a/source3/passdb/secrets.c
+++ b/source3/passdb/secrets.c
@@ -209,7 +209,7 @@ char *trustdom_keystr(const char *domain)
Lock the trust password entry.
************************************************************************/
-BOOL secrets_lock_trust_account_password(char *domain, BOOL dolock)
+BOOL secrets_lock_trust_account_password(const char *domain, BOOL dolock)
{
if (!tdb)
return False;
@@ -263,7 +263,7 @@ BOOL secrets_fetch_trust_account_password(const char *domain, uint8 ret_pwd[16],
Routine to get account password to trusted domain
************************************************************************/
-BOOL secrets_fetch_trusted_domain_password(char *domain, char** pwd,
+BOOL secrets_fetch_trusted_domain_password(const char *domain, char** pwd,
DOM_SID *sid, time_t *pass_last_set_time)
{
struct trusted_dom_pass *pass;
@@ -302,7 +302,8 @@ BOOL secrets_fetch_trusted_domain_password(char *domain, char** pwd,
/************************************************************************
Routine to set the trust account password for a domain.
************************************************************************/
-BOOL secrets_store_trust_account_password(char *domain, uint8 new_pwd[16])
+
+BOOL secrets_store_trust_account_password(const char *domain, uint8 new_pwd[16])
{
struct machine_acct_pass pass;
@@ -322,7 +323,7 @@ BOOL secrets_store_trust_account_password(char *domain, uint8 new_pwd[16])
* @return true if succeeded
**/
-BOOL secrets_store_trusted_domain_password(char* domain, smb_ucs2_t *uni_dom_name,
+BOOL secrets_store_trusted_domain_password(const char* domain, smb_ucs2_t *uni_dom_name,
size_t uni_name_len, char* pwd,
DOM_SID sid)
{
@@ -353,7 +354,8 @@ BOOL secrets_store_trusted_domain_password(char* domain, smb_ucs2_t *uni_dom_nam
Routine to set the plaintext machine account password for a realm
the password is assumed to be a null terminated ascii string
************************************************************************/
-BOOL secrets_store_machine_password(char *pass)
+
+BOOL secrets_store_machine_password(const char *pass)
{
char *key;
BOOL ret;
@@ -394,6 +396,7 @@ BOOL trust_password_delete(const char *domain)
/************************************************************************
Routine to delete the password for trusted domain
************************************************************************/
+
BOOL trusted_domain_password_delete(const char *domain)
{
return secrets_delete(trustdom_keystr(domain));
@@ -602,7 +605,7 @@ BOOL secrets_named_mutex(const char *name, unsigned int timeout)
Unlock a named mutex.
*******************************************************************************/
-void secrets_named_mutex_release(char *name)
+void secrets_named_mutex_release(const char *name)
{
tdb_unlock_bystring(tdb, name);
DEBUG(10,("secrets_named_mutex: released mutex for %s\n", name ));
diff --git a/source3/printing/notify.c b/source3/printing/notify.c
index 003718ed72..a4111831d9 100644
--- a/source3/printing/notify.c
+++ b/source3/printing/notify.c
@@ -26,6 +26,7 @@ static TALLOC_CTX *send_ctx;
static struct notify_queue {
struct notify_queue *next, *prev;
+ char *printername;
void *buf;
size_t buflen;
} *notify_queue_head = NULL;
@@ -40,33 +41,25 @@ BOOL print_notify_messages_pending(void)
}
/*******************************************************************
- Actually send the batched messages.
+ Send the batched messages - on a per-printer basis.
*******************************************************************/
-void print_notify_send_messages(void)
+static void print_notify_send_messages_to_printer(const char *printer)
{
- TDB_CONTEXT *tdb;
char *buf;
- struct notify_queue *pq;
+ struct notify_queue *pq, *pq_next;
size_t msg_count = 0, offset = 0;
+ size_t num_pids = 0;
+ size_t i;
+ pid_t *pid_list = NULL;
- if (!print_notify_messages_pending())
- return;
-
- if (!send_ctx)
- return;
-
- tdb = conn_tdb_ctx();
-
- if (!tdb) {
- DEBUG(3, ("Failed to open connections database in send_spoolss_notify2_msg\n"));
- return;
- }
-
/* Count the space needed to send the messages. */
- for (pq = notify_queue_head; pq; pq = pq->next, msg_count++)
- offset += (pq->buflen + 4);
-
+ for (pq = notify_queue_head; pq; pq = pq->next) {
+ if (strequal(printer, pq->printername)) {
+ offset += (pq->buflen + 4);
+ msg_count++;
+ }
+ }
offset += 4; /* For count. */
buf = talloc(send_ctx, offset);
@@ -79,19 +72,50 @@ void print_notify_send_messages(void)
offset = 0;
SIVAL(buf,offset,msg_count);
offset += 4;
- for (pq = notify_queue_head; pq; pq = pq->next) {
- SIVAL(buf,offset,pq->buflen);
- offset += 4;
- memcpy(buf + offset, pq->buf, pq->buflen);
- offset += pq->buflen;
+ for (pq = notify_queue_head; pq; pq = pq_next) {
+ pq_next = pq->next;
+
+ if (strequal(printer, pq->printername)) {
+ SIVAL(buf,offset,pq->buflen);
+ offset += 4;
+ memcpy(buf + offset, pq->buf, pq->buflen);
+ offset += pq->buflen;
+
+ /* Remove from list. */
+ DLIST_REMOVE(notify_queue_head, pq);
+ }
}
- DEBUG(5, ("print_notify_send_messages: sending %d print notify message%s\n",
- msg_count, msg_count != 1 ? "s" : ""));
+ DEBUG(5, ("print_notify_send_messages_to_printer: sending %d print notify message%s to printer %s\n",
+ msg_count, msg_count != 1 ? "s" : "", printer));
+
+ /*
+ * Get the list of PID's to send to.
+ */
+
+ if (!print_notify_pid_list(printer, send_ctx, &num_pids, &pid_list))
+ return;
+
+ for (i = 0; i < num_pids; i++)
+ message_send_pid(pid_list[i], MSG_PRINTER_NOTIFY2, buf, offset, True);
+}
+
+/*******************************************************************
+ Actually send the batched messages.
+*******************************************************************/
+
+void print_notify_send_messages(void)
+{
+ if (!print_notify_messages_pending())
+ return;
+
+ if (!send_ctx)
+ return;
+
+ while (print_notify_messages_pending())
+ print_notify_send_messages_to_printer(notify_queue_head->printername);
- message_send_all(tdb, MSG_PRINTER_NOTIFY2, buf, offset, False, NULL);
talloc_destroy_pool(send_ctx);
- notify_queue_head = NULL;
}
/*******************************************************************
@@ -150,10 +174,15 @@ again:
if (!pnqueue)
goto fail;
+ pnqueue->printername = talloc_strdup(send_ctx, msg->printer);
+ if (!pnqueue->printername)
+ goto fail;
+
pnqueue->buf = buf;
pnqueue->buflen = buflen;
- DEBUG(5, ("send_spoolss_notify2_msg: appending message 0x%02x/0x%02x to notify_queue_head\n", msg->type, msg->field));
+ DEBUG(5, ("send_spoolss_notify2_msg: appending message 0x%02x/0x%02x for printer %s \
+to notify_queue_head\n", msg->type, msg->field, msg->printer));
/* Note we add to the end of the list to ensure
* the messages are sent in the order they were received. JRA.
diff --git a/source3/printing/printing.c b/source3/printing/printing.c
index 2121fb20a3..6d4cc213a7 100644
--- a/source3/printing/printing.c
+++ b/source3/printing/printing.c
@@ -1041,6 +1041,254 @@ static void print_queue_update(int snum)
}
/****************************************************************************
+ Fetch and clean the pid_t record list for all pids interested in notify
+ messages. data needs freeing on exit.
+****************************************************************************/
+
+#define NOTIFY_PID_LIST_KEY "NOTIFY_PID_LIST"
+
+static TDB_DATA get_printer_notify_pid_list(struct tdb_print_db *pdb)
+{
+ TDB_DATA data;
+ size_t i;
+
+ ZERO_STRUCT(data);
+
+ data = tdb_fetch_by_string( pdb->tdb, NOTIFY_PID_LIST_KEY );
+
+ if (!data.dptr) {
+ ZERO_STRUCT(data);
+ return data;
+ }
+
+ if (data.dsize % 8) {
+ DEBUG(0,("get_pid_list: Size of record for printer %s not a multiple of 8 !\n",
+ pdb->printer_name ));
+ tdb_delete_by_string(pdb->tdb, NOTIFY_PID_LIST_KEY );
+ ZERO_STRUCT(data);
+ return data;
+ }
+
+ /*
+ * Weed out all dead entries.
+ */
+
+ for( i = 0; i < data.dsize; ) {
+ pid_t pid = (pid_t)IVAL(data.dptr, i);
+
+ if (pid == sys_getpid())
+ continue;
+
+ /* Entry is dead if process doesn't exist or refcount is zero. */
+
+ if ((IVAL(data.dptr, i + 4) == 0) || !process_exists(pid)) {
+
+ /* Refcount == zero is a logic error and should never happen. */
+ if (IVAL(data.dptr, i + 4) == 0) {
+ DEBUG(0,("get_pid_list: Refcount == 0 for pid = %u printer %s !\n",
+ (unsigned int)pid, pdb->printer_name ));
+ }
+
+ if (data.dsize - i > 8)
+ memmove( &data.dptr[i], &data.dptr[i+8], data.dsize - i - 8);
+ data.dsize -= 8;
+ continue;
+ }
+
+ i += 8;
+ }
+
+ return data;
+}
+
+/****************************************************************************
+ Return a malloced list of pid_t's that are interested in getting update
+ messages on this print queue. Used in printing/notify to send the messages.
+****************************************************************************/
+
+BOOL print_notify_pid_list(const char *printername, TALLOC_CTX *mem_ctx, size_t *p_num_pids, pid_t **pp_pid_list)
+{
+ struct tdb_print_db *pdb;
+ TDB_DATA data;
+ BOOL ret = True;
+ size_t i, num_pids;
+ pid_t *pid_list;
+
+ *p_num_pids = 0;
+ *pp_pid_list = NULL;
+
+ pdb = get_print_db_byname(printername);
+ if (!pdb)
+ return False;
+
+ if (tdb_lock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ DEBUG(0,("print_notify_pid_list: Failed to lock printer %s database\n", printername));
+ release_print_db(pdb);
+ return False;
+ }
+
+ data = get_printer_notify_pid_list( pdb );
+
+ if (!data.dptr) {
+ ret = True;
+ goto done;
+ }
+
+ num_pids = data.dsize / 8;
+
+ if ((pid_list = (pid_t *)talloc(mem_ctx, sizeof(pid_t) * num_pids)) == NULL) {
+ ret = False;
+ goto done;
+ }
+
+ for( i = 0; i < data.dsize; i += 8) {
+ pid_t pid = (pid_t)IVAL(data.dptr, i);
+ pid_list[i] = pid;
+ }
+
+ *pp_pid_list = pid_list;
+ *p_num_pids = num_pids;
+
+ ret = True;
+
+ done:
+
+ tdb_unlock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY);
+ release_print_db(pdb);
+ SAFE_FREE(data.dptr);
+ return ret;
+}
+
+/****************************************************************************
+ Create/Update an entry in the print tdb that will allow us to send notify
+ updates only to interested smbd's.
+****************************************************************************/
+
+BOOL print_notify_register_pid(int snum)
+{
+ TDB_DATA data;
+ struct tdb_print_db *pdb;
+ const char *printername = lp_const_servicename(snum);
+ uint32 mypid = (uint32)sys_getpid();
+ BOOL ret = False;
+ size_t i;
+
+ pdb = get_print_db_byname(printername);
+ if (!pdb)
+ return False;
+
+ if (tdb_lock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ DEBUG(0,("print_notify_register_pid: Failed to lock printer %s\n", printername));
+ release_print_db(pdb);
+ return False;
+ }
+
+ data = get_printer_notify_pid_list( pdb );
+
+ /* Add ourselves and increase the refcount. */
+
+ for (i = 0; i < data.dsize; i += 8) {
+ if (IVAL(data.dptr,i) == mypid) {
+ uint32 new_refcount = IVAL(data.dptr, i+4) + 1;
+ SIVAL(data.dptr, i+4, new_refcount);
+ break;
+ }
+ }
+
+ if (i == data.dsize) {
+ /* We weren't in the list. Realloc. */
+ data.dptr = Realloc(data.dptr, data.dsize + 8);
+ if (!data.dptr) {
+ DEBUG(0,("print_notify_register_pid: Relloc fail for printer %s\n", printername));
+ goto done;
+ }
+ data.dsize += 8;
+ SIVAL(data.dptr,data.dsize - 8,mypid);
+ SIVAL(data.dptr,data.dsize - 4,1); /* Refcount. */
+ }
+
+ /* Store back the record. */
+ if (tdb_store_by_string(pdb->tdb, NOTIFY_PID_LIST_KEY, data, TDB_REPLACE) == -1) {
+ DEBUG(0,("print_notify_register_pid: Failed to update pid list for printer %s\n", printername));
+ goto done;
+ }
+
+ ret = True;
+
+ done:
+
+ tdb_unlock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY);
+ release_print_db(pdb);
+ SAFE_FREE(data.dptr);
+ return ret;
+}
+
+/****************************************************************************
+ Update an entry in the print tdb that will allow us to send notify
+ updates only to interested smbd's.
+****************************************************************************/
+
+BOOL print_notify_deregister_pid(int snum)
+{
+ TDB_DATA data;
+ struct tdb_print_db *pdb;
+ const char *printername = lp_const_servicename(snum);
+ uint32 mypid = (uint32)sys_getpid();
+ size_t i;
+ BOOL ret = False;
+
+ pdb = get_print_db_byname(printername);
+ if (!pdb)
+ return False;
+
+ if (tdb_lock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY, 10) == -1) {
+ DEBUG(0,("print_notify_register_pid: Failed to lock printer %s database\n", printername));
+ release_print_db(pdb);
+ return False;
+ }
+
+ data = get_printer_notify_pid_list( pdb );
+
+ /* Reduce refcount. Remove ourselves if zero. */
+
+ for (i = 0; i < data.dsize; ) {
+ if (IVAL(data.dptr,i) == mypid) {
+ uint32 refcount = IVAL(data.dptr, i+4);
+
+ refcount--;
+
+ if (refcount == 0) {
+ if (data.dsize - i > 8)
+ memmove( &data.dptr[i], &data.dptr[i+8], data.dsize - i - 8);
+ data.dsize -= 8;
+ continue;
+ }
+ SIVAL(data.dptr, i+4, refcount);
+ }
+
+ i += 8;
+ }
+
+ if (data.dsize == 0)
+ SAFE_FREE(data.dptr);
+
+ /* Store back the record. */
+ if (tdb_store_by_string(pdb->tdb, NOTIFY_PID_LIST_KEY, data, TDB_REPLACE) == -1) {
+ DEBUG(0,("print_notify_register_pid: Failed to update pid list for printer %s\n", printername));
+ goto done;
+ }
+
+ ret = True;
+
+ done:
+
+ tdb_unlock_bystring(pdb->tdb, NOTIFY_PID_LIST_KEY);
+ release_print_db(pdb);
+ SAFE_FREE(data.dptr);
+ return ret;
+}
+
+/****************************************************************************
Check if a jobid is valid. It is valid if it exists in the database.
****************************************************************************/
diff --git a/source3/rpc_client/cli_spoolss_notify.c b/source3/rpc_client/cli_spoolss_notify.c
index d07ace8e0c..2843aaece1 100644
--- a/source3/rpc_client/cli_spoolss_notify.c
+++ b/source3/rpc_client/cli_spoolss_notify.c
@@ -37,7 +37,7 @@
notifications are performed. */
WERROR cli_spoolss_reply_open_printer(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- char *printer, uint32 printerlocal, uint32 type,
+ const char *printer, uint32 printerlocal, uint32 type,
POLICY_HND *handle)
{
prs_struct qbuf, rbuf;
@@ -227,7 +227,7 @@ done:
WERROR cli_spoolss_rffpcnex(struct cli_state *cli, TALLOC_CTX *mem_ctx,
POLICY_HND *pol, uint32 flags, uint32 options,
- char *localmachine, uint32 printerlocal,
+ const char *localmachine, uint32 printerlocal,
SPOOL_NOTIFY_OPTION *option)
{
prs_struct qbuf, rbuf;
diff --git a/source3/rpc_parse/parse_spoolss.c b/source3/rpc_parse/parse_spoolss.c
index 15cd243f89..91322a8fae 100644
--- a/source3/rpc_parse/parse_spoolss.c
+++ b/source3/rpc_parse/parse_spoolss.c
@@ -7657,7 +7657,7 @@ BOOL make_spoolss_q_deleteprinterdataex(SPOOL_Q_DELETEPRINTERDATAEX *q_u,
********************************************************************/
BOOL make_spoolss_q_rffpcnex(SPOOL_Q_RFFPCNEX *q_u, POLICY_HND *handle,
- uint32 flags, uint32 options, char *localmachine,
+ uint32 flags, uint32 options, const char *localmachine,
uint32 printerlocal, SPOOL_NOTIFY_OPTION *option)
{
memcpy(&q_u->handle, handle, sizeof(POLICY_HND));
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index a5e464f73b..245df2003f 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -178,10 +178,18 @@ static void free_spool_notify_option(SPOOL_NOTIFY_OPTION **pp)
Disconnect from the client
****************************************************************************/
-static void srv_spoolss_replycloseprinter(POLICY_HND *handle)
+static void srv_spoolss_replycloseprinter(int snum, POLICY_HND *handle)
{
WERROR result;
+ /*
+ * Tell the specific printing tdb we no longer want messages for this printer
+ * by deregistering our PID.
+ */
+
+ if (!print_notify_deregister_pid(snum))
+ DEBUG(0,("print_notify_register_pid: Failed to register our pid for printer %s\n", lp_const_servicename(snum) ));
+
/* weird if the test succeds !!! */
if (smb_connections==0) {
DEBUG(0,("srv_spoolss_replycloseprinter:Trying to close non-existant notify backchannel !\n"));
@@ -219,7 +227,8 @@ static void free_printer_entry(void *ptr)
Printer_entry *Printer = (Printer_entry *)ptr;
if (Printer->notify.client_connected==True)
- srv_spoolss_replycloseprinter(&Printer->notify.client_hnd);
+ srv_spoolss_replycloseprinter(print_queue_snum(Printer->dev.handlename),
+ &Printer->notify.client_hnd);
Printer->notify.flags=0;
Printer->notify.options=0;
@@ -2305,7 +2314,7 @@ done:
Connect to the client machine.
**********************************************************/
-static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_machine)
+static BOOL spoolss_connect_to_client(struct cli_state *the_cli, const char *remote_machine)
{
extern pstring global_myname;
@@ -2396,7 +2405,7 @@ static BOOL spoolss_connect_to_client(struct cli_state *the_cli, char *remote_ma
Connect to the client.
****************************************************************************/
-static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle)
+static BOOL srv_spoolss_replyopenprinter(int snum, const char *printer, uint32 localprinter, uint32 type, POLICY_HND *handle)
{
WERROR result;
@@ -2418,6 +2427,14 @@ static BOOL srv_spoolss_replyopenprinter(char *printer, uint32 localprinter, uin
register_message_flags( True, FLAG_MSG_PRINTING );
}
+ /*
+ * Tell the specific printing tdb we want messages for this printer
+ * by registering our PID.
+ */
+
+ if (!print_notify_register_pid(snum))
+ DEBUG(0,("print_notify_register_pid: Failed to register our pid for printer %s\n", printer ));
+
smb_connections++;
result = cli_spoolss_reply_open_printer(&notify_cli, notify_cli.mem_ctx, printer, localprinter,
@@ -2448,6 +2465,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE
uint32 options = q_u->options;
UNISTR2 *localmachine = &q_u->localmachine;
uint32 printerlocal = q_u->printerlocal;
+ int snum;
SPOOL_NOTIFY_OPTION *option = q_u->option;
/* store the notify value in the printer struct */
@@ -2459,6 +2477,9 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE
return WERR_BADFID;
}
+ if (!get_printer_snum(p, handle, &snum))
+ return WERR_BADFID;
+
Printer->notify.flags=flags;
Printer->notify.options=options;
Printer->notify.printerlocal=printerlocal;
@@ -2473,7 +2494,7 @@ WERROR _spoolss_rffpcnex(pipes_struct *p, SPOOL_Q_RFFPCNEX *q_u, SPOOL_R_RFFPCNE
/* Connect to the client machine and send a ReplyOpenPrinter */
- if(!srv_spoolss_replyopenprinter(Printer->notify.localmachine,
+ if(!srv_spoolss_replyopenprinter(snum, Printer->notify.localmachine,
Printer->notify.printerlocal, 1,
&Printer->notify.client_hnd))
return WERR_SERVER_UNAVAILABLE;
@@ -5832,7 +5853,7 @@ WERROR _spoolss_setprinter(pipes_struct *p, SPOOL_Q_SETPRINTER *q_u, SPOOL_R_SET
WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u)
{
POLICY_HND *handle = &q_u->handle;
-
+ int snum;
Printer_entry *Printer= find_printer_index_by_hnd(p, handle);
if (!Printer) {
@@ -5840,8 +5861,11 @@ WERROR _spoolss_fcpn(pipes_struct *p, SPOOL_Q_FCPN *q_u, SPOOL_R_FCPN *r_u)
return WERR_BADFID;
}
+ if (!get_printer_snum(p, handle, &snum))
+ return WERR_BADFID;
+
if (Printer->notify.client_connected==True)
- srv_spoolss_replycloseprinter(&Printer->notify.client_hnd);
+ srv_spoolss_replycloseprinter(snum, &Printer->notify.client_hnd);
Printer->notify.flags=0;
Printer->notify.options=0;
diff --git a/source3/rpcclient/display_sec.c b/source3/rpcclient/display_sec.c
index 37043c5012..2a93c915f1 100644
--- a/source3/rpcclient/display_sec.c
+++ b/source3/rpcclient/display_sec.c
@@ -54,7 +54,7 @@ char *get_sec_mask_str(uint32 type)
if (type & DELETE_ACCESS)
fstrcat(typestr, "DELETE_ACCESS ");
- printf("\t\tSpecific bits: 0x%lx\n", type&SPECIFIC_RIGHTS_MASK);
+ printf("\t\tSpecific bits: 0x%lx\n", (unsigned long)type&SPECIFIC_RIGHTS_MASK);
return typestr;
}
diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c
index c57d23cb6f..2a6dca16a8 100644
--- a/source3/tdb/tdb.c
+++ b/source3/tdb/tdb.c
@@ -1442,7 +1442,8 @@ int tdb_store(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, int flag)
}
memcpy(p, key.dptr, key.dsize);
- memcpy(p+key.dsize, dbuf.dptr, dbuf.dsize);
+ if (dbuf.dsize)
+ memcpy(p+key.dsize, dbuf.dptr, dbuf.dsize);
/* now we're into insert / modify / replace of a record which
* we know could not be optimised by an in-place store (for
diff --git a/source3/tdb/tdbutil.c b/source3/tdb/tdbutil.c
index e7650033b8..ad97f45044 100644
--- a/source3/tdb/tdbutil.c
+++ b/source3/tdb/tdbutil.c
@@ -218,17 +218,14 @@ BOOL tdb_store_uint32(TDB_CONTEXT *tdb, char *keystr, uint32 value)
on failure.
****************************************************************************/
-int tdb_store_by_string(TDB_CONTEXT *tdb, char *keystr, void *buffer, int len)
+int tdb_store_by_string(TDB_CONTEXT *tdb, char *keystr, TDB_DATA data, int flags)
{
- TDB_DATA key, data;
+ TDB_DATA key;
key.dptr = keystr;
key.dsize = strlen(keystr) + 1;
- data.dptr = buffer;
- data.dsize = len;
-
- return tdb_store(tdb, key, data, TDB_REPLACE);
+ return tdb_store(tdb, key, data, flags);
}
/****************************************************************************
@@ -247,17 +244,17 @@ TDB_DATA tdb_fetch_by_string(TDB_CONTEXT *tdb, char *keystr)
}
/****************************************************************************
- Delete a buffer using a null terminated string key.
+ Delete an entry using a null terminated string key.
****************************************************************************/
int tdb_delete_by_string(TDB_CONTEXT *tdb, char *keystr)
{
- TDB_DATA key;
+ TDB_DATA key;
- key.dptr = keystr;
- key.dsize = strlen(keystr) + 1;
+ key.dptr = keystr;
+ key.dsize = strlen(keystr) + 1;
- return tdb_delete(tdb, key);
+ return tdb_delete(tdb, key);
}
/****************************************************************************
diff --git a/source3/utils/profiles.c b/source3/utils/profiles.c
index e7ffab9101..c7356a7323 100644
--- a/source3/utils/profiles.c
+++ b/source3/utils/profiles.c
@@ -514,7 +514,7 @@ void process_acl(ACL *acl, char *prefix)
}
}
-void usage(voi)
+void usage(void)
{
fprintf(stderr, "usage: profiles [-c <OLD-SID> -n <NEW-SID>] <profilefile>\n");
fprintf(stderr, "Version: %s\n", VERSION);
@@ -530,11 +530,9 @@ int main(int argc, char *argv[])
extern char *optarg;
extern int optind;
int opt;
- int i, fd, aces, start = 0;
- int process_sids = 0;
+ int fd, start = 0;
char *base;
struct stat sbuf;
- fstring sid_str;
REGF_HDR *regf_hdr;
HBIN_HDR *hbin_hdr;
NK_HDR *nk_hdr;
@@ -639,7 +637,7 @@ int main(int argc, char *argv[])
regf_hdr = (REGF_HDR *)base;
- if (verbose) fprintf(stdout, "Registry file size: %u\n", sbuf.st_size);
+ if (verbose) fprintf(stdout, "Registry file size: %u\n", (unsigned int)sbuf.st_size);
if (IVAL(&regf_hdr->REGF_ID, 0) != REG_REGF_ID) {
fprintf(stderr, "Incorrect Registry file (doesn't have header ID): %s\n", argv[optind]);
@@ -727,5 +725,5 @@ int main(int argc, char *argv[])
munmap(base, sbuf.st_size);
close(fd);
-
+ return 0;
}
diff --git a/source3/utils/smbcontrol.c b/source3/utils/smbcontrol.c
index 5401755376..7c292dd521 100644
--- a/source3/utils/smbcontrol.c
+++ b/source3/utils/smbcontrol.c
@@ -360,7 +360,9 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
break;
/* Send a notification message to a printer */
+ /* NB. None of these currently work due to changes in the printing notify mechanisms. */
+#if 0
case MSG_PRINTER_NOTIFY2: {
char *cmd;
@@ -462,6 +464,7 @@ static BOOL do_command(char *dest, char *msg_name, int iparams, char **params)
break;
}
+#endif
case MSG_SMB_FORCE_TDIS:
if (!strequal(dest, "smbd")) {