Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern Ensure that the pgid arg to TIOCSPGRP is in the cur...



details:   https://anonhg.NetBSD.org/src/rev/df8181f8c03e
branches:  trunk
changeset: 544152:df8181f8c03e
user:      dsl <dsl%NetBSD.org@localhost>
date:      Thu Mar 13 10:20:06 2003 +0000

description:
Ensure that the pgid arg to TIOCSPGRP is in the current session.
Correctly treat a +ve value as a pgid and a -ve one as a pid.

diffstat:

 sys/kern/subr_log.c |  24 ++++++++++++++++--------
 1 files changed, 16 insertions(+), 8 deletions(-)

diffs (66 lines):

diff -r 6cdffdd77dd5 -r df8181f8c03e sys/kern/subr_log.c
--- a/sys/kern/subr_log.c       Thu Mar 13 10:18:35 2003 +0000
+++ b/sys/kern/subr_log.c       Thu Mar 13 10:20:06 2003 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_log.c,v 1.25 2002/11/26 18:44:34 christos Exp $   */
+/*     $NetBSD: subr_log.c,v 1.26 2003/03/13 10:20:06 dsl Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1993
@@ -40,7 +40,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_log.c,v 1.25 2002/11/26 18:44:34 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_log.c,v 1.26 2003/03/13 10:20:06 dsl Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -128,7 +128,7 @@
        if (log_open)
                return (EBUSY);
        log_open = 1;
-       logsoftc.sc_pgid = p->p_pid;            /* signal process only */
+       logsoftc.sc_pgid = -p->p_pid;           /* signal process only */
        /*
         * The message buffer is initialized during system configuration.
         * If it's been clobbered, note that and return an error.  (This
@@ -287,10 +287,10 @@
                return;
        selnotify(&logsoftc.sc_selp, 0);
        if (logsoftc.sc_state & LOG_ASYNC) {
-               if (logsoftc.sc_pgid < 0)
-                       gsignal(-logsoftc.sc_pgid, SIGIO); 
-               else if (logsoftc.sc_pgid > 0 &&
-                   (p = pfind(logsoftc.sc_pgid)) != NULL)
+               if (logsoftc.sc_pgid > 0)
+                       gsignal(logsoftc.sc_pgid, SIGIO); 
+               else if (logsoftc.sc_pgid < 0 &&
+                   (p = pfind(-logsoftc.sc_pgid)) != NULL)
                        psignal(p, SIGIO);
        }
        if (logsoftc.sc_state & LOG_RDWAIT) {
@@ -310,6 +310,8 @@
 {
        long l;
        int s;
+       pid_t pgid;
+       int error;
 
        switch (com) {
 
@@ -334,7 +336,13 @@
                break;
 
        case TIOCSPGRP:
-               logsoftc.sc_pgid = *(int *)data;
+               pgid = *(int *)data;
+               if (pgid != 0) {
+                       error = pgid_in_session(p, pgid);
+                       if (error)
+                               return error;
+               }
+               logsoftc.sc_pgid = pgid;
                break;
 
        case TIOCGPGRP:



Home | Main Index | Thread Index | Old Index