NetBSD Problem Report #45759

From www@NetBSD.org  Fri Dec 30 02:26:18 2011
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 52D3D63D7A5
	for <gnats-bugs@gnats.NetBSD.org>; Fri, 30 Dec 2011 02:26:18 +0000 (UTC)
Message-Id: <20111230022617.3D1B263C457@www.NetBSD.org>
Date: Fri, 30 Dec 2011 02:26:17 +0000 (UTC)
From: kdntl@espci.fr
Reply-To: kdntl@espci.fr
To: gnats-bugs@NetBSD.org
Subject: slattach(8) is not compatible with pseudo-terminals
X-Send-Pr-Version: www-1.0

>Number:         45759
>Category:       bin
>Synopsis:       slattach(8) is not compatible with pseudo-terminals
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    christos
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Dec 30 02:30:00 +0000 2011
>Closed-Date:    Sat Dec 31 14:10:35 +0000 2011
>Last-Modified:  Sat Dec 31 14:10:35 +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:/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");

>Release-Note:

>Audit-Trail:
From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/45759 CVS commit: src/sbin/slattach
Date: Thu, 29 Dec 2011 22:19:37 -0500

 Module Name:	src
 Committed By:	christos
 Date:		Fri Dec 30 03:19:37 UTC 2011

 Modified Files:
 	src/sbin/slattach: slattach.c

 Log Message:
 PR/45759: Khanh-Dang Nguyen Thu Lam: slattach(8) is not compatible with
 pseudo-terminals. Fixed by ignoring the error for the DTR ioctl.


 To generate a diff of this commit:
 cvs rdiff -u -r1.31 -r1.32 src/sbin/slattach/slattach.c

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

Responsible-Changed-From-To: bin-bug-people->christos
Responsible-Changed-By: wiz@NetBSD.org
Responsible-Changed-When: Fri, 30 Dec 2011 12:18:35 +0000
Responsible-Changed-Why:
christos committed, ok to close?


State-Changed-From-To: open->feedback
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Fri, 30 Dec 2011 12:18:35 +0000
State-Changed-Why:
see above


From: Khanh-Dang Nguyen Thu Lam <kdntl@espci.fr>
To: gnats-bugs@NetBSD.org
Cc: christos@NetBSD.org, gnats-admin@NetBSD.org, netbsd-bugs@NetBSD.org,
        wiz@NetBSD.org
Subject: Re: bin/45759 (slattach(8) is not compatible with pseudo-terminals)
Date: Sat, 31 Dec 2011 14:49:36 +0100

 On Fri 30 Dec 2011 12:18 +0000, wiz@NetBSD.org wrote:
 > Synopsis: slattach(8) is not compatible with pseudo-terminals
 > 
 > Responsible-Changed-From-To: bin-bug-people->christos
 > Responsible-Changed-By: wiz@NetBSD.org
 > Responsible-Changed-When: Fri, 30 Dec 2011 12:18:35 +0000
 > Responsible-Changed-Why:
 > christos committed, ok to close?
 > 
 > 
 > State-Changed-From-To: open->feedback
 > State-Changed-By: wiz@NetBSD.org
 > State-Changed-When: Fri, 30 Dec 2011 12:18:35 +0000
 > State-Changed-Why:
 > see above

 OK to close.  Thanks!

State-Changed-From-To: feedback->closed
State-Changed-By: wiz@NetBSD.org
State-Changed-When: Sat, 31 Dec 2011 14:10:35 +0000
State-Changed-Why:
Confirmed fixed, thanks!


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.