diff options
-rw-r--r-- | source3/include/local.h | 4 | ||||
-rw-r--r-- | source3/include/messages.h | 8 | ||||
-rw-r--r-- | source3/include/smb.h | 1 | ||||
-rw-r--r-- | source3/lib/messages.c | 25 | ||||
-rw-r--r-- | source3/printing/printing.c | 30 | ||||
-rw-r--r-- | source3/smbd/connection.c | 13 | ||||
-rw-r--r-- | source3/smbd/reply.c | 2 | ||||
-rw-r--r-- | source3/smbd/server.c | 2 | ||||
-rw-r--r-- | source3/smbd/service.c | 2 |
9 files changed, 59 insertions, 28 deletions
diff --git a/source3/include/local.h b/source3/include/local.h index 15231e92ee..5096e13fc3 100644 --- a/source3/include/local.h +++ b/source3/include/local.h @@ -67,10 +67,6 @@ #define MAX_OPEN_FILES 10000 #endif -/* the max number of simultanous connections to the server by all clients */ -/* zero means no limit. */ -#define MAXSTATUS 0 - #define WORDMAX 0xFFFF /* the maximum password length before we declare a likely attack */ diff --git a/source3/include/messages.h b/source3/include/messages.h index 58e606b40f..0e995039ff 100644 --- a/source3/include/messages.h +++ b/source3/include/messages.h @@ -59,4 +59,12 @@ #define MSG_SMB_SAM_SYNC 3003 #define MSG_SMB_SAM_REPL 3004 +/* Flags to classify messages - used in message_send_all() */ +/* Sender will filter by flag. */ + +#define FLAG_MSG_GENERAL 0x0001 +#define FLAG_MSG_SMBD 0x0002 +#define FLAG_MSG_NMBD 0x0004 +#define FLAG_MSG_PRINTING 0x0008 + #endif diff --git a/source3/include/smb.h b/source3/include/smb.h index f2eb37096c..909c1a57ec 100644 --- a/source3/include/smb.h +++ b/source3/include/smb.h @@ -718,6 +718,7 @@ struct connections_data { char addr[24]; char machine[FSTRING_LEN]; time_t start; + uint32 bcast_msg_flags; }; diff --git a/source3/lib/messages.c b/source3/lib/messages.c index e6d2de4a58..21470dff5c 100644 --- a/source3/lib/messages.c +++ b/source3/lib/messages.c @@ -382,10 +382,11 @@ void message_deregister(int msg_type) struct msg_all { int msg_type; + uint32 msg_flag; const void *buf; size_t len; BOOL duplicates; - int n_sent; + int n_sent; }; /**************************************************************************** @@ -405,13 +406,20 @@ static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void if (crec.cnum != -1) return 0; - /* if the msg send fails because the pid was not found (i.e. smbd died), + /* Don't send if the receiver hasn't registered an interest. */ + + if(!(crec.bcast_msg_flags & msg_all->msg_flag)) + return 0; + + /* If the msg send fails because the pid was not found (i.e. smbd died), * the msg has already been deleted from the messages.tdb.*/ + if (!message_send_pid(crec.pid, msg_all->msg_type, msg_all->buf, msg_all->len, msg_all->duplicates)) { - /* if the pid was not found delete the entry from connections.tdb */ + /* If the pid was not found delete the entry from connections.tdb */ + if (errno == ESRCH) { DEBUG(2,("pid %u doesn't exist - deleting connections %d [%s]\n", (unsigned int)crec.pid, crec.cnum, crec.name)); @@ -442,6 +450,17 @@ BOOL message_send_all(TDB_CONTEXT *conn_tdb, int msg_type, struct msg_all msg_all; msg_all.msg_type = msg_type; + if (msg_type < 1000) + msg_all.msg_flag = FLAG_MSG_GENERAL; + else if (msg_type > 1000 && msg_type < 2000) + msg_all.msg_flag = FLAG_MSG_NMBD; + else if (msg_type > 2000 && msg_type < 3000) + msg_all.msg_flag = FLAG_MSG_PRINTING; + else if (msg_type > 3000 && msg_type < 4000) + msg_all.msg_flag = FLAG_MSG_SMBD; + else + return False; + msg_all.buf = buf; msg_all.len = len; msg_all.duplicates = duplicates_allowed; diff --git a/source3/printing/printing.c b/source3/printing/printing.c index f3ee1a0d63..0dacfe820c 100644 --- a/source3/printing/printing.c +++ b/source3/printing/printing.c @@ -460,7 +460,7 @@ static void pjob_store_notify(int snum, uint32 jobid, struct printjob *old_data, Store a job structure back to the database. ****************************************************************************/ -static BOOL pjob_store(int snum, uint32 jobid, struct printjob *pjob) +static BOOL pjob_store(int snum, uint32 jobid, struct printjob *pjob, BOOL donotify) { TDB_DATA old_data, new_data; BOOL ret; @@ -483,7 +483,7 @@ static BOOL pjob_store(int snum, uint32 jobid, struct printjob *pjob) /* Send notify updates for what has changed */ - if (ret && (old_data.dsize == 0 || old_data.dsize == sizeof(*pjob))) { + if (donotify && ret && (old_data.dsize == 0 || old_data.dsize == sizeof(*pjob))) { pjob_store_notify( snum, jobid, (struct printjob *)old_data.dptr, (struct printjob *)new_data.dptr); @@ -581,7 +581,7 @@ static void print_unix_job(int snum, print_queue_struct *q) fstrcpy(pj.user, q->fs_user); fstrcpy(pj.queuename, lp_const_servicename(snum)); - pjob_store(snum, jobid, &pj); + pjob_store(snum, jobid, &pj, True); } @@ -868,7 +868,7 @@ static void print_queue_update(int snum) pjob->sysjob = queue[i].job; pjob->status = queue[i].status; - pjob_store(snum, jobid, pjob); + pjob_store(snum, jobid, pjob, True); } /* now delete any queued entries that don't appear in the @@ -977,7 +977,7 @@ BOOL print_job_set_name(int snum, uint32 jobid, char *name) return False; fstrcpy(pjob->jobname, name); - return pjob_store(snum, jobid, pjob); + return pjob_store(snum, jobid, pjob, True); } /**************************************************************************** @@ -1009,7 +1009,7 @@ static BOOL print_job_delete1(int snum, uint32 jobid) /* Set the tdb entry to be deleting. */ pjob->status = LPQ_DELETING; - pjob_store(snum, jobid, pjob); + pjob_store(snum, jobid, pjob, True); if (pjob->spooled && pjob->sysjob != -1) result = (*(current_printif->job_delete))(snum, pjob); @@ -1172,7 +1172,7 @@ int print_job_write(int snum, uint32 jobid, const char *buf, int size) return_code = write(pjob->fd, buf, size); if (return_code>0) { pjob->size += size; - pjob_store(snum, jobid, pjob); + pjob_store(snum, jobid, pjob, True); } return return_code; } @@ -1265,6 +1265,7 @@ int print_queue_length(int snum, print_status_struct *pstatus) return len; } +#if 0 /* JRATEST */ /**************************************************************************** Determine the number of jobs in all queues. This is very expensive. Don't call ! JRA. @@ -1298,6 +1299,7 @@ static int get_total_jobs(void) } return total_jobs; } +#endif /* JRATEST */ /*************************************************************************** Start spooling a job - return the jobid. @@ -1362,6 +1364,7 @@ uint32 print_job_start(struct current_user *user, int snum, char *jobname) return (uint32)-1; } +#if 0 /* JRATEST */ /* Insure the maximum print jobs in the system is not violated */ if (lp_totalprintjobs() && get_total_jobs() > lp_totalprintjobs()) { DEBUG(3, ("print_job_start: number of jobs (%d) larger than max printjobs per system (%d).\n", @@ -1370,6 +1373,7 @@ uint32 print_job_start(struct current_user *user, int snum, char *jobname) errno = ENOSPC; return (uint32)-1; } +#endif /* JRATEST */ /* create the database entry */ ZERO_STRUCT(pjob); @@ -1407,7 +1411,7 @@ uint32 print_job_start(struct current_user *user, int snum, char *jobname) if (!print_job_exists(snum, jobid)) break; } - if (jobid == next_jobid || !pjob_store(snum, jobid, &pjob)) { + if (jobid == next_jobid || !pjob_store(snum, jobid, &pjob, False)) { DEBUG(3, ("print_job_start: either jobid (%d)==next_jobid(%d) or pjob_store failed.\n", jobid, next_jobid )); jobid = -1; @@ -1420,6 +1424,9 @@ uint32 print_job_start(struct current_user *user, int snum, char *jobname) goto fail; } + /* We've finished with the INFO/nextjob lock. */ + tdb_unlock_bystring(pdb->tdb, "INFO/nextjob"); + /* we have a job entry - now create the spool file */ slprintf(pjob.filename, sizeof(pjob.filename)-1, "%s/%s%.8u.XXXXXX", path, PRINT_SPOOL_PREFIX, (unsigned int)jobid); @@ -1438,9 +1445,8 @@ to open spool file %s.\n", pjob.filename)); goto fail; } - pjob_store(snum, jobid, &pjob); + pjob_store(snum, jobid, &pjob, False); - tdb_unlock_bystring(pdb->tdb, "INFO/nextjob"); release_print_db(pdb); /* @@ -1481,7 +1487,7 @@ void print_job_endpage(int snum, uint32 jobid) return; pjob->page_count++; - pjob_store(snum, jobid, pjob); + pjob_store(snum, jobid, pjob, True); } /**************************************************************************** @@ -1539,7 +1545,7 @@ BOOL print_job_end(int snum, uint32 jobid, BOOL normal_close) pjob->spooled = True; pjob->status = LPQ_QUEUED; - pjob_store(snum, jobid, pjob); + pjob_store(snum, jobid, pjob, True); /* make sure the database is up to date */ if (print_cache_expired(snum)) diff --git a/source3/smbd/connection.c b/source3/smbd/connection.c index 5609c2963d..bc897a95cb 100644 --- a/source3/smbd/connection.c +++ b/source3/smbd/connection.c @@ -28,10 +28,9 @@ static TDB_CONTEXT *tdb; TDB_CONTEXT *conn_tdb_ctx(void) { - if (!tdb) { + if (!tdb) tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, O_RDWR | O_CREAT, 0644); - } return tdb; } @@ -45,7 +44,8 @@ BOOL yield_connection(connection_struct *conn,char *name) struct connections_key key; TDB_DATA kbuf; - if (!tdb) return False; + if (!tdb) + return False; DEBUG(3,("Yielding connection to %s\n",name)); @@ -111,16 +111,16 @@ static int count_fn( TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void *u Claim an entry in the connections database. ****************************************************************************/ -BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOOL Clear) +BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOOL Clear, uint32 msg_flags) { struct connections_key key; struct connections_data crec; TDB_DATA kbuf, dbuf; - if (!tdb) { + if (!tdb) tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT, O_RDWR | O_CREAT, 0644); - } + if (!tdb) return False; @@ -176,6 +176,7 @@ BOOL claim_connection(connection_struct *conn,char *name,int max_connections,BOO lp_servicename(SNUM(conn)),sizeof(crec.name)-1); } crec.start = time(NULL); + crec.bcast_msg_flags = msg_flags; StrnCpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)-1); StrnCpy(crec.addr,conn?conn->client_address:client_addr(),sizeof(crec.addr)-1); diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 010f0e47d3..263626dcc1 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -113,7 +113,7 @@ int reply_special(char *inbuf,char *outbuf) reload_services(True); reopen_logs(); - claim_connection(NULL,"",MAXSTATUS,True); + claim_connection(NULL,"",0,True,FLAG_MSG_GENERAL|FLAG_MSG_SMBD|FLAG_MSG_PRINTING); already_got_session = True; break; diff --git a/source3/smbd/server.c b/source3/smbd/server.c index c748a87da2..8082c22cff 100644 --- a/source3/smbd/server.c +++ b/source3/smbd/server.c @@ -858,7 +858,7 @@ static void usage(char *pname) register_dmalloc_msgs(); /* Setup the main smbd so that we can get messages. */ - claim_connection(NULL,"",0,True); + claim_connection(NULL,"",0,True,FLAG_MSG_GENERAL|FLAG_MSG_SMBD); /* DO NOT ENABLE THIS TILL YOU COPE WITH KILLING THESE TASKS AND INETD diff --git a/source3/smbd/service.c b/source3/smbd/service.c index d475451e6b..a8a590da80 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -578,7 +578,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser, if (!claim_connection(conn, lp_servicename(SNUM(conn)), lp_max_connections(SNUM(conn)), - False)) { + False,0)) { DEBUG(1,("too many connections - rejected\n")); conn_free(conn); *status = NT_STATUS_INSUFFICIENT_RESOURCES; |