Repost of phdaemon - version #3

Lenny Tropiano lenny at icus.UUCP
Mon Jul 18 08:50:22 AEST 1988


[I know this is not a source, it's really a discussion on one, but we don't
 have a group called unix-pc.sources.d -- I directed all other discussions
 to unix-pc.general - LBT]

In article <112 at pbhacker.UUCP> tlh at pbhacker.UUCP (Lee Hounshell) writes:
|>I've had a few requests for a repost of the fixed version of phdaemon..
|>for those of you not familiar with it, phdaemon will monitor both
|>incoming and outgoing calls on your Unix PC.
|>

Some phdaemon history...

The phdaemon everyone is familiar with was probably the version I wrote.
I've been running it here for over 10 months without any problems.  There
was some work done by Lee Hounshell (tlh at pbhacker) to avoid those
"popup smgr windows" that stopped all cron processes in this version
of phdaemon, of which he used the version of phdaemon I wrote.  
Paul Condie (pjc at pcbox) wrote the *original* phdaemon back in October 1987,
and posted his version to the net.  It had some deficiencies and problems,
so I decided to do a total rewrite and get a new-and-improved version.
I posted mine back in November, 1987.  It had two problems which I addressed
later with patches. One was the handling of LCK..ph* files and possibly getting
in a race-condition and causing the popup window to show.  The second was
the popup windows in the error-handling routine, this was later changed
to a [!!] icon which did not halt cron processes.

|>
|>/************************************************************************\
|> **									 **
|> ** Program name: phdaemon.c (Phone Daemon)				 **
|> ** Programmers:  original version   - Paul J. Condie (UUCP=pcbox!pjc) **
|> **		 modified version   - Lenny Tropiano (UUCP=icus!lenny)	 **
|> **		 fixes/enhancements - Lee Hounshell  (UUCP=pbhacker!tlh) **
|> **		 kernel	access rtns - Michael Ditto (ford at crash.CTS.COM) **

Note this was a total rewrite... I did give credit to Paul and Mike in
my comment section which was somehow changed (for what reason) by
Lee Hounshell.  I would appreciate if the header information was left
in tack, and you just added your revision history and your comments where
appropriate. [I thought this was somehow understood when people add to
someone else's programs]  

In the future anyone who modifies one of my programs, please mail me the
context diffs so that I can apply them to my source and keep it up
to date.  This avoids many people having different copies and each supporting
their own version.  It would be much better to have one person (usually
the original author) handle all revision changes and patches.  When someone
on the net says their "phdaemon isn't working" (for example) each of us
wouldn't have to look to figure out who's is at fault.

|> ** Date:	 December 13, 1987					 **
|> **									 **
|> ************************************************************************
|> **									 **
|> ** Program use: Program is run as a daemon process from the boot	 **
|> **		 procedure /etc/rc.  It	can be placed in /etc/daemons/	 **
|> **		 and will be started up	apon system boot.  This	program	 **
|> **		 monitors the data line	(defined as /dev/ph1) for	 **
|> **		 any kind of activity (or lack thereof)	and displays	 **
|> **		 the information in the	Phone Managers window. Freeing	 **
|> **		 up any	other windows from being allocated for that use	 **
|> **									 **
|> **		 This program checks for DATA or VOICE,	UUCP logins,	 **
|> **		 User logins, UUCP outgoing, Internal use of outgoing	 **
|> **		 modem.	 This process will terminate if	the /etc/ph	 **
|> **		 process is terminated.					 **
|> **									 **
|> ** Enhancements: Bugs in properly detecting incoming calls have been	 **
|> **		 fixed.	 The program now reports stray lock files in	 **
|> **		 the status window.  Errors are	reported by placing	 **
|> **		 "ERROR" in the	status window.	User logins and	errors	 **
|> **		 are now logged	in the "/usr/adm/phdaemon.log" file.	 **
|> **									 **
|>\************************************************************************/
|>
... [ rest of the source omitted ] ...

Note: I haven't tested Lee's version, although I assume it works as he
wouldn't have posted it if it didn't.   The only thing that I see might
be a problem is the printing of "ERROR" in the ph-window.  That will be
erased if the phone is picked up (ie. VOICE 1: ACTIVE) or it rings
(ie. VOICE 1: <RING).

For historical purposes here is the original header/comment block with
the actual credits, organization name (which has since changed to
ICUS Software Systems), and date in tack.

/************************************************************************\
**                                                                      **
** Program name: phdaemon.c (Phone Daemon)                              **
** Programmer:   Lenny Tropiano            UUCP: ...icus!lenny          **
** Organization: ICUS Computer Group                                    **
** Date:         November 8, 1987                                       **
**                                                                      **
**************************************************************************
**                                                                      **
** Credits:      Thanks to Michael Ditto (ford at crash.CTS.COM) for his   **
**               Programs fuser and renice which aided me to write the  **
**               Kernel accessing routines.                             **
**                                                                      **
**               Again I want to *THANK* Mike Ditto for his infinite    **
**               wisdom when it came to the "internals" of the UNIXPC   **
**                                                                      **
**               Thanks to Paul J. Condie (pcbox!pjc) for his original  **
**               idea of the phdaemon program and some tips on writing  **
**               my own.                                                **
**                                                                      **
**************************************************************************
**                                                                      **
** Program use:  Program is run as a daemon process from the boot       **
**               procedure /etc/rc.  It can be placed in /etc/daemons/  **
**               and will be started up apon system boot.  This program **
**               monitors the data line (defined as /dev/ph1) for       **
**               any kind of activity (or lack thereof) and displays    **
**               the information in the Phone Managers window. Freeing  **
**               up any other windows from being allocated for that use **
**                                                                      **
**               This program checks for DATA or VOICE, UUCP logins,    **
**               User logins, UUCP outgoing, Internal use of outgoing   **
**               modem.  This process will terminate if the /etc/ph     **
**               process is terminated.                                 **
**                                                                      **
\************************************************************************/

-- enclosed below are the Makefile and the original README text that
-- was omitted from the Lee's phdaemon version.

--- cut here --- --- cut here --- --- cut here --- --- cut here ---
#! /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:  Makefile README
# Wrapped by lenny at icus on Sun Jul 17 18:44:07 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'Makefile' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'Makefile'\"
else
echo shar: Extracting \"'Makefile'\" \(664 characters\)
sed "s/^X//" >'Makefile' <<'END_OF_FILE'
X#
X# Makefile to compile phdaemon.c  (Phone Daemon)
X# By Lenny Tropiano
X# (c)1987 ICUS Computer Group     UUCP:  ...icus!lenny
X#
XCFLAGS=-v -O
XLDFLAGS=-s
XLIBS=/lib/crt0s.o /lib/shlib.ifile
XDEST=/etc/daemons/
X#
Xphdaemon.o:
X	$(CC) $(CFLAGS) -c phdaemon.c
X#
Xphdaemon:  phdaemon.o
X	@echo "Loading ..."
X	$(LD) $(LDFLAGS) -o phdaemon phdaemon.o $(LIBS) 
X#
X# You need to be super-user to do this.
X#
X/etc/daemons:
X	mkdir /etc/daemons
X	chmod 755 /etc/daemons
X#
Xinstall: phdaemon /etc/daemons
X	cp phdaemon /etc/daemons/
X	chown root /etc/daemons/phdaemon
X	chgrp bin  /etc/daemons/phdaemon
X	chmod 4750 /etc/daemons/phdaemon
X	@echo "Phone Daemon started."
X	/etc/daemons/phdaemon
END_OF_FILE
if test 664 -ne `wc -c <'Makefile'`; then
    echo shar: \"'Makefile'\" unpacked with wrong size!
fi
# end of 'Makefile'
fi
if test -f 'README' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(4692 characters\)
sed "s/^X//" >'README' <<'END_OF_FILE'
XThe phone daemon program was written to keep all those people who jump
Xto login when they hear the relay click on the UNIX pc.  The program
Xwas first written by Paul Condie (pcbox!pjc) for this exact reason!
X
XI give thanks to Paul and Michael Ditto (ford at crash.CTS.COM) for his
Xexpertise in the internals of the AT&T UNIX pc kernel.
X
XAfter unpacking the shar file, "su" and become root.  Then type:
X
X	# make install
X
XThis will create the phdaemon executable and copy it into /etc/daemons/.
XThis directory is looked at by /etc/rc apon boot-up to start all system
Xdaemons.  If the directory doesn't exist, it will be created.  Make sure 
Xthe following code is in /etc/rc somewhere:
X
X
Xif [ -d /etc/daemons ]
Xthen
X	DAEMONS=`ls /etc/daemons/*`
X	if [ $? != 0 ] ; then DAEMONS=""; fi
X	for i in $DAEMONS
X	do
X		if [ -x $i ]
X		then	nohup $i > /dev/null 2>&1 &
X		fi
X	done
Xfi
X
XThings to know about the Phone Daemon.  This program is configured
Xfor a multi-line system, where ph0 is the VOICE only line, and ph1 is
Xthe DATA/VOICE line.  The program will need a few revisions to allow
Xto work with a ONE line system.  If someone cares to do this, please
Xmail me the context diffs.
X
XThe program will display:
X
X	DATA 2:IDLE	- obviously when the line is idle.
X	DATA 2:<LOGIN	- Login process (don't know who or what it is yet)
X
X	DATA 2:>PENDING	- A process is going out, not sure what it is.
X	DATA 2:<PENDING	- A process is coming in, not sure what it is.
X
X		The following "user" is in INVERSE video.
X
X	DATA 2:>user	- When a user locks the modem for outgoing calls
X	DATA 2:<user	- When a user locks the modem when coming in.
X	DATA 2:>ph1	- When a user locks (not sure what user) going out
X			  (Generally happens when the user uses the async_main
X			  program to dial out) -- The lock file doesn't reflect
X			  the pid of the locking process. -- POSSIBLE BUG?
X
X		The following "machine" is in BOLD video.
X
X	DATA 2:<UUCICO	- It is a uucico process but don't know what machine
X			  as of yet. (coming in)
X	DATA 2:>machine	- When a uucico process locks modem going out. 
X	DATA 2:<machine	- When a uucico process locks modem coming in. 
X
X---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ---- ----
X
XThe program doesn't allocate another window, it just uses the window 
Xallocated to the /etc/ph process.  This will not waste another window.
X
XThe following parameters can be changed to your liking:
X
X#define	SLEEP	15			/* Sleep time (interval between)*/
X#define	SNOOZE	5			/* Short Sleep time (short time)*/
X#define	NICE	5			/* Niceness value		*/
X
XThe program is set to a nice value of 25, and it sleeps for 15 seconds 
Xbetween checks.  This will keep the process from bogging down the CPU with 
Xwasted cycles.  When there is a "LOGIN or UUCICO" process that is still
Xundetermined, the program will only SNOOZE for 5 seconds, to try to catch
Xwho or what is logging in before they logout.
X
X
XThe following is a table of the programs to determine what kind of process
Xis going using the modem.  The following are my choices, more can be added
Xto match what you system requires.  Each program must have a type for either
X
X			IN_USER		- user login
X			OUT_USER	- user dialing out
X			UUCP		- uucp process
X			LPROCESS	- login process
X
X	{ "sh",		IN_USER },	/* User program when logged in */
X	{ "ksh",	IN_USER },	/* User program when logged in */
X	{ "cu",		OUT_USER },	/* Program used to dial out    */
X	{ "kermit",	OUT_USER },	/* Program used to dial out    */
X	{ "async_main",	OUT_USER },	/* Program used to dial out    */
X	{ "term",	OUT_USER },	/* Program used to dial out    */
X	{ "uucico",	UUCP },		/* UUCP program dial-in/out    */
X	{ "uusched",	UUCP },		/* UUCP program dial-in/out    */
X	{ "login",	LPROCESS },	/* Login process               */
X	{ "getty",	LPROCESS },	/* Login process               */
X	{ "uugetty",	LPROCESS },	/* Login process               */
X	{ "",           PPROCESS },	/* FAILS all cases:   PENDING  */
X
XNote:  term is a program I wrote that acts as a terminal program, I left
Xit there for example purposes.
X
XPlease report any bugs, suggestions and problems to me:
X
X============================ US MAIL:   Lenny Tropiano, ICUS Computer Group
X IIIII   CCC   U   U   SSSS             PO Box 1
X   I    C   C  U   U  S                 Islip Terrace, New York  11752
X   I    C      U   U   SSS   PHONE:     (516) 968-8576 [H] (516) 582-5525 [W] 
X   I    C   C  U   U      S  AT&T MAIL: ...attmail!icus!lenny  TELEX: 154232428
X IIIII   CCC    UUU   SSSS   UUCP:
X============================    ...{uunet!godfre, harvard!talcott}!\
X                         ...{ihnp4, boulder, mtune, skeeve, ptsfa}! >icus!lenny 
X"Usenet the final frontier"        ...{cmcl2!phri, hoptoad}!dasys1!/
END_OF_FILE
if test 4692 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
echo shar: End of shell archive.
exit 0
-- 
Paper-net: Lenny Tropiano          | @-net:         lenny at icus.UUCP
           ICUS Software Systems   | !-net:      ...att    \
           PO Box 1                |                boulder \
           Islip Terrace, NY 11752 |                talcott  !icus!lenny
Vocal-net: (516) 582-5525 [work]   |                pacbell /
           (516) 968-8576 [home]   |                sbcs   /
Telex-net: 154232428 ICUS          | Another-net:   attmail!icus!lenny



More information about the Unix-pc.sources mailing list