NetBSD Problem Report #732

From gnats  Sat Jan 14 21:25:56 1995
Received: from pain.lcs.mit.edu (pain.lcs.mit.edu [128.52.46.239]) by sun-lamp.cs.berkeley.edu (8.6.9/8.6.9) with ESMTP id VAA07611 for <gnats-bugs@sun-lamp.cs.berkeley.edu>; Sat, 14 Jan 1995 21:25:53 -0800
Message-Id: <199501150523.QAA00367@splode.mame.mu.OZ.AU>
Date: Sun, 15 Jan 1995 16:23:51 +1100
From: mrg@eterna.com.au
Reply-To: mrg@eterna.com.au
To: gnats-bugs@NetBSD.ORG
Subject: TIOCCONS should work if `I' own /dev/console
X-Send-Pr-Version: 3.2

>Number:         732
>Category:       kern
>Synopsis:       TIOCCONS should work if `I' own /dev/console
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          closed
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sat Jan 14 21:35:03 +0000 1995
>Closed-Date:    Thu Apr 10 22:04:49 +0000 2003
>Last-Modified:  Thu Apr 10 22:07:00 +0000 2003
>Originator:     matthew green
>Release:        1.0A
>Organization:
bozotic softwar foundation.
>Environment:
System: NetBSD splode.mame.mu.OZ.AU 1.0A NetBSD 1.0A (_splode_) #124: Sun Jan 15 16:07:03 EST 1995 mrg@splode.mame.mu.OZ.AU:/splode/build/src/sys/arch/sparc/compile/_splode_ sparc

>Description:

	TIOCCONS should work if i own the console, so i can redirect
	console messages elsewhere.  on the sparc is is very annoying
	to have console messages printed on the X display.

>How-To-Repeat:
	n/a
>Fix:

	this is a non-working patch of what i've done so far.  i couldn't
	finish it, and i got sick of it, so i'm sending it in here incase
	someone else tries to work on it.


Index: tty.c
===================================================================
RCS file: /local/cvs/src/sys/kern/tty.c,v
retrieving revision 1.1.1.1
retrieving revision 1.6
diff -c -r1.1.1.1 -r1.6
*** 1.1.1.1	1994/12/14 12:45:53
--- 1.6	1995/01/15 05:14:53
***************
*** 42,47 ****
--- 42,48 ----

  #include <sys/param.h>
  #include <sys/systm.h>
+ #include <sys/namei.h>
  #include <sys/ioctl.h>
  #include <sys/proc.h>
  #define	TTYDEFCHARS
***************
*** 699,708 ****
  			    ISSET(constty->t_state, TS_CARR_ON | TS_ISOPEN) ==
  			    (TS_CARR_ON | TS_ISOPEN))
  				return (EBUSY);
! #ifndef	UCONSOLE
! 			if (error = suser(p->p_ucred, &p->p_acflag))
! 				return (error);
  #endif
  			constty = tp;
  		} else if (tp == constty)
  			constty = NULL;
--- 700,753 ----
  			    ISSET(constty->t_state, TS_CARR_ON | TS_ISOPEN) ==
  			    (TS_CARR_ON | TS_ISOPEN))
  				return (EBUSY);
! 
! 			if (error = suser(p->p_ucred, &p->p_acflag)) {
! 				register struct ucred *cred;
! 				uid_t t_uid;
! 				gid_t t_gid;
! 				struct vnode *vp;
! 
! 		/*
! 		 * need some better way to do this rather than trying to
! 		 # use "/dev/console".  probably something that takes the
! 		 # value of constty->t_dev, and creates a vp out of it..
! 		 * how to do this, i haven't a clue.
! 		 *
! 		 * Mycroft says: You could use cdevvp(constty->t_dev, &vp),
! 		 * if you want to check the ownership of /dev/console,
! 		 * specifically, but that assumes the vnode is open.
! 		 * You could do cdevvp() and see if the tag is VT_NON.
! 		 * That's a kluge, of course.
! 		 */
! #if 1
! 				struct nameidata nd;
! 
! 				NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF,
! 				    UIO_SYSSPACE, "/dev/console", p);
! 				error = namei(&nd);
! 				if (error)
! 					return (error);
! 				vp = nd.ni_vp;
! #else
! 				error = cdevvp(constty->t_dev, &vp);
! 				printf("ioctl TIOCCONS: error %d on cdevvp", error);
! 				if (error) 
! 					return (error);
! 				printf("ioctl TIOCCONS: vp->v_tag is %d", vp->v_tag);
! 				if (vp->v_tag == VT_NON) /* XXX this is a kludge */
! 					return (EBUSY);
  #endif
+ 				cred = p->p_ucred;
+ 				t_uid = cred->cr_uid;
+ 				t_gid = cred->cr_groups[0];
+ 				cred->cr_uid = p->p_cred->p_ruid;
+ 				cred->cr_groups[0] = p->p_cred->p_rgid;
+ 				error = VOP_ACCESS(vp, VREAD, cred, p);
+ 				cred->cr_uid = t_uid;
+ 				cred->cr_groups[0] = t_gid;
+ 				if (error) 
+ 					return (error);
+ 			}
  			constty = tp;
  		} else if (tp == constty)
  			constty = NULL;
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: jeremy 
State-Changed-When: Thu Apr 10 12:46:13 PDT 1997 
State-Changed-Why:  
Either your change was used, or someone else made one.  In either case, 
I think this has been solved finally with 'options UCONSOLE'. 
State-Changed-From-To: closed->open 
State-Changed-By: mrg 
State-Changed-When: Thu Apr 10 18:12:43 PDT 1997 
State-Changed-Why:  
actually, this problem is still exactly as it was, which is why i'm 
re-opening it.  it has not been fixed and UCONSOLE is _NOT_ a solution. 
removing UCONSOLE is part of a solution, though.  :-) 
Responsible-Changed-From-To: kern-bug-people->mrg 
Responsible-Changed-By: perry 
Responsible-Changed-When: Mon Sep 23 11:47:56 PDT 2002 
Responsible-Changed-Why:  
He submitted it -- he should probably decide what to do. 
Responsible-Changed-From-To: mrg->kern-bug-people 
Responsible-Changed-By: mrg 
Responsible-Changed-When: Tue Sep 24 17:22:27 PDT 2002 
Responsible-Changed-Why:  
just because i submitted this does not mean i have any idea of the 
CORRECT way to fix it.  i suspect it coms down to a new ioctl() 
along the lines of what chris torek proposed on tech-kern(?) 
several years ago....but i don't own this bug. 
State-Changed-From-To: open->feedback 
State-Changed-By: darcy 
State-Changed-When: Sun Feb 16 15:14:43 PST 2003 
State-Changed-Why:  
I know that I can direct console messages to xconsole to the annoyance of 
my Linux friends who can't keep the display from interfering with their 
working terminals.  What further functionality is needed here.  If no 
one can find the time or urgency to work on it in 8 years then perhaps wer 
should just close this. 
State-Changed-From-To: feedback->closed 
State-Changed-By: mrg 
State-Changed-When: Sun Feb 16 17:46:52 PST 2003 
State-Changed-Why:  
this is still a bug.  why do people continue to insist on trying to resole this 
bug but NOT FIXING IT?  please stop. 
State-Changed-From-To: closed->open 
State-Changed-By: mrg 
State-Changed-When: Mon Feb 17 00:08:00 PST 2003 
State-Changed-Why:  
oops, wrongly closed. :-) 
State-Changed-From-To: open->closed 
State-Changed-By: christos 
State-Changed-When: Thu Apr 10 18:04:30 EDT 2003 
State-Changed-Why:  
Fixed, thanks 

From: Christos Zoulas <christos@netbsd.org>
To: gnats-bugs@gnats.netbsd.org
Cc:  
Subject: pr/732 CVS commit: src/sys/kern
Date: Fri, 11 Apr 2003 01:05:58 +0300 (EEST)

 Module Name:	src
 Committed By:	christos
 Date:		Thu Apr 10 22:05:58 UTC 2003

 Modified Files:
 	src/sys/kern: tty.c

 Log Message:
 PR/732: Matt Green: TIOCCONS should work if the user owns /dev/console.


 To generate a diff of this commit:
 cvs rdiff -r1.150 -r1.151 src/sys/kern/tty.c

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.