Subject: re: Problems with xsrc X server on -current
To: None <bad@ora.de, mrg@eterna.com.au>
From: Chris Torek <torek@BSDI.COM>
List: port-sparc
Date: 02/27/1999 12:11:28
>my feeling on this is that anyone with read access on
>/dev/console should be able to do a TIOCCONS.

There is a simple method for achieving this: make an ioctl operation
that works on /dev/console, NOT on the target fd, and do:

	fd = open("/dev/console", O_RDWR);	/* or whatnot */
	if (fd < 0) ... error ...

	whereto = STDOUT_FILENO;		/* e.g. */
	error = ioctl(fd, TIOCCONSREDIR, &whereto);

The code to handle the CONSREDIR ioctl would go in cons.c,
and would need to translate the fd to a vnode, etc.

Be sure to check for redirection-to-self (and maybe allow
redirection to fd "-1" to mean "end redirection).

The only drawback to this, aside from the specificity (perhaps
the ioctl should be fully general and allow redirecting data from
any fd, to any fd, in any direction), is that you then have to
modify xterm and xconsole to use the new ioctl.

Chris