mirror of
https://github.com/samba-team/samba.git
synced 2025-12-21 20:23:50 +03:00
Add bcast_msg_flags to connection struct. Allows sender to filter when
sending broadcast messages. Also initial cut-down of printing notify messages (not yet finished). Jeremy.
This commit is contained in:
@@ -67,10 +67,6 @@
|
|||||||
#define MAX_OPEN_FILES 10000
|
#define MAX_OPEN_FILES 10000
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* the max number of simultanous connections to the server by all clients */
|
|
||||||
/* zero means no limit. */
|
|
||||||
#define MAXSTATUS 0
|
|
||||||
|
|
||||||
#define WORDMAX 0xFFFF
|
#define WORDMAX 0xFFFF
|
||||||
|
|
||||||
/* the maximum password length before we declare a likely attack */
|
/* the maximum password length before we declare a likely attack */
|
||||||
|
|||||||
@@ -59,4 +59,12 @@
|
|||||||
#define MSG_SMB_SAM_SYNC 3003
|
#define MSG_SMB_SAM_SYNC 3003
|
||||||
#define MSG_SMB_SAM_REPL 3004
|
#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
|
#endif
|
||||||
|
|||||||
@@ -718,6 +718,7 @@ struct connections_data {
|
|||||||
char addr[24];
|
char addr[24];
|
||||||
char machine[FSTRING_LEN];
|
char machine[FSTRING_LEN];
|
||||||
time_t start;
|
time_t start;
|
||||||
|
uint32 bcast_msg_flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -382,6 +382,7 @@ void message_deregister(int msg_type)
|
|||||||
|
|
||||||
struct msg_all {
|
struct msg_all {
|
||||||
int msg_type;
|
int msg_type;
|
||||||
|
uint32 msg_flag;
|
||||||
const void *buf;
|
const void *buf;
|
||||||
size_t len;
|
size_t len;
|
||||||
BOOL duplicates;
|
BOOL duplicates;
|
||||||
@@ -405,13 +406,20 @@ static int traverse_fn(TDB_CONTEXT *the_tdb, TDB_DATA kbuf, TDB_DATA dbuf, void
|
|||||||
if (crec.cnum != -1)
|
if (crec.cnum != -1)
|
||||||
return 0;
|
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.*/
|
* the msg has already been deleted from the messages.tdb.*/
|
||||||
|
|
||||||
if (!message_send_pid(crec.pid, msg_all->msg_type,
|
if (!message_send_pid(crec.pid, msg_all->msg_type,
|
||||||
msg_all->buf, msg_all->len,
|
msg_all->buf, msg_all->len,
|
||||||
msg_all->duplicates)) {
|
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) {
|
if (errno == ESRCH) {
|
||||||
DEBUG(2,("pid %u doesn't exist - deleting connections %d [%s]\n",
|
DEBUG(2,("pid %u doesn't exist - deleting connections %d [%s]\n",
|
||||||
(unsigned int)crec.pid, crec.cnum, crec.name));
|
(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;
|
struct msg_all msg_all;
|
||||||
|
|
||||||
msg_all.msg_type = msg_type;
|
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.buf = buf;
|
||||||
msg_all.len = len;
|
msg_all.len = len;
|
||||||
msg_all.duplicates = duplicates_allowed;
|
msg_all.duplicates = duplicates_allowed;
|
||||||
|
|||||||
@@ -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.
|
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;
|
TDB_DATA old_data, new_data;
|
||||||
BOOL ret;
|
BOOL ret;
|
||||||
@@ -483,7 +483,7 @@ static BOOL pjob_store(int snum, uint32 jobid, struct printjob *pjob)
|
|||||||
|
|
||||||
/* Send notify updates for what has changed */
|
/* 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(
|
pjob_store_notify(
|
||||||
snum, jobid, (struct printjob *)old_data.dptr,
|
snum, jobid, (struct printjob *)old_data.dptr,
|
||||||
(struct printjob *)new_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.user, q->fs_user);
|
||||||
fstrcpy(pj.queuename, lp_const_servicename(snum));
|
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->sysjob = queue[i].job;
|
||||||
pjob->status = queue[i].status;
|
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
|
/* 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;
|
return False;
|
||||||
|
|
||||||
fstrcpy(pjob->jobname, name);
|
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. */
|
/* Set the tdb entry to be deleting. */
|
||||||
|
|
||||||
pjob->status = LPQ_DELETING;
|
pjob->status = LPQ_DELETING;
|
||||||
pjob_store(snum, jobid, pjob);
|
pjob_store(snum, jobid, pjob, True);
|
||||||
|
|
||||||
if (pjob->spooled && pjob->sysjob != -1)
|
if (pjob->spooled && pjob->sysjob != -1)
|
||||||
result = (*(current_printif->job_delete))(snum, pjob);
|
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);
|
return_code = write(pjob->fd, buf, size);
|
||||||
if (return_code>0) {
|
if (return_code>0) {
|
||||||
pjob->size += size;
|
pjob->size += size;
|
||||||
pjob_store(snum, jobid, pjob);
|
pjob_store(snum, jobid, pjob, True);
|
||||||
}
|
}
|
||||||
return return_code;
|
return return_code;
|
||||||
}
|
}
|
||||||
@@ -1265,6 +1265,7 @@ int print_queue_length(int snum, print_status_struct *pstatus)
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 /* JRATEST */
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
Determine the number of jobs in all queues. This is very expensive. Don't
|
Determine the number of jobs in all queues. This is very expensive. Don't
|
||||||
call ! JRA.
|
call ! JRA.
|
||||||
@@ -1298,6 +1299,7 @@ static int get_total_jobs(void)
|
|||||||
}
|
}
|
||||||
return total_jobs;
|
return total_jobs;
|
||||||
}
|
}
|
||||||
|
#endif /* JRATEST */
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
Start spooling a job - return the jobid.
|
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;
|
return (uint32)-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 /* JRATEST */
|
||||||
/* Insure the maximum print jobs in the system is not violated */
|
/* Insure the maximum print jobs in the system is not violated */
|
||||||
if (lp_totalprintjobs() && get_total_jobs() > lp_totalprintjobs()) {
|
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",
|
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;
|
errno = ENOSPC;
|
||||||
return (uint32)-1;
|
return (uint32)-1;
|
||||||
}
|
}
|
||||||
|
#endif /* JRATEST */
|
||||||
|
|
||||||
/* create the database entry */
|
/* create the database entry */
|
||||||
ZERO_STRUCT(pjob);
|
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))
|
if (!print_job_exists(snum, jobid))
|
||||||
break;
|
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",
|
DEBUG(3, ("print_job_start: either jobid (%d)==next_jobid(%d) or pjob_store failed.\n",
|
||||||
jobid, next_jobid ));
|
jobid, next_jobid ));
|
||||||
jobid = -1;
|
jobid = -1;
|
||||||
@@ -1420,6 +1424,9 @@ uint32 print_job_start(struct current_user *user, int snum, char *jobname)
|
|||||||
goto fail;
|
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 */
|
/* we have a job entry - now create the spool file */
|
||||||
slprintf(pjob.filename, sizeof(pjob.filename)-1, "%s/%s%.8u.XXXXXX",
|
slprintf(pjob.filename, sizeof(pjob.filename)-1, "%s/%s%.8u.XXXXXX",
|
||||||
path, PRINT_SPOOL_PREFIX, (unsigned int)jobid);
|
path, PRINT_SPOOL_PREFIX, (unsigned int)jobid);
|
||||||
@@ -1438,9 +1445,8 @@ to open spool file %s.\n", pjob.filename));
|
|||||||
goto fail;
|
goto fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
pjob_store(snum, jobid, &pjob);
|
pjob_store(snum, jobid, &pjob, False);
|
||||||
|
|
||||||
tdb_unlock_bystring(pdb->tdb, "INFO/nextjob");
|
|
||||||
release_print_db(pdb);
|
release_print_db(pdb);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -1481,7 +1487,7 @@ void print_job_endpage(int snum, uint32 jobid)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
pjob->page_count++;
|
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->spooled = True;
|
||||||
pjob->status = LPQ_QUEUED;
|
pjob->status = LPQ_QUEUED;
|
||||||
pjob_store(snum, jobid, pjob);
|
pjob_store(snum, jobid, pjob, True);
|
||||||
|
|
||||||
/* make sure the database is up to date */
|
/* make sure the database is up to date */
|
||||||
if (print_cache_expired(snum))
|
if (print_cache_expired(snum))
|
||||||
|
|||||||
@@ -28,10 +28,9 @@ static TDB_CONTEXT *tdb;
|
|||||||
|
|
||||||
TDB_CONTEXT *conn_tdb_ctx(void)
|
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,
|
tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
|
||||||
O_RDWR | O_CREAT, 0644);
|
O_RDWR | O_CREAT, 0644);
|
||||||
}
|
|
||||||
|
|
||||||
return tdb;
|
return tdb;
|
||||||
}
|
}
|
||||||
@@ -45,7 +44,8 @@ BOOL yield_connection(connection_struct *conn,char *name)
|
|||||||
struct connections_key key;
|
struct connections_key key;
|
||||||
TDB_DATA kbuf;
|
TDB_DATA kbuf;
|
||||||
|
|
||||||
if (!tdb) return False;
|
if (!tdb)
|
||||||
|
return False;
|
||||||
|
|
||||||
DEBUG(3,("Yielding connection to %s\n",name));
|
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.
|
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_key key;
|
||||||
struct connections_data crec;
|
struct connections_data crec;
|
||||||
TDB_DATA kbuf, dbuf;
|
TDB_DATA kbuf, dbuf;
|
||||||
|
|
||||||
if (!tdb) {
|
if (!tdb)
|
||||||
tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
|
tdb = tdb_open_log(lock_path("connections.tdb"), 0, TDB_CLEAR_IF_FIRST|TDB_DEFAULT,
|
||||||
O_RDWR | O_CREAT, 0644);
|
O_RDWR | O_CREAT, 0644);
|
||||||
}
|
|
||||||
if (!tdb)
|
if (!tdb)
|
||||||
return False;
|
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);
|
lp_servicename(SNUM(conn)),sizeof(crec.name)-1);
|
||||||
}
|
}
|
||||||
crec.start = time(NULL);
|
crec.start = time(NULL);
|
||||||
|
crec.bcast_msg_flags = msg_flags;
|
||||||
|
|
||||||
StrnCpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)-1);
|
StrnCpy(crec.machine,get_remote_machine_name(),sizeof(crec.machine)-1);
|
||||||
StrnCpy(crec.addr,conn?conn->client_address:client_addr(),sizeof(crec.addr)-1);
|
StrnCpy(crec.addr,conn?conn->client_address:client_addr(),sizeof(crec.addr)-1);
|
||||||
|
|||||||
@@ -113,7 +113,7 @@ int reply_special(char *inbuf,char *outbuf)
|
|||||||
reload_services(True);
|
reload_services(True);
|
||||||
reopen_logs();
|
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;
|
already_got_session = True;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -858,7 +858,7 @@ static void usage(char *pname)
|
|||||||
register_dmalloc_msgs();
|
register_dmalloc_msgs();
|
||||||
|
|
||||||
/* Setup the main smbd so that we can get messages. */
|
/* 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
|
DO NOT ENABLE THIS TILL YOU COPE WITH KILLING THESE TASKS AND INETD
|
||||||
|
|||||||
@@ -578,7 +578,7 @@ static connection_struct *make_connection_snum(int snum, user_struct *vuser,
|
|||||||
if (!claim_connection(conn,
|
if (!claim_connection(conn,
|
||||||
lp_servicename(SNUM(conn)),
|
lp_servicename(SNUM(conn)),
|
||||||
lp_max_connections(SNUM(conn)),
|
lp_max_connections(SNUM(conn)),
|
||||||
False)) {
|
False,0)) {
|
||||||
DEBUG(1,("too many connections - rejected\n"));
|
DEBUG(1,("too many connections - rejected\n"));
|
||||||
conn_free(conn);
|
conn_free(conn);
|
||||||
*status = NT_STATUS_INSUFFICIENT_RESOURCES;
|
*status = NT_STATUS_INSUFFICIENT_RESOURCES;
|
||||||
|
|||||||
Reference in New Issue
Block a user