1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-06 13:09:50 +00:00

Handle the case where we truss an SUGID program -- in particular, we need

to wake up any processes waiting via PIOCWAIT on process exit, and truss
needs to be more aware that a process may actually disappear while it's
waiting.

Reviewed by:	Paul Saab <ps@yahoo-inc.com>
This commit is contained in:
Sean Eric Fagan 2000-01-10 04:09:05 +00:00
parent 9090c22ce7
commit 893618352c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=55707
4 changed files with 20 additions and 4 deletions

View File

@ -149,6 +149,7 @@ exit1(p, rv)
vmsizmon();
#endif
STOPEVENT(p, S_EXIT, rv);
wakeup(&p->p_stype); /* Wakeup anyone in procfs' PIOCWAIT */
/*
* Check if any loadable modules need anything done at process exit.

View File

@ -932,6 +932,6 @@ setsugid(p)
struct proc *p;
{
p->p_flag |= P_SUGID;
if (p->p_pfsflags & PF_ISUGID)
if (!(p->p_pfsflags & PF_ISUGID))
p->p_stops = 0;
}

View File

@ -202,6 +202,9 @@ main(int ac, char **av) {
Procfd = start_tracing(pid, S_EXEC | S_SCE | S_SCX | S_CORE | S_EXIT |
(nosigs ? 0 : S_SIG));
if (Procfd == -1)
return 0;
pfs.why = 0;
funcs = set_etype();
@ -251,8 +254,12 @@ main(int ac, char **av) {
break;
}
}
if (ioctl(Procfd, PIOCCONT, val) == -1)
warn("PIOCCONT");
if (ioctl(Procfd, PIOCCONT, val) == -1) {
if (kill(pid, 0) == -1 && errno == ESRCH)
break;
else
warn("PIOCCONT");
}
} while (pfs.why != S_EXIT);
fflush(outfile);
if (sigexit) {

View File

@ -133,8 +133,16 @@ start_tracing(int pid, int flags) {
sprintf(buf, "/proc/%d/mem", pid);
fd = open(buf, O_RDWR);
if (fd == -1)
if (fd == -1) {
/*
* The process may have run away before we could start -- this
* happens with SUGID programs. So we need to see if it still
* exists before we complain bitterly.
*/
if (kill(pid, 0) == -1)
return -1;
err(8, "cannot open %s", buf);
}
if (ioctl(fd, PIOCSTATUS, &tmp) == -1) {
err(10, "cannot get procfs status struct");