summaryrefslogtreecommitdiffstats
path: root/usr.bin/talk
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1994-12-30 16:09:31 +0000
committerache <ache@FreeBSD.org>1994-12-30 16:09:31 +0000
commit319b403916158fbde498b6bd5e494ad91a122c22 (patch)
tree67041f45827a69bcfaf475609076a8fff174fc9f /usr.bin/talk
parent25a5fb98620fbab0b47cd399913603405728819d (diff)
downloadFreeBSD-src-319b403916158fbde498b6bd5e494ad91a122c22.zip
FreeBSD-src-319b403916158fbde498b6bd5e494ad91a122c22.tar.gz
Add check for writeable terminal
Submitted by: mark@grondar.za (and slightly modified)
Diffstat (limited to 'usr.bin/talk')
-rw-r--r--usr.bin/talk/init_disp.c19
-rw-r--r--usr.bin/talk/talk.c2
2 files changed, 21 insertions, 0 deletions
diff --git a/usr.bin/talk/init_disp.c b/usr.bin/talk/init_disp.c
index 5bebcd8..ee99556 100644
--- a/usr.bin/talk/init_disp.c
+++ b/usr.bin/talk/init_disp.c
@@ -42,12 +42,31 @@ static char sccsid[] = "@(#)init_disp.c 8.2 (Berkeley) 2/16/94";
#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)
+ err(1, "ttyname");
+ if (stat(tty, &sb) < 0)
+ err(1, "%s", tty);
+ if (!(sb.st_mode & S_IWGRP))
+ errx(1, "The callee cannot write to this terminal, use \"mesg y\".");
+}
+
+/*
* Set up curses, catch the appropriate signals,
* and build the various windows.
*/
diff --git a/usr.bin/talk/talk.c b/usr.bin/talk/talk.c
index 702df16..8873e26 100644
--- a/usr.bin/talk/talk.c
+++ b/usr.bin/talk/talk.c
@@ -55,6 +55,7 @@ static char sccsid[] = "@(#)talk.c 8.1 (Berkeley) 6/6/93";
* 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)
@@ -62,6 +63,7 @@ main(argc, argv)
char *argv[];
{
get_names(argc, argv);
+ check_writeable();
init_display();
open_ctl();
open_sockt();
OpenPOWER on IntegriCloud