Subject: Re: (Quasi-) SUMMARY: pre-built kernels with UCONSOLE
To: None <port-sparc@netbsd.org>
From: matthew green <mrg@splode.mame.mu.OZ.AU>
List: port-sparc
Date: 12/07/1994 02:44:07
well, i went and implimented this, but it's not tested.  there's one
thing i really hate about what i've done, but i didn't see how to
get a struct vnode from a device number.  so it really lamely does
a namei() on /dev/console.. totally bogus, but someone who knows
the right way will be able to fix this.

remember:  i'm too lazy to reboot and test that this works, so don't
blame me if it causes major fireworks.

remember:  i hate the hardcoded `/dev/console'.  someone who knows
How To Do That Bit Right should fix it (and also tell me!  ;-).

remember:  this is untested (it does compile ;-).

.mrg.

Index: tty.c
*** 1.1.1.1	1994/12/04 03:33:41
--- tty.c	1994/12/06 15:42:10
***************
*** 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,737 ----
  			    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;
! 				register 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.
! 		 */
! 				struct nameidata nd;
! 
! 				NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF,
! 				    UIO_USERSPACE, "/dev/console", p);
! 				error = namei(&nd);
! 				if (0 == error) {
! 					vp = nd.ni_vp;
! 					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;