From mark@grondar.za  Wed Dec 28 09:51:30 1994
Received: from grunt.grondar.za (grunt.grondar.za [196.7.18.129]) by freefall.cdrom.com (8.6.9/8.6.6) with ESMTP id JAA24932 for <FreeBSD-gnats-submit@freebsd.org>; Wed, 28 Dec 1994 09:51:03 -0800
Received: (from mark@localhost) by grunt.grondar.za (8.6.9/8.6.9) id TAA18035; Wed, 28 Dec 1994 19:50:36 +0200
Message-Id: <199412281750.TAA18035@grunt.grondar.za>
Date: Wed, 28 Dec 1994 19:50:36 +0200
From: Mark Murray <mark@grondar.za>
Reply-To: mark@grondar.za
To: FreeBSD-gnats-submit@freebsd.org
Subject: Usr.bin/talk still works if terminal is unwritable.
X-Send-Pr-Version: 3.2

>Number:         90
>Category:       bin
>Synopsis:       Usr.bin/talk still works if terminal is unwritable.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    core
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Dec 28 10:00:01 1994
>Closed-Date:    Wed Dec 28 10:00:01 1994
>Last-Modified:  Thu Sep 13 12:54:41 GMT 2007
>Originator:     Mark Murray
>Release:        FreeBSD 2.1.0-Development i386
>Organization:
GTA
>Environment:

Seems to be most forms of UNIX, but specifically BSD variants.

>Description:

Talk will still try to establish a connection, even if the terminal is
unwritable by the called party.

>How-To-Repeat:

1. $ mesg n
2. $ talk <someone>
3. "<someone>" responds - talk <you> - gets rude message about <you>
   refusing messages.

>Fix:
	

diff -cdp /usr/src/usr.bin/talk/init_disp.c ./init_disp.c
*** /usr/src/usr.bin/talk/init_disp.c	Tue Sep 20 10:07:52 1994
--- ./init_disp.c	Wed Dec 28 19:43:04 1994
*************** static char sccsid[] = "@(#)init_disp.c	
*** 42,51 ****
--- 42,70 ----
  
  #include <sys/ioctl.h>
  #include <sys/ioctl_compat.h>
+ #include <sys/types.h>
+ #include <sys/stat.h>
  
+ #include <unistd.h>
  #include <signal.h>
  #include <err.h>
  #include "talk.h"
+ 
+ /* 
+  * Make sure the callee can write to the screen
+  */
+ void check_writeable()
+ {
+ 	char *tty;
+ 	struct stat sb;
+ 
+ 	if ((tty = ttyname(STDERR_FILENO)) == NULL)
+ 		errx(1, "ttyname");
+ 	if (stat(tty, &sb) < 0)
+ 		errx(1, "%s", tty);
+ 	if (!(sb.st_mode & S_IWGRP))
+ 		errx(1, "The callee cannot write to this terminal.");
+ }
  
  /* 
   * Set up curses, catch the appropriate signals,
diff -cdp /usr/src/usr.bin/talk/talk.c ./talk.c
*** /usr/src/usr.bin/talk/talk.c	Fri May 27 14:32:47 1994
--- ./talk.c	Wed Dec 28 19:45:07 1994
*************** static char sccsid[] = "@(#)talk.c	8.1 (
*** 55,60 ****
--- 55,61 ----
   *		Modified to run under 4.1a by Clem Cole and Peter Moore
   *		Modified to run between hosts by Peter Moore, 8/19/82
   *		Modified to run under 4.1c by Peter Moore 3/17/83
+  *		Fixed to not run with unwriteable terminals MRVM 28/12/94
   */
  
  main(argc, argv)
*************** main(argc, argv)
*** 62,67 ****
--- 63,69 ----
  	char *argv[];
  {
  	get_names(argc, argv);
+ 	check_writeable();
  	init_display();
  	open_ctl();
  	open_sockt();
>Release-Note:
>Audit-Trail:
>Unformatted:



