[alt.sources] talkanswer 1.0 - a talk answering machine

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (09/14/90)

This is talkanswer 1.0, an answering machine for BSD talk. Once you've
installed it, if anyone talks to a user not logged on to your machine,
talkanswer will answer instead and send the message through normal mail.
All the work is done by a shell script that you can easily customize.

Send comments to me or to alt.sources.d.

---Dan

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of shell archive."
# Contents:  README talkanswer talkdiff
# Wrapped by brnstnd@kramden on Fri Sep 14 12:15:50 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(1216 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XThis is talkanswer 1.0, an answering machine for BSD talk. Once you've
Xinstalled it, if anyone talks to a user not logged on to your machine,
Xtalkanswer will answer instead and send the message through normal mail.
XAll the work is done by a shell script that you can easily customize.
X
X
XDon't try to install talkanswer unless you have the new talk. To see if
Xyou have new talk, check for a line containing 518 in /etc/services.
X
XYou need the pty program and setuid utility. pty is available upon
Xrequest to brnstnd@nyu.edu or via anonymous ftp to 128.122.128.22.
Xsetuid is included in the authutil package, which is available from
Xuunet.uu.net:/comp.sources.unix/volume22/auth-utils/part*.
X
XYou need the talkd source to set up talkanswer. If you don't have the
Xsource, get it from uunet.uu.net:/bsd-sources/src/network/talkd.tar.Z.
XApply the patch in talkdiff and recompile.
X
XOnce you've successfully compiled talkd, hide /etc/ntalkd in a safe
Xplace and put the new talkd there.
X
XFinally, put talkanswer into a path that's in inetd's environment. If
Xyou want, change the talkanswer pathname in announce.c for this.
X
XSend comments or complaints to me, Dan Bernstein, at brnstnd@nyu.edu.
XThis is version 1.0, 9/14/90.
END_OF_FILE
if test 1216 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'talkanswer' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'talkanswer'\"
else
echo shar: Extracting \"'talkanswer'\" \(739 characters\)
sed "s/^X//" >'talkanswer' <<'END_OF_FILE'
X#!/bin/sh
XTERM=vt100;export TERM
X{
X  /bin/setuid "$1" touch /tmp/talkans.$$
X  until grep -s stablished /tmp/talkans.$$
X  do
X    sleep 3
X  done
X  /bin/setuid "$1" rm /tmp/talkans.$$
X  echo "This is the talkanswer system, answering for $1."
X  echo "Please leave your name after the beep."
X  echo "<beep>"
X  sleep 300
X  echo ""
X  echo "Thirty seconds left on the tape."
X  sleep 30
X  echo ""
X  echo "Thank you for calling."
X  echo "<beep>"
X  echo x | tr x '\003'
X} | {
X  echo "From: $2@$3"
X  echo "To: $1"
X  echo ""
X  /bin/setuid "$1" /usr/local/pty -dxuR /usr/ucb/talk "$2@$3" 2>&1
X} | {
X  /bin/setuid "$1" awk '{ print }
X/stablished/ { print "established" >"/tmp/talkans.'$$'" }'
X} | /usr/lib/sendmail -f"$2@$3" -F"talkanswer" "$1" &
Xexit 0
END_OF_FILE
if test 739 -ne `wc -c <'talkanswer'`; then
    echo shar: \"'talkanswer'\" unpacked with wrong size!
fi
chmod +x 'talkanswer'
# end of 'talkanswer'
fi
if test -f 'talkdiff' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'talkdiff'\"
else
echo shar: Extracting \"'talkdiff'\" \(1310 characters\)
sed "s/^X//" >'talkdiff' <<'END_OF_FILE'
X*** announce.c.orig	Sat Jun 18 17:10:48 1988
X--- announce.c	Fri Sep 14 11:33:11 1990
X***************
X*** 28,33 ****
X--- 28,34 ----
X  #include <sys/wait.h>
X  #include <errno.h>
X  #include <syslog.h>
X+ #include <pwd.h>
X  
X  #include <protocols/talkd.h>
X  
X***************
X*** 83,88 ****
X--- 84,96 ----
X  	FILE *tf;
X  	struct stat stbuf;
X  
X+ 	if (request->r_tty[0] == '/')
X+ 	 {
X+ 	  /* Answering machine. */
X+ 	  execlp("talkanswer","talkanswer",request->r_name,
X+ 		  request->l_name,remote_machine,(char *) 0);
X+ 	  return(FAILED);
X+ 	 }
X  	(void)sprintf(full_tty, "/dev/%s", request->r_tty);
X  	if (access(full_tty, 0) != 0)
X  		return (FAILED);
X*** process.c.orig	Sat Jun 18 17:10:49 1988
X--- process.c	Fri Sep 14 11:33:06 1990
X***************
X*** 122,129 ****
X  	/* see if the user is logged */
X  	result = find_user(mp->r_name, mp->r_tty);
X  	if (result != SUCCESS) {
X! 		rp->answer = result;
X! 		return;
X  	}
X  #define	satosin(sa)	((struct sockaddr_in *)(sa))
X  	hp = gethostbyaddr(&satosin(&mp->ctl_addr)->sin_addr,
X--- 122,129 ----
X  	/* see if the user is logged */
X  	result = find_user(mp->r_name, mp->r_tty);
X  	if (result != SUCCESS) {
X! 	  mp->r_tty[0] = '/';
X! 	  result = SUCCESS;
X  	}
X  #define	satosin(sa)	((struct sockaddr_in *)(sa))
X  	hp = gethostbyaddr(&satosin(&mp->ctl_addr)->sin_addr,
END_OF_FILE
if test 1310 -ne `wc -c <'talkdiff'`; then
    echo shar: \"'talkdiff'\" unpacked with wrong size!
fi
# end of 'talkdiff'
fi
echo shar: End of shell archive.
exit 0