NetBSD-Bugs archive

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

bin/45759: slattach(8) is not compatible with pseudo-terminals



>Number:         45759
>Category:       bin
>Synopsis:       slattach(8) is not compatible with pseudo-terminals
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 30 02:30:00 +0000 2011
>Originator:     Khanh-Dang Nguyen Thu Lam
>Release:        NetBSD-5.1
>Organization:
>Environment:
NetBSD zoee 5.1 NetBSD 5.1 (GENERIC) #0: Sat Nov  6 18:44:40 UTC 2010  
builds%b6.netbsd.org@localhost:/home/builds/ab/netbsd-5-1-RELEASE/sparc/201011061943Z-obj/home/builds/ab/netbsd-5-1-RELEASE/src/sys/arch/sparc/compile/GENERIC
 sparc
>Description:
slattach(8) does not work on pseudo-terminals pty(4).
>How-To-Repeat:
# ifconfig sl0 create
# slattach -l /dev/ptyp0
slattach: TIOCSDTR: Inappropriate ioctl for device

The error message is the same if slattach opens the slave pseudo-terminal 
(instead of the master pseudo-terminal, as in the above example):

# ifconfig sl0 create
# cat 3<>/dev/ptyp0 >&3 <&3 &
# slattach -l /dev/ttyp0
slattach: TIOCSDTR: Inappropriate ioctl for device

>Fix:
I propose the little patch below.

The modified line tries to set the DTR line and fails when the file descriptor 
is a pseudo terminal, because ioctl(TIOCSDTR) is not implemented for pseudo 
terminals.  It is not clear to me whether it is better to change the pty 
driver, or even the tty driver, instead (these drivers would simply ignore 
TIOCSDTR and friends).


--- src/sbin/slattach/slattach.c.orig   2011-08-28 05:02:05.000000000 +0200
+++ src/sbin/slattach/slattach.c        2011-12-30 03:07:34.000000000 +0100
@@ -55,6 +55,7 @@
 #include <netinet/in.h>
 
 #include <err.h>
+#include <errno.h>
 #include <fcntl.h>
 #include <netdb.h>
 #include <paths.h>
@@ -135,7 +136,7 @@
        cfsetspeed(&tty, speed);
        if (tcsetattr(fd, TCSADRAIN, &tty) < 0)
                err(1, "tcsetattr");
-       if (ioctl(fd, TIOCSDTR, 0) < 0)
+       if (ioctl(fd, TIOCSDTR, 0) < 0 && errno != ENOTTY)
                err(1, "TIOCSDTR");
        if (ioctl(fd, TIOCSETD, &slipdisc) < 0)
                err(1, "TIOCSETD");



Home | Main Index | Thread Index | Old Index