Module Name:    src
Committed By:   plunky
Date:           Mon Jul 18 15:44:17 UTC 2011

Modified Files:
        src/usr.bin/rfcomm_sppd: rfcomm_sppd.c

Log Message:
only modify the termios structure when tty_in is verifiably a terminal


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/usr.bin/rfcomm_sppd/rfcomm_sppd.c

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

Modified files:

Index: src/usr.bin/rfcomm_sppd/rfcomm_sppd.c
diff -u src/usr.bin/rfcomm_sppd/rfcomm_sppd.c:1.13 src/usr.bin/rfcomm_sppd/rfcomm_sppd.c:1.14
--- src/usr.bin/rfcomm_sppd/rfcomm_sppd.c:1.13	Wed Nov  3 08:27:27 2010
+++ src/usr.bin/rfcomm_sppd/rfcomm_sppd.c	Mon Jul 18 15:44:17 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rfcomm_sppd.c,v 1.13 2010/11/03 08:27:27 plunky Exp $	*/
+/*	$NetBSD: rfcomm_sppd.c,v 1.14 2011/07/18 15:44:17 plunky Exp $	*/
 
 /*-
  * Copyright (c) 2006 Itronix Inc.
@@ -62,7 +62,7 @@
   Copyright (c) 2006 Itronix, Inc.\
   Copyright (c) 2003 Maksim Yevmenkin m_evmen...@yahoo.com.\
   All rights reserved.");
-__RCSID("$NetBSD: rfcomm_sppd.c,v 1.13 2010/11/03 08:27:27 plunky Exp $");
+__RCSID("$NetBSD: rfcomm_sppd.c,v 1.14 2011/07/18 15:44:17 plunky Exp $");
 
 #include <sys/param.h>
 
@@ -230,18 +230,20 @@
 	 * be used directly with stdio
 	 */
 	if (tty == NULL) {
-		if (tcgetattr(tty_in, &t) < 0)
-			err(EXIT_FAILURE, "tcgetattr");
+		if (isatty(tty_in)) {
+			if (tcgetattr(tty_in, &t) < 0)
+				err(EXIT_FAILURE, "tcgetattr");
+
+			memcpy(&tio, &t, sizeof(tio));
+			t.c_lflag &= ~(ECHO | ICANON);
+			t.c_iflag &= ~(ICRNL);
+
+			if (memcmp(&tio, &t, sizeof(tio))) {
+				if (tcsetattr(tty_in, TCSANOW, &t) < 0)
+					err(EXIT_FAILURE, "tcsetattr");
 
-		memcpy(&tio, &t, sizeof(tio));
-		t.c_lflag &= ~(ECHO | ICANON);
-		t.c_iflag &= ~(ICRNL);
-
-		if (memcmp(&tio, &t, sizeof(tio))) {
-			if (tcsetattr(tty_in, TCSANOW, &t) < 0)
-				err(EXIT_FAILURE, "tcsetattr");
-
-			atexit(reset_tio);
+				atexit(reset_tio);
+			}
 		}
 	} else {
 		if (daemon(0, 0) < 0)

Reply via email to