summaryrefslogtreecommitdiff
path: root/source3/lib/messages.c
diff options
context:
space:
mode:
authorMartin Pool <mbp@samba.org>2002-03-20 06:57:03 +0000
committerMartin Pool <mbp@samba.org>2002-03-20 06:57:03 +0000
commit75722fa183d1678bc7360bc79f9ac8cf17cd62e3 (patch)
treee0d46b5c43e731ddba89fb1e632ccef081e100ad /source3/lib/messages.c
parenta17b5158f1fad6702187afcd1c39684eb4d2ed34 (diff)
downloadsamba-75722fa183d1678bc7360bc79f9ac8cf17cd62e3.tar.gz
samba-75722fa183d1678bc7360bc79f9ac8cf17cd62e3.tar.bz2
samba-75722fa183d1678bc7360bc79f9ac8cf17cd62e3.zip
Add assertions that kill() is never accidentally passed a non-positive
pid. This follows a bug in rsync where it would accidentally kill(-1), removing all the user's processes. I can't see any way this would directly happen in Samba, but having the assertions seems beneficial. http://cvs.samba.org/cgi-bin/cvsweb/rsync/util.c.diff?r1=1.108&r2=1.109&f=h (This used to be commit 098905bea29c7d5b886809d431294ddf2fc1e152)
Diffstat (limited to 'source3/lib/messages.c')
-rw-r--r--source3/lib/messages.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/source3/lib/messages.c b/source3/lib/messages.c
index 642caafac4..b745cbaf8b 100644
--- a/source3/lib/messages.c
+++ b/source3/lib/messages.c
@@ -144,6 +144,9 @@ static TDB_DATA message_key_pid(pid_t pid)
static BOOL message_notify(pid_t pid)
{
+ /* Doing kill with a non-positive pid causes messages to be
+ * sent to places we don't want. */
+ SMB_ASSERT(pid > 0);
if (kill(pid, SIGUSR1) == -1) {
if (errno == ESRCH) {
DEBUG(2,("pid %d doesn't exist - deleting messages record\n", (int)pid));
@@ -174,6 +177,10 @@ BOOL message_send_pid(pid_t pid, int msg_type, const void *buf, size_t len,
rec.src = sys_getpid();
rec.len = len;
+ /* Doing kill with a non-positive pid causes messages to be
+ * sent to places we don't want. */
+ SMB_ASSERT(pid > 0);
+
kbuf = message_key_pid(pid);
/* lock the record for the destination */