Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern Maintain a short list of the actual descriptors tha...
details: https://anonhg.NetBSD.org/src/rev/dbd6967730e3
branches: trunk
changeset: 526756:dbd6967730e3
user: atatat <atatat%NetBSD.org@localhost>
date: Thu May 09 17:57:07 2002 +0000
description:
Maintain a short list of the actual descriptors that were closed and
log that intead of being ambiguous about which of 0, 1, and/or 2 it
was that was closed.
diffstat:
sys/kern/kern_descrip.c | 31 ++++++++++++++++++-------------
1 files changed, 18 insertions(+), 13 deletions(-)
diffs (70 lines):
diff -r e44986a67726 -r dbd6967730e3 sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c Thu May 09 17:52:03 2002 +0000
+++ b/sys/kern/kern_descrip.c Thu May 09 17:57:07 2002 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_descrip.c,v 1.91 2002/04/28 22:35:19 enami Exp $ */
+/* $NetBSD: kern_descrip.c,v 1.92 2002/05/09 17:57:07 atatat Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.91 2002/04/28 22:35:19 enami Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.92 2002/05/09 17:57:07 atatat Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -1381,6 +1381,7 @@
* descriptor referencing /dev/null for each of stdin, stdout, and
* stderr that is not already open.
*/
+#define CHECK_UPTO 3
int
fdcheckstd(p)
struct proc *p;
@@ -1391,22 +1392,17 @@
struct file *devnullfp;
struct proc *pp;
register_t retval;
- int fd, i, error, flags = FREAD|FWRITE, devnull = -1, logged = 0;
+ int fd, i, error, flags = FREAD|FWRITE, devnull = -1;
+ char closed[CHECK_UPTO * 3 + 1], which[3 + 1];
+ closed[0] = '\0';
if ((fdp = p->p_fd) == NULL)
return (0);
- for (i = 0; i < 3; i++) {
+ for (i = 0; i < CHECK_UPTO; i++) {
if (fdp->fd_ofiles[i] != NULL)
continue;
- if (!logged) {
- pp = p->p_pptr;
- log(LOG_WARNING, "set{u,g}id pid %d (%s) "
- "was invoked by uid %d ppid %d (%s) "
- "with fd 0, 1, or 2 closed\n",
- p->p_pid, p->p_comm, pp->p_ucred->cr_uid,
- pp->p_pid, pp->p_comm);
- logged++;
- }
+ snprintf(which, sizeof(which), ",%d", i);
+ strcat(closed, which);
if (devnull < 0) {
if ((error = falloc(p, &fp, &fd)) != 0)
return (error);
@@ -1443,5 +1439,14 @@
return (error);
}
}
+ if (closed[0] != '\0') {
+ pp = p->p_pptr;
+ log(LOG_WARNING, "set{u,g}id pid %d (%s) "
+ "was invoked by uid %d ppid %d (%s) "
+ "with fd %s closed\n",
+ p->p_pid, p->p_comm, pp->p_ucred->cr_uid,
+ pp->p_pid, pp->p_comm, &closed[1]);
+ }
return (0);
}
+#undef CHECK_UPTO
Home |
Main Index |
Thread Index |
Old Index