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
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));
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 */
BOOL process_exists(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);
return(kill(pid,0) == 0 || errno != ESRCH);
}
void kill_async_dns_child(void)
{
- if(child_pid != 0 && child_pid != -1)
- kill(child_pid, SIGTERM);
+ if (child_pid > 0) {
+ kill(child_pid, SIGTERM);
+ }
}
/***************************************************************************
if (geteuid() != 0) return;
- if (pid == 0) return;
+ if (pid <= 0) return;
kill(pid, SIGTERM);
}
if (geteuid() != 0) return;
- if (pid == 0) return;
+ if (pid <= 0) return;
kill(pid, SIGTERM);
}