On 2015/10/07 12:00, Theo de Raadt wrote:
> CVSROOT:      /cvs
> Module name:  src
> Changes by:   [email protected] 2015/10/07 12:00:06
> 
> Modified files:
>       usr.bin/tty    : tty.c 
> 
> Log message:
> use tame "stdio rpath tty", for ttyname().  from Rob Pierce, who chose to
> do this using ktrace step by step.  not the method i recommend, because
> it requires 100% coverage via feature tests.  better to read the code and
> understand everything being called, then make decisions.
> 

I ran into a problem building ports/korean/hanterm-xf in DPB with this.

checking for tty group name... Killed 
wheel
checking if we may use wheel group... Killed 
no

Followed later by

./main.c: In function 'get_pty':
./main.c:2352: warning: assignment makes pointer from integer without a cast
./main.c:2353: error: dereferencing pointer to incomplete type

because USE_TTY_GROUP wasn't defined, which is a prerequisite to pull in grp.h:

#ifdef USE_TTY_GROUP
#include <grp.h>
#endif

So during the autoconf checks, we get this:

Oct  8 17:44:01 i386 /bsd: tty(18956): syscall 54
Oct  8 17:44:01 i386 /bsd: tty(18956): syscall 54
Oct  8 17:44:01 i386 /bsd: tty(968): syscall 54
Oct  8 17:44:01 i386 /bsd: tty(968): syscall 54

This comes from tty(1) doing this

        t = ttyname(STDIN_FILENO);

which calls tcgetattr, which calls an ioctl (54=ioctl)

        return (ioctl(fd, TIOCGETA, t));

But it only happens when run through ssh.

$ tty
/dev/ttyp2
$ ssh i386 tty
^[[A Killed 

So in order to tame tty(1), the ioctl check needs to be more lax than
the current one,

                        if (fp->f_type == DTYPE_VNODE && (vp->v_flag & VISTTY))
                                return (0);

Reply via email to