From:	SMTP%"ram@acri.fr" 18-FEB-1995 10:53:59.09
To:	USRC
CC:	
Subj:	v47i064: mailagent - Flexible mail filtering and processing package, v3.0, Patch33

Resent-Date: 16 Feb 1995 14:15:03 -0600
Path: decwrl!gossip.pyramid.com!olivea!hookup!newshost.marcam.com!news.mathworks.com!udel!gatech!howland.reston.ans.net!vixen.cso.uiuc.edu!news.ksu.ksu.edu!news.mid.net!news.nde.state.ne.us!nlcnews.nlc.state.ne.us!sparky!not-for-mail
From: ram@acri.fr (Raphael Manfredi)
Newsgroups: comp.sources.misc
Subject: v47i064: mailagent - Flexible mail filtering and processing package, v3.0, Patch33
Followup-To: comp.sources.d
Date: 16 Feb 1995 14:15:03 -0600
Organization: Advanced Computer Research Institute, Lyon, France
Lines: 1818
Sender: kent@sparky.sterling.com
Approved: kent@sparky.sterling.com
Message-Id: <3i0bo7$hpn@sparky.sterling.com>
Nntp-Posting-Host: sparky.sterling.com
X-Md4-Signature: bd68ea9bf708b407ef0313843e6d4bce
To: unix-sources@pa.dec.com
Resent-Message-Id: <"AZmkV1.0._77.5hLHl"@ftp-gw-1.pa.dec.com>
Resent-From: unix-sources@pa.dec.com
X-Mailing-List: <unix-sources@pa.dec.com> archive/latest/487
X-Loop: unix-sources@pa.dec.com
Precedence: list
Resent-Sender: unix-sources-request@pa.dec.com

Submitted-by: ram@acri.fr (Raphael Manfredi)
Posting-number: Volume 47, Issue 64
Archive-name: mailagent/patch33
Environment: UNIX, Perl
Patch-To: mailagent: Volume 41, Issue 1-26

[The latest patch for mailagent version 3.0 is #34.]

System: mailagent version 3.0
Patch #: 33
Priority: LOW
Subject: patch #32, continued
Date: Thu Feb 16 15:58:22 MET 1995
From: Raphael Manfredi <ram@acri.fr>

Description:
	See patch #32.


Fix:	From rn, say "| patch -p -N -d DIR", where DIR is your mailagent source
	directory.  Outside of rn, say "cd DIR; patch -p -N <thisarticle".
	If you don't have the patch program, apply the following by hand,
	or get patch (version 2.0, latest patchlevel).

	After patching:
		*** DO NOTHING--INSTALL ALL PATCHES UP THROUGH #34 FIRST ***

	If patch indicates that patchlevel is the wrong version, you may need
	to apply one or more previous patches, or the patch may already
	have been applied.  See the patchlevel.h file to find out what has or
	has not been applied.  In any event, don't continue with the patch.

	If you are missing previous patches they can be obtained from me:

		Raphael Manfredi <ram@acri.fr>

	If you send a mail message of the following form it will greatly speed
	processing:

		Subject: Command
		@SH mailpatch PATH mailagent 3.0 LIST
			   ^ note the c

	where PATH is a return path FROM ME TO YOU either in Internet notation,
	or in bang notation from some well-known host, and LIST is the number
	of one or more patches you need, separated by spaces, commas, and/or
	hyphens.  Saying 35- says everything from 35 to the end.

	To get some more detailed instructions, send me the following mail:

		Subject: Command
		@SH mailhelp PATH


Index: patchlevel.h
Prereq: 32
4c4
< #define PATCHLEVEL 32
---
> #define PATCHLEVEL 33

Index: Configure
Prereq: 3.0.1.8
*** Configure.old	Thu Feb 16 15:43:30 1995
--- Configure	Thu Feb 16 15:43:31 1995
***************
*** 18,26 ****
  # archive site. Check with Archie if you don't know where that can be.)
  #
  
! # $Id: Configure,v 3.0.1.8 1995/01/25 15:13:16 ram Exp $
  #
! # Generated on Wed Jan 11 17:24:28 MET 1995 [metaconfig 3.0 PL48]
  
  cat >/tmp/c1$$ <<EOF
  ARGGGHHHH!!!!!
--- 18,26 ----
  # archive site. Check with Archie if you don't know where that can be.)
  #
  
! # $Id: Configure,v 3.0.1.9 1995/02/16 14:17:44 ram Exp $
  #
! # Generated on Thu Feb 16 15:14:05 MET 1995 [metaconfig 3.0 PL51]
  
  cat >/tmp/c1$$ <<EOF
  ARGGGHHHH!!!!!
***************
*** 312,317 ****
--- 312,318 ----
  perlpath=''
  pidtype=''
  prefix=''
+ prefixexp=''
  installprivlib=''
  privlib=''
  privlibexp=''
***************
*** 560,567 ****
  silent=''
  extractsh=''
  override=''
! optdef='optdef.sh'
! rm -f $optdef
  
  : option parsing
  while test $# -gt 0; do
--- 561,567 ----
  silent=''
  extractsh=''
  override=''
! rm -f optdef.sh
  
  : option parsing
  while test $# -gt 0; do
***************
*** 593,616 ****
  			echo "$me: ignoring -D $1" >&2
  			;;
  		*=*) echo "$1" | \
! 				sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> $optdef;;
! 		*) echo "$1='define'" >> $optdef;;
  		esac
  		shift
  		;;
  	-U)
  		shift
  		case "$1" in
! 		*=) echo "$1" >> $optdef;;
  		*=*)
  			echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
  			echo "$me: ignoring -U $1" >&2
  			;;
! 		*) echo "$1='undef'" >> $optdef;;
  		esac
  		shift
  		;;
! 	-V) echo "$me generated by metaconfig 3.0 PL48." >&2
  		exit 0;;
  	--) break;;
  	-*) echo "$me: unknown option $1" >&2; shift; error=true;;
--- 593,616 ----
  			echo "$me: ignoring -D $1" >&2
  			;;
  		*=*) echo "$1" | \
! 				sed -e "s/'/'\"'\"'/g" -e "s/=\(.*\)/='\1'/" >> optdef.sh;;
! 		*) echo "$1='define'" >> optdef.sh;;
  		esac
  		shift
  		;;
  	-U)
  		shift
  		case "$1" in
! 		*=) echo "$1" >> optdef.sh;;
  		*=*)
  			echo "$me: use '-D symbol=val', not '-U symbol=val'." >&2
  			echo "$me: ignoring -U $1" >&2
  			;;
! 		*) echo "$1='undef'" >> optdef.sh;;
  		esac
  		shift
  		;;
! 	-V) echo "$me generated by metaconfig 3.0 PL51." >&2
  		exit 0;;
  	--) break;;
  	-*) echo "$me: unknown option $1" >&2; shift; error=true;;
***************
*** 650,657 ****
  esac
  
  : run the defines and the undefines, if any, but leave the file out there...
! touch $optdef
! . ./$optdef
  
  case "$extractsh" in
  true)
--- 650,657 ----
  esac
  
  : run the defines and the undefines, if any, but leave the file out there...
! touch optdef.sh
! . ./optdef.sh
  
  case "$extractsh" in
  true)
***************
*** 664,670 ****
  	echo "Fetching answers from $config_sh..."
  	cd ..
  	. $config
! 	test "$override" && . ./$optdef
  	echo " "
  	. ./UU/extract
  	rm -rf UU
--- 664,670 ----
  	echo "Fetching answers from $config_sh..."
  	cd ..
  	. $config
! 	test "$override" && . ./optdef.sh
  	echo " "
  	. ./UU/extract
  	rm -rf UU
***************
*** 675,687 ****
  
  : set package name
  package=mailagent
  
  : Eunice requires " " instead of "", can you believe it
  echo " "
  : Here we go...
  echo "Beginning of configuration questions for $package."
  
! trap 'echo " "; rm -rf $rmlist; exit 1' 1 2 3 15
  
  : Some greps do not return status, grrr.
  echo "grimblepritz" >grimble
--- 675,693 ----
  
  : set package name
  package=mailagent
+ first=`echo $package | sed -e 's/^\(.\).*/\1/'`
+ last=`echo $package | sed -e 's/^.\(.*\)/\1/'`
+ case "`echo AbyZ | tr '[:lower:]' '[:upper:]' 2>/dev/null`" in
+ ABYZ) spackage=`echo $first | tr '[:lower:]' '[:upper:]'`$last;;
+ *) spackage=`echo $first | tr '[a-z]' '[A-Z]'`$last;;
+ esac
  
  : Eunice requires " " instead of "", can you believe it
  echo " "
  : Here we go...
  echo "Beginning of configuration questions for $package."
  
! trap 'echo " "; test -d ../UU && rm -rf X $rmlist; exit 1' 1 2 3 15
  
  : Some greps do not return status, grrr.
  echo "grimblepritz" >grimble
***************
*** 936,944 ****
  
  Much effort has been expended to ensure that this shell script will run on any
  Unix system.  If despite that it blows up on yours, your best bet is to edit
! Configure and run it again.  Also, let me (ram@acri.fr)
! know how I blew it.  If you can't run Configure for some reason, you'll have to
! generate a config.sh file by hand.
  
  This installation script affects things in two ways:
  
--- 942,950 ----
  
  Much effort has been expended to ensure that this shell script will run on any
  Unix system.  If despite that it blows up on yours, your best bet is to edit
! Configure and run it again.  If you can't run Configure for some reason,
! you'll have to generate a config.sh file by hand.  Whatever problems you
! have, let me (ram@acri.fr) know how I blew it.
  
  This installation script affects things in two ways:
  
***************
*** 1230,1244 ****
  myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
  myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
  	./tr '[A-Z]' '[a-z]' | tr '\012' ' '`
  dflt=n
  if test "$fastread" = yes; then
  	dflt=y
  elif test -f ../config.sh; then
- 	oldmyuname=''
  	if $contains myuname= ../config.sh >/dev/null 2>&1; then
! 		eval "old`grep myuname= ../config.sh`"
  	fi
! 	if test "X$myuname" = "X$oldmyuname"; then
  		dflt=y
  	fi
  fi
--- 1236,1250 ----
  myuname=`( ($uname -a) 2>/dev/null || hostname) 2>&1`
  myuname=`echo $myuname | $sed -e 's/^[^=]*=//' -e 's/\///g' | \
  	./tr '[A-Z]' '[a-z]' | tr '\012' ' '`
+ newmyuname="$myuname"
  dflt=n
  if test "$fastread" = yes; then
  	dflt=y
  elif test -f ../config.sh; then
  	if $contains myuname= ../config.sh >/dev/null 2>&1; then
! 		eval "`grep myuname= ../config.sh`"
  	fi
! 	if test "X$myuname" = "X$newmyuname"; then
  		dflt=y
  	fi
  fi
***************
*** 1256,1262 ****
  		tmp_n="$n"
  		tmp_c="$c"
  		. ../config.sh
- 		test "$override" && . ./$optdef
  		cp ../config.sh .
  		n="$tmp_n"
  		c="$tmp_c"
--- 1262,1267 ----
***************
*** 1274,1286 ****
  	cp $config_sh config.sh 2>/dev/null
  	. ./config.sh
  	cd UU
- 	test "$override" && . ./$optdef
  	cp ../config.sh .
  	n="$tmp_n"
  	c="$tmp_c"
  	hint=previous
  	;;
  esac
  
  : Restore computed paths
  for file in $loclist $trylist; do
--- 1279,1292 ----
  	cp $config_sh config.sh 2>/dev/null
  	. ./config.sh
  	cd UU
  	cp ../config.sh .
  	n="$tmp_n"
  	c="$tmp_c"
  	hint=previous
  	;;
  esac
+ test "$override" && . ./optdef.sh
+ myuname="$newmyuname"
  
  : Restore computed paths
  for file in $loclist $trylist; do
***************
*** 1512,1522 ****
  				fi
  				;;
  			Locate)
! 				if test -d "$value"; then
  					echo "(Looking for $loc_file in directory $value.)"
  					value="$value/$loc_file"
  				fi
! 				if test -f "$value"; then
  					type=''
  				fi
  				case "$nopath_ok" in
--- 1518,1529 ----
  				fi
  				;;
  			Locate)
! 				if test -d "$ansexp"; then
  					echo "(Looking for $loc_file in directory $value.)"
  					value="$value/$loc_file"
+ 					ansexp="$ansexp/$loc_file"
  				fi
! 				if test -f "$ansexp"; then
  					type=''
  				fi
  				case "$nopath_ok" in
***************
*** 2811,2817 ****
  		y*) passcat='nidump passwd .'
  			;;
  		*)	echo "You told me, so don't blame me."
- 			passcat='cat /etc/passwd'
  			;;
  		esac
  		echo " "
--- 2818,2823 ----
***************
*** 2825,2831 ****
  		. ./myread
  		case "$ans" in
  		y*) hostcat='nidump hosts .';;
! 		*) hostcat='cat /etc/hosts';;
  		esac
  	fi
  	case "$passcat" in
--- 2831,2837 ----
  		. ./myread
  		case "$ans" in
  		y*) hostcat='nidump hosts .';;
! 		*) ;;
  		esac
  	fi
  	case "$passcat" in
***************
*** 3943,3958 ****
  *) echo "As you already told me, '$installdir' should work.";;
  esac
  
- : is AFS running?
- echo " "
- if test -d /afs; then
- 	echo "AFS may be running... I'll be extra cautious then..." >&4
- 	afs=true
- else
- 	echo "AFS does not seem to be running..." >&4
- 	afs=false
- fi
- 
  : determine root of directory hierarchy where package will be installed.
  case "$prefix" in
  '')
--- 3949,3954 ----
***************
*** 3971,3997 ****
  binaries. If you wish to have binaries under /bin but manual pages
  under /usr/local/man, that's ok: you will be prompted separately
  for each of the installation directories, the prefix being only used
! to set defaults.
  
  EOM
  fn=d~
  rp='Installation prefix to use?'
  . ./getfile
  prefix="$ans"
  
  : determine where public executables go
  echo " "
! case "$bin" in
! '')
! 	dflt="$prefix/bin"
! 	;;
! *)
! 	dflt="$bin"
! 	;;
! esac
  fn=d~
  rp='Pathname where the public executables will reside?'
  . ./getfile
  bin="$ans"
  binexp="$ansexp"
  if $afs; then
--- 3967,4037 ----
  binaries. If you wish to have binaries under /bin but manual pages
  under /usr/local/man, that's ok: you will be prompted separately
  for each of the installation directories, the prefix being only used
! to set the defaults.
  
  EOM
  fn=d~
  rp='Installation prefix to use?'
  . ./getfile
+ oldprefix=''
+ case "$prefix" in
+ '') ;;
+ *)
+ 	case "$ans" in
+ 	"$prefix") ;;
+ 	*) oldprefix="$prefix";;
+ 	esac
+ 	;;
+ esac
  prefix="$ans"
+ prefixexp="$ansexp"
+ 
+ : set the prefixit variable, to compute a suitable default value
+ prefixit='case "$3" in
+ ""|none)
+ 	case "$oldprefix" in
+ 	"") eval "$1=\"\$$2\"";;
+ 	*)
+ 		case "$3" in
+ 		"") eval "$1=";;
+ 		none)
+ 			eval "tp=\"\$$2\"";
+ 			case "$tp" in
+ 			""|" ") eval "$1=\"\$$2\"";;
+ 			*) eval "$1=";;
+ 			esac;;
+ 		esac;;
+ 	esac;;
+ *)
+ 	eval "tp=\"$oldprefix-\$$2-\""; eval "tp=\"$tp\"";
+ 	case "$tp" in
+ 	--|/*--|\~*--) eval "$1=\"$prefix/$3\"";;
+ 	/*-$oldprefix/*|\~*-$oldprefix/*)
+ 		eval "$1=\`echo \$$2 | sed \"s,^$oldprefix,$prefix,\"\`";;
+ 	*) eval "$1=\"\$$2\"";;
+ 	esac;;
+ esac'
+ 
+ : is AFS running?
+ echo " "
+ if test -d /afs; then
+ 	echo "AFS may be running... I'll be extra cautious then..." >&4
+ 	afs=true
+ else
+ 	echo "AFS does not seem to be running..." >&4
+ 	afs=false
+ fi
  
  : determine where public executables go
  echo " "
! set dflt bin bin
! eval $prefixit
  fn=d~
  rp='Pathname where the public executables will reside?'
  . ./getfile
+ if $test "X$ansexp" != "X$binexp"; then
+ 	installbin=''
+ fi
  bin="$ans"
  binexp="$ansexp"
  if $afs; then
***************
*** 4014,4023 ****
  	installbin="$binexp"
  fi
  
  : determine where manual pages go
  $cat <<EOM
  
! $package has manual pages available in source form.
  EOM
  case "$nroff" in
  nroff)
--- 4054,4071 ----
  	installbin="$binexp"
  fi
  
+ : set the prefixup variable, to restore leading tilda escape
+ prefixup='case "$prefixexp" in
+ "$prefix") ;;
+ *) eval "$1=\`echo \$$1 | sed \"s,^$prefixexp,$prefix,\"\`";;
+ esac'
+ 
  : determine where manual pages go
+ set mansrc mansrc none
+ eval $prefixit
  $cat <<EOM
  
! $spackage has manual pages available in source form.
  EOM
  case "$nroff" in
  nroff)
***************
*** 4029,4046 ****
  echo "If you don't want the manual sources installed, answer 'none'."
  case "$mansrc" in
  '')
! 	lookpath="$prefix/man/man1 $prefix/man/u_man/man1 $prefix/man/l_man/man1"
! 	lookpath="$lookpath /usr/local/man/man1 /usr/local/man/man1 /usr/man/manl"
  	lookpath="$lookpath /usr/man/local/man1 /usr/man/l_man/man1"
  	lookpath="$lookpath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
  	lookpath="$lookpath /usr/man/man.L"
! 	mansrc=`./loc . $prefix/man/man1 $lookpath`
  	if $test -d "$mansrc"; then
  		dflt="$mansrc"
  	else
  		dflt="$sysman"
  	fi
  	;;
  *)  dflt="$mansrc"
  	;;
  esac
--- 4077,4098 ----
  echo "If you don't want the manual sources installed, answer 'none'."
  case "$mansrc" in
  '')
! 	lookpath="$prefixexp/man/man1 $prefixexp/man/u_man/man1"
! 	lookpath="$lookpath $prefixexp/man/l_man/man1"
! 	lookpath="$lookpath /usr/local/man/man1 /opt/man/man1 /usr/man/manl"
  	lookpath="$lookpath /usr/man/local/man1 /usr/man/l_man/man1"
  	lookpath="$lookpath /usr/local/man/u_man/man1 /usr/local/man/l_man/man1"
  	lookpath="$lookpath /usr/man/man.L"
! 	mansrc=`./loc . $prefixexp/man/man1 $lookpath`
  	if $test -d "$mansrc"; then
  		dflt="$mansrc"
  	else
  		dflt="$sysman"
  	fi
+ 	set dflt
+ 	eval $prefixup
  	;;
+ ' ') dflt=none;;
  *)  dflt="$mansrc"
  	;;
  esac
***************
*** 4048,4055 ****
--- 4100,4114 ----
  fn=dn~
  rp='Where do the manual pages (source) go?'
  . ./getfile
+ if test "X$mansrcexp" != "X$ansexp"; then
+ 	installmansrc=''
+ fi
  mansrc="$ans"
  mansrcexp="$ansexp"
+ case "$mansrc" in
+ '') mansrc=' '
+ 	installmansrc='';;
+ esac
  if $afs; then
  	$cat <<EOM
  
***************
*** 4070,4078 ****
  	installmansrc="$mansrcexp"
  fi
  
- 
  case "$mansrc" in
! '') manext='0';;
  *l) manext=l;;
  *n) manext=n;;
  *o) manext=l;;
--- 4129,4136 ----
  	installmansrc="$mansrcexp"
  fi
  
  case "$mansrc" in
! ' ') manext='0';;
  *l) manext=l;;
  *n) manext=n;;
  *o) manext=l;;
***************
*** 4084,4096 ****
  esac
  
  : determine where private executables go
! case "$privlib" in
! '')
! 	dflt=$prefix/lib/$package
! 	;;
! *)  dflt="$privlib"
! 	;;
! esac
  $cat <<EOM
  
  There are some auxiliary files for $package that need to be put into a
--- 4142,4149 ----
  esac
  
  : determine where private executables go
! set dflt privlib lib/$package
! eval $prefixit
  $cat <<EOM
  
  There are some auxiliary files for $package that need to be put into a
***************
*** 4098,4105 ****
  
  EOM
  fn=d~+
! rp='Pathname where private library files will reside?'
  . ./getfile
  privlib="$ans"
  privlibexp="$ansexp"
  if $afs; then
--- 4151,4161 ----
  
  EOM
  fn=d~+
! rp='Pathname where the private library files will reside?'
  . ./getfile
+ if $test "X$privlibexp" != "X$ansexp"; then
+ 	installprivlib=''
+ fi
  privlib="$ans"
  privlibexp="$ansexp"
  if $afs; then
***************
*** 4123,4128 ****
--- 4179,4186 ----
  fi
  
  : determine where public executable scripts go
+ set scriptdir scriptdir
+ eval $prefixit
  case "$scriptdir" in
  '')
  	dflt="$bin"
***************
*** 4130,4136 ****
  	$test -d /usr/share/scripts && dflt=/usr/share/scripts
  	$test -d /usr/share/bin && dflt=/usr/share/bin
  	$test -d /usr/local/script && dflt=/usr/local/script
! 	$test -d $prefix/script && dflt=$prefix/script
  	;;
  *)  dflt="$scriptdir"
  	;;
--- 4188,4196 ----
  	$test -d /usr/share/scripts && dflt=/usr/share/scripts
  	$test -d /usr/share/bin && dflt=/usr/share/bin
  	$test -d /usr/local/script && dflt=/usr/local/script
! 	$test -d $prefixexp/script && dflt=$prefixexp/script
! 	set dflt
! 	eval $prefixup
  	;;
  *)  dflt="$scriptdir"
  	;;
***************
*** 4146,4151 ****
--- 4206,4214 ----
  fn=d~
  rp='Where do you keep publicly executable scripts?'
  . ./getfile
+ if $test "X$ansexp" != "X$scriptdirexp"; then
+ 	installscript=''
+ fi
  scriptdir="$ans"
  scriptdirexp="$ansexp"
  if $afs; then
***************
*** 4617,4627 ****
  $rm -f .foo
  
  : determine root id
- echo " "
  rootid=`$sed -e "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e "q" -e "}" -e "d" </etc/passwd`
  case "$rootid" in
  '') rootid=0 ;;
! *) echo "Root uid = $rootid" >&4 ;;
  esac
  
  : see if signal is declared as pointer to function returning int or void
--- 4680,4689 ----
  $rm -f .foo
  
  : determine root id
  rootid=`$sed -e "/^root:/{s/^[^:]*:[^:]*:\([^:]*\).*"'$'"/\1/" -e "q" -e "}" -e "d" </etc/passwd`
  case "$rootid" in
  '') rootid=0 ;;
! *) echo " "; echo "Root uid = $rootid" >&4 ;;
  esac
  
  : see if signal is declared as pointer to function returning int or void
***************
*** 5341,5554 ****
  # Configured by: $cf_by
  # Target system: $myuname
  
- d_bsd='$d_bsd'
- d_eunice='$d_eunice'
- d_xenix='$d_xenix'
- eunicefix='$eunicefix'
- Mcc='$Mcc'
- awk='$awk'
- bash='$bash'
- bison='$bison'
- byacc='$byacc'
- cat='$cat'
- chgrp='$chgrp'
- chmod='$chmod'
- chown='$chown'
- comm='$comm'
- compress='$compress'
- cp='$cp'
- cpio='$cpio'
- cpp='$cpp'
- csh='$csh'
- date='$date'
- echo='$echo'
- egrep='$egrep'
- emacs='$emacs'
- expr='$expr'
- find='$find'
- flex='$flex'
- gcc='$gcc'
- grep='$grep'
- inews='$inews'
- ksh='$ksh'
- less='$less'
- line='$line'
- lint='$lint'
- ln='$ln'
- lp='$lp'
- lpr='$lpr'
- ls='$ls'
- mail='$mail'
- mailx='$mailx'
- make='$make'
- mkdir='$mkdir'
- more='$more'
- mv='$mv'
- nroff='$nroff'
- perl='$perl'
- pg='$pg'
- pmake='$pmake'
- pr='$pr'
- rm='$rm'
- rmail='$rmail'
- sed='$sed'
- sendmail='$sendmail'
- sh='$sh'
- shar='$shar'
- sleep='$sleep'
- smail='$smail'
- sort='$sort'
- submit='$submit'
- tail='$tail'
- tar='$tar'
- tbl='$tbl'
- test='$test'
- touch='$touch'
- tr='$tr'
- troff='$troff'
- uname='$uname'
- uniq='$uniq'
- uuname='$uuname'
- vi='$vi'
- zcat='$zcat'
- mailpatches='$mailpatches'
- notifypatches='$notifypatches'
- usermail='$usermail'
- hint='$hint'
- myuname='$myuname'
- osname='$osname'
- osvers='$osvers'
  Author='$Author'
  Date='$Date'
  Header='$Header'
  Id='$Id'
  Locker='$Locker'
  Log='$Log'
  RCSfile='$RCSfile'
  Revision='$Revision'
  Source='$Source'
  State='$State'
  afs='$afs'
  baserev='$baserev'
  bin='$bin'
  binexp='$binexp'
! installbin='$installbin'
  cc='$cc'
- gccversion='$gccversion'
  ccflags='$ccflags'
- cppflags='$cppflags'
- ldflags='$ldflags'
- lkflags='$lkflags'
- optimize='$optimize'
- cf_email='$cf_email'
  cf_by='$cf_by'
  cf_time='$cf_time'
  contains='$contains'
  cpplast='$cpplast'
  cppminus='$cppminus'
  cpprun='$cpprun'
  cppstdin='$cppstdin'
  d_bcopy='$d_bcopy'
  d_flock='$d_flock'
! aphostname='$aphostname'
  d_gethname='$d_gethname'
- d_phostname='$d_phostname'
- d_uname='$d_uname'
  d_hidnet='$d_hidnet'
! hiddennet='$hiddennet'
  d_open3='$d_open3'
  d_portable='$d_portable'
  d_rename='$d_rename'
  d_setpgid='$d_setpgid'
- d_bsdpgrp='$d_bsdpgrp'
  d_setpgrp='$d_setpgrp'
  d_setsid='$d_setsid'
  d_strccmp='$d_strccmp'
- d_index='$d_index'
  d_strchr='$d_strchr'
  d_strerrm='$d_strerrm'
  d_strerror='$d_strerror'
  d_sysernlst='$d_sysernlst'
  d_syserrlst='$d_syserrlst'
  d_time='$d_time'
! timetype='$timetype'
  d_uwait3='$d_uwait3'
  d_uwait='$d_uwait'
  d_vfork='$d_vfork'
- usevfork='$usevfork'
  d_voidsig='$d_voidsig'
! signal_t='$signal_t'
  defeditor='$defeditor'
  h_fcntl='$h_fcntl'
  h_sysfile='$h_sysfile'
  i_fcntl='$i_fcntl'
  i_string='$i_string'
- strings='$strings'
  i_sysfile='$i_sysfile'
- d_voidtty='$d_voidtty'
- i_bsdioctl='$i_bsdioctl'
  i_sysfilio='$i_sysfilio'
  i_sysioctl='$i_sysioctl'
- i_syssockio='$i_syssockio'
  i_sysparam='$i_sysparam'
  i_systypes='$i_systypes'
  i_syswait='$i_syswait'
- i_sgtty='$i_sgtty'
  i_termio='$i_termio'
  i_termios='$i_termios'
- i_systime='$i_systime'
- i_systimek='$i_systimek'
  i_time='$i_time'
! timeincl='$timeincl'
  install='$install'
  installdir='$installdir'
  intsize='$intsize'
  libc='$libc'
- glibpth='$glibpth'
  libpth='$libpth'
- plibpth='$plibpth'
- xlibpth='$xlibpth'
  libs='$libs'
  lns='$lns'
  maildir='$maildir'
  maildirexp='$maildirexp'
  mailer='$mailer'
  mailfile='$mailfile'
! installmansrc='$installmansrc'
  manext='$manext'
  mansrc='$mansrc'
  mansrcexp='$mansrcexp'
- d_flockonly='$d_flockonly'
- d_lockflock='$d_lockflock'
- flock_only='$flock_only'
- lock_by_flock='$lock_by_flock'
- mkdep='$mkdep'
- huge='$huge'
- large='$large'
  medium='$medium'
  models='$models'
! small='$small'
! split='$split'
  mydomain='$mydomain'
  myhostname='$myhostname'
! phostname='$phostname'
! c='$c'
  n='$n'
- d_berknames='$d_berknames'
- d_passnames='$d_passnames'
- d_usgnames='$d_usgnames'
  nametype='$nametype'
! groupcat='$groupcat'
! hostcat='$hostcat'
! passcat='$passcat'
  orgname='$orgname'
  package='$package'
! spackage='$spackage'
  patchlevel='$patchlevel'
  perlpath='$perlpath'
  pidtype='$pidtype'
  prefix='$prefix'
! installprivlib='$installprivlib'
  privlib='$privlib'
  privlibexp='$privlibexp'
  prototype='$prototype'
--- 5403,5591 ----
  # Configured by: $cf_by
  # Target system: $myuname
  
  Author='$Author'
  Date='$Date'
  Header='$Header'
  Id='$Id'
  Locker='$Locker'
  Log='$Log'
+ Mcc='$Mcc'
  RCSfile='$RCSfile'
  Revision='$Revision'
  Source='$Source'
  State='$State'
  afs='$afs'
+ aphostname='$aphostname'
+ awk='$awk'
  baserev='$baserev'
+ bash='$bash'
  bin='$bin'
  binexp='$binexp'
! bison='$bison'
! byacc='$byacc'
! c='$c'
! cat='$cat'
  cc='$cc'
  ccflags='$ccflags'
  cf_by='$cf_by'
+ cf_email='$cf_email'
  cf_time='$cf_time'
+ chgrp='$chgrp'
+ chmod='$chmod'
+ chown='$chown'
+ comm='$comm'
+ compress='$compress'
  contains='$contains'
+ cp='$cp'
+ cpio='$cpio'
+ cpp='$cpp'
+ cppflags='$cppflags'
  cpplast='$cpplast'
  cppminus='$cppminus'
  cpprun='$cpprun'
  cppstdin='$cppstdin'
+ csh='$csh'
  d_bcopy='$d_bcopy'
+ d_berknames='$d_berknames'
+ d_bsd='$d_bsd'
+ d_bsdpgrp='$d_bsdpgrp'
+ d_eunice='$d_eunice'
  d_flock='$d_flock'
! d_flockonly='$d_flockonly'
  d_gethname='$d_gethname'
  d_hidnet='$d_hidnet'
! d_index='$d_index'
! d_lockflock='$d_lockflock'
  d_open3='$d_open3'
+ d_passnames='$d_passnames'
+ d_phostname='$d_phostname'
  d_portable='$d_portable'
  d_rename='$d_rename'
  d_setpgid='$d_setpgid'
  d_setpgrp='$d_setpgrp'
  d_setsid='$d_setsid'
  d_strccmp='$d_strccmp'
  d_strchr='$d_strchr'
  d_strerrm='$d_strerrm'
  d_strerror='$d_strerror'
  d_sysernlst='$d_sysernlst'
  d_syserrlst='$d_syserrlst'
  d_time='$d_time'
! d_uname='$d_uname'
! d_usgnames='$d_usgnames'
  d_uwait3='$d_uwait3'
  d_uwait='$d_uwait'
  d_vfork='$d_vfork'
  d_voidsig='$d_voidsig'
! d_voidtty='$d_voidtty'
! d_xenix='$d_xenix'
! date='$date'
  defeditor='$defeditor'
+ defvoidused='$defvoidused'
+ echo='$echo'
+ egrep='$egrep'
+ emacs='$emacs'
+ eunicefix='$eunicefix'
+ expr='$expr'
+ find='$find'
+ flex='$flex'
+ flock_only='$flock_only'
+ gcc='$gcc'
+ gccversion='$gccversion'
+ glibpth='$glibpth'
+ grep='$grep'
+ groupcat='$groupcat'
  h_fcntl='$h_fcntl'
  h_sysfile='$h_sysfile'
+ hiddennet='$hiddennet'
+ hint='$hint'
+ hostcat='$hostcat'
+ huge='$huge'
+ i_bsdioctl='$i_bsdioctl'
  i_fcntl='$i_fcntl'
+ i_sgtty='$i_sgtty'
  i_string='$i_string'
  i_sysfile='$i_sysfile'
  i_sysfilio='$i_sysfilio'
  i_sysioctl='$i_sysioctl'
  i_sysparam='$i_sysparam'
+ i_syssockio='$i_syssockio'
+ i_systime='$i_systime'
+ i_systimek='$i_systimek'
  i_systypes='$i_systypes'
  i_syswait='$i_syswait'
  i_termio='$i_termio'
  i_termios='$i_termios'
  i_time='$i_time'
! incpath='$incpath'
! inews='$inews'
  install='$install'
+ installbin='$installbin'
  installdir='$installdir'
+ installmansrc='$installmansrc'
+ installprivlib='$installprivlib'
+ installscript='$installscript'
  intsize='$intsize'
+ ksh='$ksh'
+ large='$large'
+ ldflags='$ldflags'
+ less='$less'
  libc='$libc'
  libpth='$libpth'
  libs='$libs'
+ line='$line'
+ lint='$lint'
+ lkflags='$lkflags'
+ ln='$ln'
  lns='$lns'
+ lock_by_flock='$lock_by_flock'
+ lp='$lp'
+ lpr='$lpr'
+ ls='$ls'
+ mail='$mail'
  maildir='$maildir'
  maildirexp='$maildirexp'
  mailer='$mailer'
  mailfile='$mailfile'
! mailpatches='$mailpatches'
! mailx='$mailx'
! make='$make'
  manext='$manext'
  mansrc='$mansrc'
  mansrcexp='$mansrcexp'
  medium='$medium'
+ mips='$mips'
+ mips_type='$mips_type'
+ mkdep='$mkdep'
+ mkdir='$mkdir'
  models='$models'
! more='$more'
! mv='$mv'
  mydomain='$mydomain'
  myhostname='$myhostname'
! myuname='$myuname'
  n='$n'
  nametype='$nametype'
! nm_opt='$nm_opt'
! notifypatches='$notifypatches'
! nroff='$nroff'
! optimize='$optimize'
  orgname='$orgname'
+ osname='$osname'
+ osvers='$osvers'
  package='$package'
! passcat='$passcat'
  patchlevel='$patchlevel'
+ perl='$perl'
  perlpath='$perlpath'
+ pg='$pg'
+ phostname='$phostname'
  pidtype='$pidtype'
+ plibpth='$plibpth'
+ pmake='$pmake'
+ pr='$pr'
  prefix='$prefix'
! prefixexp='$prefixexp'
  privlib='$privlib'
  privlibexp='$privlibexp'
  prototype='$prototype'
***************
*** 5569,5596 ****
  reg8='$reg8'
  reg9='$reg9'
  registers='$registers'
  rootid='$rootid'
! installscript='$installscript'
  scriptdir='$scriptdir'
  scriptdirexp='$scriptdirexp'
! so='$so'
  sharpbang='$sharpbang'
  shsharp='$shsharp'
  spitshell='$spitshell'
  startperl='$startperl'
  startsh='$startsh'
  sysman='$sysman'
  uidtype='$uidtype'
! nm_opt='$nm_opt'
! runnm='$runnm'
  usenm='$usenm'
! incpath='$incpath'
! mips='$mips'
! mips_type='$mips_type'
  usrinc='$usrinc'
  utmp='$utmp'
! defvoidused='$defvoidused'
  voidflags='$voidflags'
  EOT
  
  : add special variables
--- 5606,5659 ----
  reg8='$reg8'
  reg9='$reg9'
  registers='$registers'
+ rm='$rm'
+ rmail='$rmail'
  rootid='$rootid'
! runnm='$runnm'
  scriptdir='$scriptdir'
  scriptdirexp='$scriptdirexp'
! sed='$sed'
! sendmail='$sendmail'
! sh='$sh'
! shar='$shar'
  sharpbang='$sharpbang'
  shsharp='$shsharp'
+ signal_t='$signal_t'
+ sleep='$sleep'
+ smail='$smail'
+ small='$small'
+ so='$so'
+ sort='$sort'
+ spackage='$spackage'
  spitshell='$spitshell'
+ split='$split'
  startperl='$startperl'
  startsh='$startsh'
+ strings='$strings'
+ submit='$submit'
  sysman='$sysman'
+ tail='$tail'
+ tar='$tar'
+ tbl='$tbl'
+ test='$test'
+ timeincl='$timeincl'
+ timetype='$timetype'
+ touch='$touch'
+ tr='$tr'
+ troff='$troff'
  uidtype='$uidtype'
! uname='$uname'
! uniq='$uniq'
  usenm='$usenm'
! usermail='$usermail'
! usevfork='$usevfork'
  usrinc='$usrinc'
  utmp='$utmp'
! uuname='$uuname'
! vi='$vi'
  voidflags='$voidflags'
+ xlibpth='$xlibpth'
+ zcat='$zcat'
  EOT
  
  : add special variables
***************
*** 5632,5642 ****
  cont)
  	;;
  '')
- 	echo " "
  	dflt=''
  	nostick=true
! echo "If you didn't make any mistakes, then just type a carriage return here."
! 	rp="If you need to edit config.sh, do it as a shell escape here:"
  	. UU/myread
  	nostick=''
  	case "$ans" in
--- 5695,5709 ----
  cont)
  	;;
  '')
  	dflt=''
  	nostick=true
! 	$cat <<EOM
! 
! If you'd like to make any changes to the config.sh file before I begin
! to configure things, do it as a shell escape now (e.g. !vi config.sh).
! 
! EOM
! 	rp="Press return or use a shell escape to edit config.sh:"
  	. UU/myread
  	nostick=''
  	case "$ans" in

Index: agent/pl/install.pl
*** agent/pl/install.pl.old	Thu Feb 16 15:43:41 1995
--- agent/pl/install.pl	Thu Feb 16 15:43:42 1995
***************
*** 0 ****
--- 1,444 ----
+ ;# $Id: install.pl,v 3.0.1.1 1995/02/16 14:33:13 ram Exp $
+ ;#
+ ;#  Copyright (c) 1990-1993, Raphael Manfredi
+ ;#  
+ ;#  You may redistribute only under the terms of the Artistic License,
+ ;#  as specified in the README file that comes with the distribution.
+ ;#  You may reuse parts of this distribution only within the terms of
+ ;#  that same Artistic License; a copy of which may be found at the root
+ ;#  of the source tree for mailagent 3.0.
+ ;#
+ ;# $Log: install.pl,v $
+ ;# Revision 3.0.1.1  1995/02/16  14:33:13  ram
+ ;# patch32: created
+ ;#
+ ;#
+ ;# This part of the 'cf' package is responsible for setting up a proper config
+ ;# for mailagent to run correctly.
+ ;#
+ ;# The main entry point is &cf'setup. Little information is available at that
+ ;# time, and of course, we do not have any logging. Therefore, messages are
+ ;# printed on stdout.
+ ;#
+ ;# We start by looking for the ~/.mailagent file. If it exists, then we'll
+ ;# have to merge it with newer variables that may have been introduced.
+ ;# The configuration is then loaded and all mandatory directories or files
+ ;# are created.
+ ;#
+ ;# The configured path is also checked to ensure we can find at least perl
+ ;# and mailagent. NB: when creating a ~/.mailagent from scratch, we only
+ ;# configure the path variable, not the p_host one.
+ ;#
+ #
+ # Configuration setup main entry point
+ #
+ 
+ package cf;
+ 
+ # Setup a decent mailagent environment, and returns a proper exit status,
+ # i.e. 0 for success and 1 for failure.
+ sub setup {
+ 	*main'add_log = *main'stdout_log;	# Setup a decent logging routine
+ 
+ 	# To allow for automatic -I testing, we set-up the following two
+ 	# variables specially for the test suite when invoked with the
+ 	# undocumented -TEST option.
+ 
+ 	local($cfset'home);					# Computed HOME directory
+ 	local($cfset'privlib);				# Installed mailagent libdir
+ 	if ($'test_mode) {
+ 		$cfset'home = $ENV{'HOME'};					# agent/test/out
+ 		$cfset'privlib = "$cfset'home/../../files";	# agent/files
+ 	} else {
+ 		$cfset'home = &'tilda_expand('~');
+ 		$cfset'privlib = &'tilda_expand($'privlib);
+ 	}
+ 
+ 	umask(077);							# Default mode: rw for user only!
+ 	$home = $cfset'home;				# Required by &main'tilda...
+ 
+ 	# Setup a default configuration
+ 	unless (&cfset'init) {
+ 		&'add_log("trouble initializing configuration -- help required");
+ 		return 1;
+ 	}
+ 
+ 	# Now load new configuration and perform sanity checks
+ 	&'get_configuration;
+ 	unless (defined $main'loglvl) {
+ 		&'add_log("trouble getting new configuration -- check it up");
+ 		return 1;
+ 	}
+ 
+ 	&cfset'check;		# Check the configuration
+ 	return 0;			# OK
+ }
+ 
+ #
+ # Configuration setup routines
+ #
+ 
+ package cfset;
+ 
+ # Initialize configuration, returning true on success.
+ sub init {
+ 	unless (-d $home) {
+ 		&'add_log("cannot locate home directory -- all I have is '$home'");
+ 		return 0;	# failed
+ 	}
+ 	unless (-w $home) {
+ 		&'add_log("you lack write permissions in $home");
+ 		return 0;	# failed
+ 	}
+ 
+ 	local($pwdhome) = $'test_mode ? $ENV{'HOME'} : (getpwuid($<))[7];
+ 	if (defined $ENV{'HOME'} && $ENV{'HOME'} ne $pwdhome) {
+ 		&'add_log("your HOME environment variable disagrees with /etc/passwd");
+ 		&'add_log("HOME: $ENV{'HOME'}, /etc/passwd: $pwdhome");
+ 	}
+ 
+ 	$ENV{'HOME'} = $home;					# This is set by filter normally
+ 
+ 	return 0 unless &read_setup;			# Get setup.cf for defaults
+ 	return &merge if -e "$home/.mailagent";	# Merge if already exists
+ 
+ 	# Ok, at this point, we need to create a default ~/.mailagent that
+ 	# will enable the user to run mailagent correctly.
+ 
+ 	&'add_log("creating ~/.mailagent...");
+ 
+ 	unless (open(TEMPLATE, "$privlib/mailagent.cf")) {
+ 		&'add_log("cannot open $privlib/mailagent.cf: $!");
+ 		return 0;	# failed
+ 	}
+ 
+ 	unless (open(CONFIG, ">$home/.mailagent")) {
+ 		&'add_log("cannot create $home/.mailagent: $!");
+ 		return 0;	# failed
+ 	}
+ 
+ 	# Build up a default configuratiuon from the mailagent.cf template.
+ 	# If some variables have configured defaults in setup.cf, then use that.
+ 	# Otherwise, copy the line, propagating the "commented out" status.
+ 
+ 	local($_);
+ 	local($c, $var, $sp1, $sp2, $val, $comment);
+ 	while (<TEMPLATE>) {
+ 		if (
+ 			($c, $var, $sp1, $sp2, $val, $comment) =
+ 			/^(#?)(\w+)(\s*):(\s*)([^#\n]*)(#.*)?/
+ 		) {
+ 			next if $var =~ /^p_/;				# Skip p_host examples
+ 			if (defined $Var{$var}) {			# Has a computable default
+ 				($val) = $val =~ m/(\s+)$/;		# Keep spaces before comment
+ 				print CONFIG "$c$var$sp1:$sp2", &dflt($var), "$val$comment\n";
+ 			} else {
+ 				print CONFIG;		# No computable default, print verbatim
+ 			}
+ 		} else {
+ 			print CONFIG;
+ 		}
+ 	}
+ 	close CONFIG;
+ 	close TEMPLATE;
+ }
+ 
+ # Merge existing configuration with possible new variables, returning
+ # true on success. Called from &init, after setup.cf loading when an
+ # existing ~/.mailagent is detected.
+ sub merge {
+ 	local($old) = '.mailagent';
+ 	local($new) = "$old.new";
+ 	local($bak) = "$old.bak";
+ 
+ 	&'add_log("merging ~/.mailagent...");
+ 
+ 	unless (open(OLD, "$home/$old")) {
+ 		&'add_log("cannot open $home/$old: $!");
+ 		return 0;	# failed
+ 	}
+ 
+ 	# Fist pass on old file to get at the currently defined variables
+ 
+ 	local(%seen);		# Records variables in current configuration
+ 	local($_);
+ 	while (<OLD>) {
+ 		$seen{$1}++ if /^#?(\w+)\s*:/;
+ 	}
+ 	seek(OLD, 0, 0);	# Rewind
+ 
+ 	unless (open(TEMPLATE, "$privlib/mailagent.cf")) {
+ 		&'add_log("cannot open $privlib/mailagent.cf: $!");
+ 		return 0;	# failed
+ 	}
+ 
+ 	# Now grab all the "known" variables in the mailagent.cf template.
+ 	# Those tell us about the possible new variables that may have been
+ 	# introduced since  the time ~/.mailagent was first created.
+ 
+ 	local(%known);
+ 	while (<TEMPLATE>) {
+ 		$known{$1}++ if /^#?(\w+)\s*:/;
+ 	}
+ 	seek(TEMPLATE, 0, 0);	# Rewind
+ 
+ 	unless (open(NEW, ">$home/$new")) {
+ 		&'add_log("cannot create $home/$new: $!");
+ 		return 0;	# failed
+ 	}
+ 
+ 	# Start duplicating existing configuration
+ 	while (<OLD>) {
+ 		print NEW;			# Print line verbatim
+ 	}
+ 	close OLD;
+ 
+ 	local(%missing);
+ 	local($missing) = 0;
+ 
+ 	# Look for possible new variables added since last configuration
+ 	foreach $var (keys %known) {
+ 		next if $var =~ /^p_/;				# Skip p_host examples
+ 		$missing{$var}++ unless defined $seen{$var};
+ 		$missing++ unless defined $seen{$var};
+ 	}
+ 
+ 	if ($missing) {
+ 		local($s) = $missing == 1 ? '' : 's';
+ 		&'add_log("adding $missing extra variable$s to ~/.mailagent...");
+ 		print NEW <<EOM;
+ 
+ #
+ # Extra variables added to configuration -- version $'mversion PL$'patchlevel
+ #
+ 
+ EOM
+ 	} else {
+ 		close NEW;
+ 		close TEMPLATE;
+ 		&'add_log("existing configuration was up-to-date");
+ 		unlink("$home/$new") || &'add_log("WARNING can't unlink $new: $!");
+ 		return 1;	# OK
+ 	}
+ 
+ 	# Add all new variables. If they have configured defaults in setup.cf,
+ 	# then use that. Otherwise, copy the line verbatim from the mailagent.cf
+ 	# template. We propagate the "commented out" status as necessary.
+ 
+ 	local($c, $var, $sp1, $sp2, $val, $comment);
+ 	while (<TEMPLATE>) {
+ 		if (
+ 			($c, $var, $sp1, $sp2, $val, $comment) =
+ 			/^(#?)(\w+)(\s*):(\s*)([^#\n]*)(#.*)?/
+ 		) {
+ 			next unless defined $missing{$var};
+ 			if (defined $Var{$var}) {			# Has a computable default
+ 				($val) = $val =~ m/(\s+)$/;		# Keep spaces before comment
+ 				print NEW "$c$var$sp1:$sp2", &dflt($var), "$val$comment\n";
+ 			} else {
+ 				print NEW;		# No computable default, print verbatim
+ 			}
+ 		}
+ 	}
+ 	close NEW;
+ 	close TEMPLATE;
+ 
+ 	local($status) = 1;
+ 
+ 	unless (rename("$home/$old", "$home/$bak")) {
+ 		&'add_log("ERROR unable to rename $old into $bak: $!");
+ 	} else {
+ 		&'add_log("renamed $old into $bak");
+ 	}
+ 
+ 	unless (rename("$home/$new", "$home/$old")) {
+ 		&'add_log("ERROR unable to intall new $old: $!");
+ 		$status = 0;
+ 	} else {
+ 		&'add_log("new $old installed");
+ 	}
+ 
+ 	return $status;	# OK, unless ~/.mailagent not installed
+ }
+ 
+ # Check the current loaded configuration.
+ # We ensure all the required files/directories are there, and that the path
+ # setting on this machine is good enough to locate perl and mailagent.
+ sub check {
+ 	&'add_log("checking your configuration...");
+ 
+ 	# Check file/directory existence and consistency...
+ 	local($path);		# Computed value for given configuration parameter
+ 	local($type);		# File/directory type
+ 	foreach $var (keys %File) {
+ 		eval '$path = $cf' . "'$var";
+ 		&'add_log("ERROR in &cfset'check: $@") if chop($@);
+ 		next if $@ ne '';
+ 		$type = $File{$var};
+ 		next unless $type;
+ 		next if $path eq '' && $type =~ /^[fd]/;	# Missing, but optional
+ 		$path = &'tilda_expand($path);
+ 		if ($type =~ /^[fd]/) {
+ 			&exists($path, $type);		# Check existing file/dir
+ 		} elsif ($path eq '') {
+ 			&'add_log("ERROR mandatory parameter '$var' not defined");
+ 		} else {
+ 			&create($path, $type);		# Create missing file/dir
+ 		}
+ 	}
+ 
+ 	# Check home directory consistency...
+ 	local($pwdhome) = $'test_mode ? $ENV{'HOME'} : (getpwuid($<))[7];
+ 	unless ($pwdhome eq $cf'home) {
+ 		&'add_log("WARNING home config parameter disagrees with /etc/passwd");
+ 		&'add_log("home: $cf'home, /etc/passwd: $pwdhome");
+ 	}
+ 
+ 	# Make sure path setting is correct...
+ 	&path_check;
+ 	&path_check('mailagent');
+ 	&path_check('perl');
+ }
+ 
+ # Get the setup.cf file, and create two data structures:
+ #   %Var:  indexed by variable name, yielding a perl expression to compute
+ #          the default value of that variable.
+ #   %File: indexed by variable name, yields whether it refers to a file
+ #          or a directory. Used to check-up the configuration.
+ # Return true on success.
+ sub read_setup {
+ 	unless (open(SETUP, "$privlib/setup.cf")) {
+ 		&'add_log("cannot open $privlib/setup.cf: $!");
+ 		return 0;	# failed
+ 	}
+ 	local($_);
+ 	while (<SETUP>) {
+ 		next if /^#/;			# Skip comments
+ 		next if /^\s*$/;		# Skip blank lines
+ 		if (/^(\w+)\s*:\s*(.*)/) {			# var: perl-expr
+ 			$Var{$1} = $2;					# specifies a computation for var
+ 		} elsif (/^(\w+)\s*=\s*(.*)/) {		# var= F file
+ 			$File{$1} = $2;					# tells what $var points to
+ 		} else {
+ 			&'add_log("WARNING setup.cf file corrupted at line $.");
+ 		}
+ 	}
+ 	close SETUP;
+ 	return 1;		# OK
+ }
+ 
+ # Compute a default specified by the setup.cf file.
+ sub dflt {
+ 	local($var) = @_;
+ 	local($perl) = $Var{$var};
+ 	local($dflt);
+ 	eval '$dflt = ' . $perl;
+ 	&'add_log("ERROR while computing default for $var: $@") if chop($@);
+ 	return $dflt;
+ }
+ 
+ # Check that a given file/directory is of the correct kind.
+ sub exists {
+ 	local($path, $type) = @_;
+ 	return unless -e $path;
+ 	local($what) = $type =~ /^[Dd]/ ? 'directory' : 'file';
+ 	local($short) = &'tilda($path);
+ 	if ($type =~ /^[Dd]/) {
+ 		&'add_log("ERROR $short is not a directory") unless -d $path;
+ 	} else {
+ 		&'add_log("ERROR $short is not a file") if -d $path;
+ 	}
+ }
+ 
+ # Create file/directory, using type sepcification from the setup.cf file.
+ sub create {
+ 	local($path, $type) = @_;
+ 	return &exists(path, $type) if -e $path;
+ 	local($what) = $type =~ /^D/ ? 'directory' : 'file';
+ 	local($file) = $type =~ /^\w\s*(.*)/;
+ 	local($from) = $file ? "from default $file" : '(empty)';
+ 	local($short) = &'tilda($path);
+ 	&'add_log("creating mandatory $what $short $from");
+ 	if ($type =~ /^D/) {
+ 		&'makedir($path);
+ 	} else {
+ 		local($dir, $base) = $path =~ m|(.*)/(.*)|;
+ 		&'makedir($dir);
+ 		unless (open(BASE, ">$dir/$base")) {
+ 			&'add_log("ERROR cannot create $dir/$base: $!") if $cf'level;
+ 			return;
+ 		}
+ 		if ($file && !open(FILE, "$privlib/$file")) {
+ 			&'add_log("ERROR cannot open $privlib/$file: $!") if $cf'level;
+ 		} else {
+ 			local($_);
+ 			while (<FILE>) {
+ 				print BASE;
+ 			}
+ 			close FILE;
+ 		}
+ 		close BASE;
+ 	}
+ }
+ 
+ # Check path setting.
+ # Without any argument, simply checks that each path directory is correct.
+ # Otherwise, try to locate the argument within the path.
+ sub path_check {
+ 	local($prog) = @_;
+ 	local($host) = &'hostname;
+ 	$host =~ s/^(\w+).*/$1/;		# Trim domain name
+ 	local($lpath);					# Value of local path (p_host)
+ 	eval '$lpath = $cf' . "'p_$host";
+ 	&'add_log("ERROR in cfset'path_check: $@") if chop($@);
+ 
+ 	local($direxp);		# Expanded version of the directory
+ 	local($found) = 0;
+ 	foreach $dir (split(/:/, "$lpath:$cf'path")) {
+ 		next if $dir eq '';
+ 		$direxp = &'tilda_expand($dir);
+ 		unless (defined $prog || -d $direxp) {
+ 			&'add_log("WARNING path component '$dir' not found!");
+ 		}
+ 		if (defined $prog && -e "$direxp/$prog" && -x _ && !-d _) {
+ 			$found++;
+ 			last;
+ 		}
+ 	}
+ 	&'add_log("WARNING cannot locate '$prog' in set-up path")
+ 		if defined($prog) && !$found;
+ }
+ 
+ # Compute a suitable default path and return it. We try to include directories
+ # under the user home directory, and directories containing some programs
+ # like 'ls', 'pg', 'perl' and 'mailagent'.
+ # NB: This routine is not called directly but via setup.cf and &dflt.
+ sub default_path {
+ 	local($path) = '';		# The build-up path
+ 	local($short);			# Path with tilda substitution
+ 	foreach $dir (split(/:/, $ENV{'PATH'})) {
+ 		next if $dir eq '' || $dir =~ /^\.\.?$/;
+ 		$short = &'tilda($dir);
+ 		if ($short ne $dir) {
+ 			$path .= "$short:";
+ 			next;
+ 		}
+ 		$path .= "$dir:" if &contains($dir, 'ls', 'pg', 'perl', 'mailagent');
+ 	}
+ 	chop($path);			# Remove trailing ':'
+ 	return $path;
+ }
+ 
+ # Returns true if the specified dir exists, has the x bit set and contains
+ # one of the specified programs.
+ sub contains {
+ 	local($dir, @progs) = @_;
+ 	return 0 if !-d $dir || !-x _;
+ 	foreach $prog (@progs) {
+ 		return 1 if -e "$dir/$prog" && -x _;
+ 	}
+ 	return 0;	# Not found
+ }
+ 
+ package main;
+ 

Index: agent/magent.sh
Prereq: 3.0.1.7
*** agent/magent.sh.old	Thu Feb 16 15:43:36 1995
--- agent/magent.sh	Thu Feb 16 15:43:36 1995
***************
*** 24,30 ****
  # via the filter. Mine looks like this:
  #   "|exec /users/ram/mail/filter >>/users/ram/.bak 2>&1"
  
! # $Id: magent.sh,v 3.0.1.7 1995/02/03 17:57:16 ram Exp $
  #
  #  Copyright (c) 1990-1993, Raphael Manfredi
  #  
--- 24,30 ----
  # via the filter. Mine looks like this:
  #   "|exec /users/ram/mail/filter >>/users/ram/.bak 2>&1"
  
! # $Id: magent.sh,v 3.0.1.8 1995/02/16 14:24:42 ram Exp $
  #
  #  Copyright (c) 1990-1993, Raphael Manfredi
  #  
***************
*** 35,40 ****
--- 35,44 ----
  #  of the source tree for mailagent 3.0.
  #
  # $Log: magent.sh,v $
+ # Revision 3.0.1.8  1995/02/16  14:24:42  ram
+ # patch32: new -I option for installation setup and checking
+ # patch32: usage message now sorts options by case type
+ #
  # Revision 3.0.1.7  1995/02/03  17:57:16  ram
  # patch30: also select hot piping on stderr to avoid problems on fork
  #
***************
*** 189,194 ****
--- 193,202 ----
  	elsif ($_ eq '-F') {	# Force processing, even if already seen
  		++$force_seen;
  	}
+ 	elsif ($_ eq '-I') {	# Install a suitable mailagent environment...
+ 		++$has_option;		# That option must be the only one specified
+ 		++$install_me;
+ 	}
  	elsif ($_ eq '-L') {	# Specify new logging level
  		$log_level = int(shift);
  	}
***************
*** 213,218 ****
--- 221,228 ----
  	exit 1;
  }
  
+ exit(&cf'setup) if $install_me;	# Get a suitable configuration if -I
+ 
  $file_name = shift;				# File name to be processed (null if stdin)
  $ENV{'IFS'}='' if $ENV{'IFS'};	# Shell separation field
  &init_constants;				# Constants definitions
***************
*** 353,374 ****
  # Print usage and exit
  sub usage {
  	print STDERR <<EOF;
! Usage: $prog_name [-dFhilqtV] [-s{umary}] [-f file] [-e rules] [-c config]
         [-L level] [-r file] [-o def] [mailfile]
    -c : specify alternate configuration file.
    -d : dump filter rules (special).
    -e : enter rules to be applied.
    -f : get messages from UNIX-style mailbox file.
-   -F : force processing on already filtered messages.
    -h : print this help message and exits.
    -i : interactive usage -- print log messages on stderr.
    -l : list message queue (special).
-   -L : force logging level.
    -o : overwrite config file with supplied definition.
    -q : process the queue (special).
    -r : sepcify alternate rule file.
    -s : report gathered statistics (special).
    -t : track rules on stdout.
    -V : print version number and exits.
  EOF
  	exit 1;
--- 363,385 ----
  # Print usage and exit
  sub usage {
  	print STDERR <<EOF;
! Usage: $prog_name [-dhilqtFIV] [-s{umary}] [-f file] [-e rules] [-c config]
         [-L level] [-r file] [-o def] [mailfile]
    -c : specify alternate configuration file.
    -d : dump filter rules (special).
    -e : enter rules to be applied.
    -f : get messages from UNIX-style mailbox file.
    -h : print this help message and exits.
    -i : interactive usage -- print log messages on stderr.
    -l : list message queue (special).
    -o : overwrite config file with supplied definition.
    -q : process the queue (special).
    -r : sepcify alternate rule file.
    -s : report gathered statistics (special).
    -t : track rules on stdout.
+   -F : force processing on already filtered messages.
+   -I : install configuration and perform sanity checks.
+   -L : force logging level.
    -V : print version number and exits.
  EOF
  	exit 1;
***************
*** 673,677 ****
--- 684,689 ----
  $grep -v '^;#' pl/biff.pl >>magent
  $grep -v '^;#' pl/rulenv.pl >>magent
  $grep -v '^;#' pl/options.pl >>magent
+ $grep -v '^;#' pl/install.pl >>magent
  chmod 755 magent
  $eunicefix magent

*** End of Patch 33 ***

exit 0 # Just in case...

