home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-12-03 | 54.7 KB | 1,717 lines |
- Newsgroups: comp.sources.misc
- From: Raphael Manfredi <ram@acri.fr>
- Subject: v41i021: mailagent - Flexible mail filtering and processing package, v3.0, Part21/26
- Message-ID: <1993Dec3.213510.22993@sparky.sterling.com>
- X-Md4-Signature: 3c5d388e6d8c5962220eea2d4b3b6c42
- Sender: kent@sparky.sterling.com (Kent Landfield)
- Organization: Advanced Computer Research Institute, Lyon, France.
- Date: Fri, 3 Dec 1993 21:35:10 GMT
- Approved: kent@sparky.sterling.com
-
- Submitted-by: Raphael Manfredi <ram@acri.fr>
- Posting-number: Volume 41, Issue 21
- Archive-name: mailagent/part21
- Environment: UNIX, Perl
- Supersedes: mailagent: Volume 33, Issue 93-109
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then feed it
- # into a shell via "sh file" or similar. To overwrite existing files,
- # type "sh file -c".
- # The tool that generated this appeared in the comp.sources.unix newsgroup;
- # send mail to comp-sources-unix@uunet.uu.net if you want that tool.
- # Contents: agent/files/help/newpower.SH agent/files/help/release.SH
- # agent/files/help/user.SH agent/filter/hash.h agent/filter/msg.c
- # agent/filter/user.c agent/mailhelp.SH agent/pl/include.pl
- # agent/pl/mailhook.pl agent/pl/once.pl agent/test/basic/filter.t
- # agent/test/cmd/keep.t agent/test/cmd/once.t
- # agent/test/cmd/record.t agent/test/cmd/store.t
- # agent/test/cmd/strip.t agent/test/cmd/unique.t
- # agent/test/cmd/write.t agent/test/misc/mh.t
- # agent/test/misc/newcmd.t agent/test/option/s.t misc/unkit/rules
- # Wrapped by ram@soft208 on Mon Nov 29 16:49:57 1993
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- echo If this archive is complete, you will see the following message:
- echo ' "shar: End of archive 21 (of 26)."'
- if test -f 'agent/files/help/newpower.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/files/help/newpower.SH'\"
- else
- echo shar: Extracting \"'agent/files/help/newpower.SH'\" \(1900 characters\)
- sed "s/^X//" >'agent/files/help/newpower.SH' <<'END_OF_FILE'
- Xcase $CONFIG in
- X'')
- X if test -f config.sh; then TOP=.;
- X elif test -f ../config.sh; then TOP=..;
- X elif test -f ../../config.sh; then TOP=../..;
- X elif test -f ../../../config.sh; then TOP=../../..;
- X elif test -f ../../../../config.sh; then TOP=../../../..;
- X else
- X echo "Can't find config.sh."; exit 1
- X fi
- X . $TOP/config.sh
- X ;;
- Xesac
- Xcase "$0" in
- X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
- Xesac
- Xecho "Extracting agent/files/help/newpower (with variable substitutions)"
- X$spitshell >/dev/null <<!GROK!THIS!
- X# $Id: newpower.SH,v 3.0 1993/11/29 13:47:57 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: newpower.SH,v $
- X# Revision 3.0 1993/11/29 13:47:57 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X!GROK!THIS!
- X$spitshell >newpower <<'!NO!SUBS!'
- XNAME
- X
- X newpower -- Adds a new power to the system
- X
- XSYNOPSIS
- X
- X newpower power password [alias]
- X ... users ...
- X EOF
- X
- XDESCRIPTION
- X
- XThis command creates a new server power and assigns a password to protect it.
- XIf the power name is longer than 12 characters, you may specify an alias for
- Xthat power, which will be used internally by mailagent to reference it, or
- Xleave the field blank and mailagent will generate one for you.
- X
- XThe 'system' power is normally required to create a new power. The 'security'
- Xpower is required to create the root power and the 'root' power is needed to
- Xcreate 'security'. In order to bootstrap either power, please refer to the
- Xmailagent manual page where this is explained in detail.
- X
- XEXAMPLE
- X
- X newpower list-power mypasswd
- X ram@acri.fr
- X ram@eiffel.com
- X EOF
- X!NO!SUBS!
- Xchmod 644 newpower
- END_OF_FILE
- if test 1900 -ne `wc -c <'agent/files/help/newpower.SH'`; then
- echo shar: \"'agent/files/help/newpower.SH'\" unpacked with wrong size!
- fi
- chmod +x 'agent/files/help/newpower.SH'
- # end of 'agent/files/help/newpower.SH'
- fi
- if test -f 'agent/files/help/release.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/files/help/release.SH'\"
- else
- echo shar: Extracting \"'agent/files/help/release.SH'\" \(1745 characters\)
- sed "s/^X//" >'agent/files/help/release.SH' <<'END_OF_FILE'
- Xcase $CONFIG in
- X'')
- X if test -f config.sh; then TOP=.;
- X elif test -f ../config.sh; then TOP=..;
- X elif test -f ../../config.sh; then TOP=../..;
- X elif test -f ../../../config.sh; then TOP=../../..;
- X elif test -f ../../../../config.sh; then TOP=../../../..;
- X else
- X echo "Can't find config.sh."; exit 1
- X fi
- X . $TOP/config.sh
- X ;;
- Xesac
- Xcase "$0" in
- X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
- Xesac
- Xecho "Extracting agent/files/help/release (with variable substitutions)"
- X$spitshell >/dev/null <<!GROK!THIS!
- X# $Id: release.SH,v 3.0 1993/11/29 13:47:58 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: release.SH,v $
- X# Revision 3.0 1993/11/29 13:47:58 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X!GROK!THIS!
- X$spitshell >release <<'!NO!SUBS!'
- XNAME
- X
- X release -- Releases power
- X
- XSYNOPSIS
- X
- X release name
- X
- XDESCRIPTION
- X
- XThis command releases the specified power.
- X
- XIf the 'root' power is releases, other powers obtained while root or before
- Xare kept. That way, it makes sense to ask for powers while root, when the
- Xpassword for some minor power has been change, since you do not need to
- Xsupply it. Then 'root' may be released and the work continued with the
- Xminor power handy.
- X
- XIt is not recommend to run an entire session with 'root' privileges, unless
- Xneeded to bypass some restrictions like the maximum number of commands that
- Xmay be issued in a session.
- X
- XEXAMPLE
- X
- X release list
- X!NO!SUBS!
- Xchmod 644 release
- END_OF_FILE
- if test 1745 -ne `wc -c <'agent/files/help/release.SH'`; then
- echo shar: \"'agent/files/help/release.SH'\" unpacked with wrong size!
- fi
- chmod +x 'agent/files/help/release.SH'
- # end of 'agent/files/help/release.SH'
- fi
- if test -f 'agent/files/help/user.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/files/help/user.SH'\"
- else
- echo shar: Extracting \"'agent/files/help/user.SH'\" \(1958 characters\)
- sed "s/^X//" >'agent/files/help/user.SH' <<'END_OF_FILE'
- Xcase $CONFIG in
- X'')
- X if test -f config.sh; then TOP=.;
- X elif test -f ../config.sh; then TOP=..;
- X elif test -f ../../config.sh; then TOP=../..;
- X elif test -f ../../../config.sh; then TOP=../../..;
- X elif test -f ../../../../config.sh; then TOP=../../../..;
- X else
- X echo "Can't find config.sh."; exit 1
- X fi
- X . $TOP/config.sh
- X ;;
- Xesac
- Xcase "$0" in
- X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
- Xesac
- Xecho "Extracting agent/files/help/user (with variable substitutions)"
- X$spitshell >/dev/null <<!GROK!THIS!
- X# $Id: user.SH,v 3.0 1993/11/29 13:48:01 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: user.SH,v $
- X# Revision 3.0 1993/11/29 13:48:01 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X!GROK!THIS!
- X$spitshell >user <<'!NO!SUBS!'
- XNAME
- X
- X user -- Runs a command on behalf of another user
- X
- XSYNOPSIS
- X
- X user [name [command]]
- X
- XDESCRIPTION
- X
- XThis command may be used to execute some other commands on behalf of a user.
- X
- XIf a command is specified, it is immediately executed under the new identity
- X(which is merely an e-mail address), and that new identity only lasts for
- Xthat single command. Otherwise, the remaining commands are executed with the
- Xnew identity.
- X
- XIf no user name is specified, the original sender identity is restored.
- X
- XAll the powers are lost when the 'user' command is executed, but this is
- Xonly temporary when a command is specified on the same line.
- X
- XNote that it is up to the command to make use of this "effective" user
- Xidentity, by looking at the proper environment variables.
- X
- XEXAMPLES
- X
- X user root@acri.fr
- X ... some commands ...
- X user
- X user ram@acri.fr subscribe agent-users
- X!NO!SUBS!
- Xchmod 644 user
- END_OF_FILE
- if test 1958 -ne `wc -c <'agent/files/help/user.SH'`; then
- echo shar: \"'agent/files/help/user.SH'\" unpacked with wrong size!
- fi
- chmod +x 'agent/files/help/user.SH'
- # end of 'agent/files/help/user.SH'
- fi
- if test -f 'agent/filter/hash.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/filter/hash.h'\"
- else
- echo shar: Extracting \"'agent/filter/hash.h'\" \(1960 characters\)
- sed "s/^X//" >'agent/filter/hash.h' <<'END_OF_FILE'
- X/*
- X
- X # # ## #### # # # #
- X # # # # # # # # #
- X ###### # # #### ###### ######
- X # # ###### # # # ### # #
- X # # # # # # # # ### # #
- X # # # # #### # # ### # #
- X
- X Declarations for hash table.
- X*/
- X
- X/*
- X * $Id: hash.h,v 3.0 1993/11/29 13:48:09 ram Exp ram $
- X *
- X * Copyright (c) 1990-1993, Raphael Manfredi
- X *
- X * You may redistribute only under the terms of the Artistic License,
- X * as specified in the README file that comes with the distribution.
- X * You may reuse parts of this distribution only within the terms of
- X * that same Artistic License; a copy of which may be found at the root
- X * of the source tree for mailagent 3.0.
- X *
- X * $Log: hash.h,v $
- X * Revision 3.0 1993/11/29 13:48:09 ram
- X * Baseline for mailagent 3.0 netwide release.
- X *
- X */
- X
- X#ifndef _hash_h
- X#define _hash_h
- X
- X/* Structure which describes the hash table: array of keys and array of
- X * values, along with the table's size and the number of recorded elements.
- X */
- Xstruct htable {
- X int32 h_size; /* Size of table (prime number) */
- X int32 h_items; /* Number of items recorded in table */
- X char **h_keys; /* Array of keys (strings) */
- X int h_pos; /* Last position in table (iterations) */
- X char **h_values; /* Array of values (strings) */
- X};
- X
- X/* Function declaration */
- Xextern int ht_create(); /* Create H table */
- Xextern char *ht_value(); /* Get value given some key */
- Xextern char *ht_put(); /* Insert value in H table */
- Xextern char *ht_force(); /* Like ht_put, but replace old value */
- Xextern int ht_xtend(); /* Extend size of full H table */
- Xextern int ht_start(); /* Start iteration over H table */
- Xextern int ht_next(); /* Go to next item in H table */
- Xextern char *ht_ckey(); /* Fetch current key */
- Xextern char *ht_cvalue(); /* Fetch current value */
- Xextern int ht_count(); /* Number of items in H table */
- X
- X#endif
- END_OF_FILE
- if test 1960 -ne `wc -c <'agent/filter/hash.h'`; then
- echo shar: \"'agent/filter/hash.h'\" unpacked with wrong size!
- fi
- # end of 'agent/filter/hash.h'
- fi
- if test -f 'agent/filter/msg.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/filter/msg.c'\"
- else
- echo shar: Extracting \"'agent/filter/msg.c'\" \(1957 characters\)
- sed "s/^X//" >'agent/filter/msg.c' <<'END_OF_FILE'
- X/*
- X
- X # # #### #### ####
- X ## ## # # # # #
- X # ## # #### # #
- X # # # # ### ### #
- X # # # # # # ### # #
- X # # #### #### ### ####
- X
- X Fatal messages.
- X*/
- X
- X/*
- X * $Id: msg.c,v 3.0 1993/11/29 13:48:17 ram Exp ram $
- X *
- X * Copyright (c) 1990-1993, Raphael Manfredi
- X *
- X * You may redistribute only under the terms of the Artistic License,
- X * as specified in the README file that comes with the distribution.
- X * You may reuse parts of this distribution only within the terms of
- X * that same Artistic License; a copy of which may be found at the root
- X * of the source tree for mailagent 3.0.
- X *
- X * $Log: msg.c,v $
- X * Revision 3.0 1993/11/29 13:48:17 ram
- X * Baseline for mailagent 3.0 netwide release.
- X *
- X */
- X
- X#include "config.h"
- X#include "portable.h"
- X#include <stdio.h>
- X#include <sys/types.h>
- X#include "sysexits.h"
- X#include "logfile.h"
- X#include "lock.h"
- X#include "io.h"
- X#include "confmagic.h"
- X
- X#define MAX_STRING 1024 /* Maximum length for error string */
- X
- X/* VARARGS2 */
- Xpublic void fatal(reason, arg1, arg2, arg3, arg4, arg5)
- Xchar *reason;
- Xint arg1, arg2, arg3, arg4, arg5;
- X{
- X /* Fatal error -- die with a meaningful error status for sendmail. If the
- X * logfile has been opened, the reason will also be logged there.
- X */
- X char buffer[MAX_STRING];
- X int status; /* Status from emergency_save() */
- X
- X status = emergency_save(); /* Attempt emergency saving */
- X
- X fprintf(stderr, "%s: ", progname);
- X fprintf(stderr, reason, arg1, arg2, arg3, arg4, arg5);
- X fputc('\n', stderr);
- X sprintf(buffer, "FATAL %s", reason);
- X add_log(1, buffer, arg1, arg2, arg3, arg4, arg5);
- X release_lock();
- X
- X if (!was_queued()) {
- X add_log(6, "NOTICE leaving mail in MTA's queue");
- X exit(EX_TEMPFAIL);
- X } else if (status == -1) {
- X add_log(5, "WARNING no saving was ever done");
- X add_log(6, "NOTICE leaving mail in MTA's queue");
- X exit(EX_TEMPFAIL);
- X }
- X
- X exit(EX_OK);
- X}
- X
- END_OF_FILE
- if test 1957 -ne `wc -c <'agent/filter/msg.c'`; then
- echo shar: \"'agent/filter/msg.c'\" unpacked with wrong size!
- fi
- # end of 'agent/filter/msg.c'
- fi
- if test -f 'agent/filter/user.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/filter/user.c'\"
- else
- echo shar: Extracting \"'agent/filter/user.c'\" \(1915 characters\)
- sed "s/^X//" >'agent/filter/user.c' <<'END_OF_FILE'
- X/*
- X
- X # # #### ###### ##### ####
- X # # # # # # # #
- X # # #### ##### # # #
- X # # # # ##### ### #
- X # # # # # # # ### # #
- X #### #### ###### # # ### ####
- X
- X Compute user login name.
- X*/
- X
- X/*
- X * $Id: user.c,v 3.0 1993/11/29 13:48:21 ram Exp ram $
- X *
- X * Copyright (c) 1990-1993, Raphael Manfredi
- X *
- X * You may redistribute only under the terms of the Artistic License,
- X * as specified in the README file that comes with the distribution.
- X * You may reuse parts of this distribution only within the terms of
- X * that same Artistic License; a copy of which may be found at the root
- X * of the source tree for mailagent 3.0.
- X *
- X * $Log: user.c,v $
- X * Revision 3.0 1993/11/29 13:48:21 ram
- X * Baseline for mailagent 3.0 netwide release.
- X *
- X */
- X
- X#include "config.h"
- X#include "portable.h"
- X#include <sys/types.h> /* For uid_t */
- X#include <pwd.h>
- X
- X#ifdef I_STRING
- X#include <string.h>
- X#else
- X#include <strings.h>
- X#endif
- X#include "confmagic.h"
- X
- X#define LOGIN_LEN 8 /* Maximum login name length */
- X
- Xextern struct passwd *getpwuid(); /* Get password entry for UID */
- Xextern Uid_t geteuid(); /* Effective user UID */
- X
- Xpublic char *logname()
- X{
- X /* Return pointer to static data holding the user login name. Note that we
- X * look-up in /etc/passwd. Hence, if the user has duplicate entries in the
- X * file, the first one will be reported. This may or may not bother you.
- X * NB: we use the *effective* user ID, not the real one.
- X */
- X
- X static char login[LOGIN_LEN + 1]; /* Where login name is stored */
- X struct passwd *pw; /* Pointer to password entry */
- X
- X pw = getpwuid(geteuid()); /* Get first entry matching UID */
- X if (pw == (struct passwd *) 0)
- X return (char *) 0; /* User not found */
- X
- X strncpy(login, pw->pw_name, LOGIN_LEN);
- X login[LOGIN_LEN] = '\0';
- X
- X return login;
- X}
- X
- END_OF_FILE
- if test 1915 -ne `wc -c <'agent/filter/user.c'`; then
- echo shar: \"'agent/filter/user.c'\" unpacked with wrong size!
- fi
- # end of 'agent/filter/user.c'
- fi
- if test -f 'agent/mailhelp.SH' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/mailhelp.SH'\"
- else
- echo shar: Extracting \"'agent/mailhelp.SH'\" \(2462 characters\)
- sed "s/^X//" >'agent/mailhelp.SH' <<'END_OF_FILE'
- Xcase $CONFIG in
- X'')
- X if test -f config.sh; then TOP=.;
- X elif test -f ../config.sh; then TOP=..;
- X elif test -f ../../config.sh; then TOP=../..;
- X elif test -f ../../../config.sh; then TOP=../../..;
- X elif test -f ../../../../config.sh; then TOP=../../../..;
- X else
- X echo "Can't find config.sh."; exit 1
- X fi
- X . $TOP/config.sh
- X ;;
- Xesac
- Xcase "$0" in
- X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
- Xesac
- Xecho "Extracting agent/mailhelp (with variable substitutions)"
- X$spitshell >mailhelp <<!GROK!THIS!
- X$startperl
- X eval "exec perl -S \$0 \$*"
- X if \$running_under_some_shell;
- X
- X# $Id: mailhelp.SH,v 3.0 1993/11/29 13:48:23 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: mailhelp.SH,v $
- X# Revision 3.0 1993/11/29 13:48:23 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- X\$mversion = '$VERSION';
- X\$patchlevel = '$PATCHLEVEL';
- X!GROK!THIS!
- X
- X$spitshell >>mailhelp <<'!NO!SUBS!'
- X
- X$prog_name = $0; # Who I am
- X$prog_name =~ s|^.*/(.*)|$1|; # Keep only base name
- X
- X&read_config; # First, read configuration file (in ~/.mailagent)
- X
- X# take job number and command from environment
- X# (passed by mailagent)
- X$jobnum = $ENV{'jobnum'};
- X$fullcmd = $ENV{'fullcmd'};
- X
- X$dest=shift; # Who should the help be sent to
- X$dest = $ENV{'path'} if $dest eq ''; # If dest was ommitted
- X
- X# A single '-' as first argument stands for return path
- X$dest = $ENV{'path'} if $dest eq '-';
- X
- Xopen(HELP, "$cf'spool/agenthelp") || &fatal("no help file!\n");
- Xopen(MAILER, "|$cf'sendmail $cf'mailopt $dest");
- Xprint MAILER
- X"To: $dest
- XSubject: How to use my mail agent
- XX-Mailer: mailagent [version $mversion PL$patchlevel]
- X
- X";
- Xwhile (<HELP>) {
- X # Replace some tokens by parameters
- X s/=DEST=/$dest/g;
- X s/=MAXSIZE=/$cf'maxsize/g;
- X print MAILER;
- X}
- Xprint MAILER
- X"
- X-- $prog_name speaking for $cf'user
- X";
- Xclose MAILER;
- Xif ($?) {
- X &add_log("ERROR couldn't send help to $dest") if $loglvl > 0;
- X} else {
- X &add_log("SENT help to $dest") if $loglvl > 2;
- X}
- Xclose HELP;
- X
- X!NO!SUBS!
- X$grep -v '^;#' pl/fatal.pl >>mailhelp
- X$grep -v '^;#' pl/add_log.pl >>mailhelp
- X$grep -v '^;#' pl/read_conf.pl >>mailhelp
- X$grep -v '^;#' pl/secure.pl >>mailhelp
- Xchmod 755 mailhelp
- X$eunicefix mailhelp
- END_OF_FILE
- if test 2462 -ne `wc -c <'agent/mailhelp.SH'`; then
- echo shar: \"'agent/mailhelp.SH'\" unpacked with wrong size!
- fi
- chmod +x 'agent/mailhelp.SH'
- # end of 'agent/mailhelp.SH'
- fi
- if test -f 'agent/pl/include.pl' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/pl/include.pl'\"
- else
- echo shar: Extracting \"'agent/pl/include.pl'\" \(1799 characters\)
- sed "s/^X//" >'agent/pl/include.pl' <<'END_OF_FILE'
- X;# $Id: include.pl,v 3.0 1993/11/29 13:48:52 ram Exp ram $
- X;#
- X;# Copyright (c) 1990-1993, Raphael Manfredi
- X;#
- X;# You may redistribute only under the terms of the Artistic License,
- X;# as specified in the README file that comes with the distribution.
- X;# You may reuse parts of this distribution only within the terms of
- X;# that same Artistic License; a copy of which may be found at the root
- X;# of the source tree for mailagent 3.0.
- X;#
- X;# $Log: include.pl,v $
- X;# Revision 3.0 1993/11/29 13:48:52 ram
- X;# Baseline for mailagent 3.0 netwide release.
- X;#
- X;#
- X# Process "include-file" requests. The file is allowed to have shell comments
- X# and leading spaces are trimmed. The function returns an array, each item
- X# being one of the non-comment lines found in the file.
- Xsub include_file {
- X local($inc) = shift(@_); # Include request "file-name"
- X local($what) = shift(@_); # What we are looking for (singular)
- X local(*INCLUDE); # Local file handle
- X local($filename) = $inc =~ /^"(.*)"$/;
- X local(@result);
- X local($_);
- X # Find file using mailfilter, maildir variables if not specified with an
- X # absolute pathname (starting iwht a '/').
- X $filename = &locate_file($filename);
- X &add_log("loading ".&plural($what)." from $filename") if $loglvl > 18;
- X if ($filename ne '' && open(INCLUDE, "$filename")) {
- X while (<INCLUDE>) {
- X next if /^\s*#/; # Skip shell comments
- X chop;
- X s/^\s+//; # Remove leading spaces
- X push(@result, $_);
- X &add_log("loaded $what '$_'") if $loglvl > 19;
- X }
- X close INCLUDE;
- X } elsif ($filename ne '') { # Could not open file
- X &add_log("WARNING couldn't open $filename for ".&plural($what).": $!")
- X if $loglvl > 4;
- X } else {
- X &add_log("WARNING incorrect file inclusion request: $inc")
- X if $loglvl > 4;
- X }
- X @result; # List of non-comment lines held in file
- X}
- X
- END_OF_FILE
- if test 1799 -ne `wc -c <'agent/pl/include.pl'`; then
- echo shar: \"'agent/pl/include.pl'\" unpacked with wrong size!
- fi
- # end of 'agent/pl/include.pl'
- fi
- if test -f 'agent/pl/mailhook.pl' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/pl/mailhook.pl'\"
- else
- echo shar: Extracting \"'agent/pl/mailhook.pl'\" \(2231 characters\)
- sed "s/^X//" >'agent/pl/mailhook.pl' <<'END_OF_FILE'
- X;# $Id: mailhook.pl,v 3.0 1993/11/29 13:48:58 ram Exp ram $
- X;#
- X;# Copyright (c) 1990-1993, Raphael Manfredi
- X;#
- X;# You may redistribute only under the terms of the Artistic License,
- X;# as specified in the README file that comes with the distribution.
- X;# You may reuse parts of this distribution only within the terms of
- X;# that same Artistic License; a copy of which may be found at the root
- X;# of the source tree for mailagent 3.0.
- X;#
- X;# $Log: mailhook.pl,v $
- X;# Revision 3.0 1993/11/29 13:48:58 ram
- X;# Baseline for mailagent 3.0 netwide release.
- X;#
- X;#
- X#
- X# Various hook utilities
- X# (name in package hook, compiled in package mailhook)
- X#
- X
- Xpackage mailhook;
- X
- X# Parse mail and initialize special variables. The perl script used as hook
- X# does not have (usually) to do any parsing on the mail. Headers of the mail
- X# are available via the %header array and some special variables are set as
- X# conveniences.
- Xsub hook'initvar {
- X local($package) = @_; # Package into which variables should be set
- X local($init) = &'q(<<'EOP');
- X: *header = *main'Header; # User may fetch headers via %header
- X: $sender = $header{'Sender'};
- X: $subject = $header{'Subject'};
- X: $precedence = $header{'Precedence'};
- X: $from = $header{'From'};
- X: $to = $header{'To'};
- X: $cc = $header{'Cc'};
- X: $envelope = $header{'Envelope'};
- X: ($reply_to) = &'parse_address($header{'Reply-To'});
- X: ($address, $friendly) = &'parse_address($from);
- X: $login = &'login_name($address);
- X: @to = split(/,/, $to);
- X: @cc = split(/,/, $to);
- X: # Leave only the address part in @to and @cc
- X: grep(($_ = (&'parse_address($_))[0], 0), @to);
- X: grep(($_ = (&'parse_address($_))[0], 0), @cc);
- XEOP
- X eval(<<EOP); # Initialize variables inside package
- X package $package;
- X $init
- XEOP
- X}
- X
- X# Load hook script and run it
- Xsub hook'run {
- X local($hook) = @_;
- X open(HOOK, $hook) || &'fatal("cannot open $hook: $!");
- X local($body) = ' ' x (-s HOOK);
- X {
- X local($/) = undef;
- X $body = <HOOK>; # Slurp whole file
- X }
- X close(HOOK);
- X unshift(@INC, $'privlib); # Files first searched for in mailagent's lib
- X eval $body; # Load, compile and execute within mailhook
- X if (chop($@)) {
- X $@ =~ s/ in file \(eval\)//;
- X &'add_log("ERROR $@") if $'loglvl;
- X die("$hook aborted");
- X }
- X}
- X
- Xpackage main;
- X
- END_OF_FILE
- if test 2231 -ne `wc -c <'agent/pl/mailhook.pl'`; then
- echo shar: \"'agent/pl/mailhook.pl'\" unpacked with wrong size!
- fi
- # end of 'agent/pl/mailhook.pl'
- fi
- if test -f 'agent/pl/once.pl' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/pl/once.pl'\"
- else
- echo shar: Extracting \"'agent/pl/once.pl'\" \(1871 characters\)
- sed "s/^X//" >'agent/pl/once.pl' <<'END_OF_FILE'
- X;# $Id: once.pl,v 3.0 1993/11/29 13:49:04 ram Exp ram $
- X;#
- X;# Copyright (c) 1990-1993, Raphael Manfredi
- X;#
- X;# You may redistribute only under the terms of the Artistic License,
- X;# as specified in the README file that comes with the distribution.
- X;# You may reuse parts of this distribution only within the terms of
- X;# that same Artistic License; a copy of which may be found at the root
- X;# of the source tree for mailagent 3.0.
- X;#
- X;# $Log: once.pl,v $
- X;# Revision 3.0 1993/11/29 13:49:04 ram
- X;# Baseline for mailagent 3.0 netwide release.
- X;#
- X;#
- X;# Handling of the "once" directory for ONCE commands. A once command is
- X;# tagged with a tuple (name,ruletag). The name is used for hashing, and
- X;# the ruletag sepecifies the entry to be used by the command for timestamp
- X;# recording. The dbr package is used to maintain the database
- X;#
- X# Given a tuple (name, tag) and a period, make sure the command may be
- X# executed. If it can, update the timestamp and return true. false otherwise.
- Xsub once_check {
- X local($hname, $tag, $period) = @_;
- X $hname =~ s/\s//g; # There cannot be spaces in the name
- X local($ok) = 1; # Is once ok ?
- X local($timestamp) = 0; # Time stamp attached to entry
- X local($linenum) = 0; # Line where entry was found
- X if (-f $file) {
- X ($timestamp, $linenum) = &dbr'info($hname, 'ONCE', $tag);
- X return 0 if $timestamp == -1; # An error occurred
- X }
- X local($now) = time; # Number of seconds since The Epoch
- X if (($timestamp + $period) > $now) {
- X &'add_log("we have to wait for ($hname, $tag)") if $'loglvl > 18;
- X return 0;
- X }
- X # Now we know we can execute the command. So update the database entry.
- X # If the timestamp is 0, then an append has to be done, otherwise it's
- X # a single replacement.
- X if ($timestamp > 0) {
- X &dbr'update($hname, 'ONCE', $linenum, $tag);
- X } else {
- X &dbr'update($hname, 'ONCE', 0, $tag);
- X }
- X 1;
- X}
- X
- END_OF_FILE
- if test 1871 -ne `wc -c <'agent/pl/once.pl'`; then
- echo shar: \"'agent/pl/once.pl'\" unpacked with wrong size!
- fi
- # end of 'agent/pl/once.pl'
- fi
- if test -f 'agent/test/basic/filter.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/basic/filter.t'\"
- else
- echo shar: Extracting \"'agent/test/basic/filter.t'\" \(2249 characters\)
- sed "s/^X//" >'agent/test/basic/filter.t' <<'END_OF_FILE'
- X# Make sure filter queues messages correctly
- X
- X# $Id: filter.t,v 3.0 1993/11/29 13:49:24 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: filter.t,v $
- X# Revision 3.0 1993/11/29 13:49:24 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/init.pl';
- Xdo '../pl/logfile.pl';
- Xchdir '../out' || exit 0;
- Xopen(WAIT, ">queue/agent.wait") || print "1\n";
- Xclose WAIT;
- X`chmod u-w queue`;
- X$? == 0 || print "2\n";
- X# Use the special undocumented -t option from filter to get HOME directory
- X# via environment instead of /etc/passwd.
- Xopen(FILTER, "|$filter -t >/dev/null 2>&1") || print "3\n";
- Xprint FILTER <<EOF;
- XDummy mail
- XEOF
- Xclose FILTER;
- X$? == 0 || print "4\n"; # Must terminate correctly (stored in agent.wait)
- X&get_log(5);
- X&check_log('memorized', 6); # Make sure mail has been memorized
- X-s 'queue/agent.wait' || print "7\n";
- X$file = <emerg/*>;
- Xif (-f "$file") {
- X chop($what = `cat queue/agent.wait`);
- X chop($pwd = `pwd`);
- X $what eq "$pwd/$file" || print "8\n";
- X unlink "$file";
- X} else {
- X print "8\n";
- X}
- X`chmod u+w queue`;
- Xunlink 'queue/agent.wait', 'agentlog';
- Xopen(FILTER, "|$filter -t >/dev/null 2>&1") || print "9\n";
- Xprint FILTER <<EOF;
- XDummy mail
- XEOF
- Xclose FILTER;
- X$? == 0 || print "10\n"; # Must terminate correctly (queued)
- X&get_log(11);
- X&check_log('QUEUED', 12); # Mail was queued
- X$file = <queue/qm*>;
- X-f "$file" || print "13\n"; # Must have been left in queue
- Xunlink "$file", 'agentlog';
- X# Make sure file is correctly queued when another filter is running
- X`cp /dev/null filter.lock`;
- X$? == 0 || print "14\n";
- Xopen(FILTER, "|$filter -t >/dev/null 2>&1") || print "15\n";
- Xprint FILTER <<EOF;
- XDummy mail
- XEOF
- Xclose FILTER;
- X$? == 0 || print "16\n"; # Must terminate correctly (queued)
- X&get_log(17);
- X&check_log('QUEUED', 18); # Mail was queued
- X$file = <queue/fm*>;
- X-f "$file" || print "19\n"; # Must have been left in queue as a 'fm' file
- Xunlink "$file", 'agentlog', 'filter.lock';
- Xprint "0\n";
- END_OF_FILE
- if test 2249 -ne `wc -c <'agent/test/basic/filter.t'`; then
- echo shar: \"'agent/test/basic/filter.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/basic/filter.t'
- fi
- if test -f 'agent/test/cmd/keep.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/cmd/keep.t'\"
- else
- echo shar: Extracting \"'agent/test/cmd/keep.t'\" \(1830 characters\)
- sed "s/^X//" >'agent/test/cmd/keep.t' <<'END_OF_FILE'
- X# Test KEEP command
- X
- X# $Id: keep.t,v 3.0 1993/11/29 13:49:33 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: keep.t,v $
- X# Revision 3.0 1993/11/29 13:49:33 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/cmd.pl';
- Xunlink 'ok', 'no_resync';
- X
- Xopen(LIST, '>header-list') || print "17\n";
- Xprint LIST <<EOL;
- XTo
- XSubject
- XU*
- XX*
- XEOL
- Xclose LIST;
- X
- X&add_header('X-Tag: keep');
- X&add_header('X-Long-Line: this is a long line and has a continuation');
- X&add_header(' right below it with a MARK token');
- X&add_header(' and another with the MARK token');
- X&add_header('X-Removed-Line: this is a long line and has a continuation');
- X&add_header(' right below it with another mark TOKEN');
- X&add_header(' and another with the mark TOKEN');
- X&add_header('unusual-header: None');
- X`$cmd`;
- X$? == 0 || print "1\n";
- X-f "$user" && print "2\n"; # Mail saved...
- X-f 'ok' || print "3\n"; # ...here
- X&get_log(4, 'ok');
- X¬_log('^Received:', 5); # Make sure Received: disappeared
- X&check_log('^To:', 6); # But To: still here
- X&check_log('^From:', 7);
- X&check_log('^Subject:', 8);
- X¬_log('^X-None:', 9);
- X&check_log('MARK', 10) == 2 || print "11\n"; # Continuation line kept
- X&check_log('^X-Long-Line:', 12); # So is the parent field
- X¬_log('^X-Removed-Line:', 13);
- X¬_log('TOKEN', 14); # This continuation was removed
- X&check_log('^unusual-header:', 16);
- X-f 'no_resync' || print "15\n"; # Ensure header not disturbed
- X
- X# Last: 17
- Xunlink 'ok', 'no_resync', 'mail', 'header-list';
- Xprint "0\n";
- END_OF_FILE
- if test 1830 -ne `wc -c <'agent/test/cmd/keep.t'`; then
- echo shar: \"'agent/test/cmd/keep.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/cmd/keep.t'
- fi
- if test -f 'agent/test/cmd/once.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/cmd/once.t'\"
- else
- echo shar: Extracting \"'agent/test/cmd/once.t'\" \(1837 characters\)
- sed "s/^X//" >'agent/test/cmd/once.t' <<'END_OF_FILE'
- X# The ONCE command and autocleaning feature
- X
- X# $Id: once.t,v 3.0 1993/11/29 13:49:37 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: once.t,v $
- X# Revision 3.0 1993/11/29 13:49:37 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/cmd.pl';
- Xunlink 'one', 'two', 'three', 'four', "$user";
- X
- X&add_header('X-Tag: once');
- X`rm -rf dbr` if -d 'dbr';
- X`$cmd`;
- X$? == 0 || print "1\n";
- X-f "$user" && print "2\n";
- X-f 'one' || print "3\n";
- X-f 'two' && print "4\n";
- X-f 'three' || print "5\n";
- X-f 'four' || print "6\n";
- X-d 'dbr' || print "7\n";
- X@files = <dbr/*/*>;
- X@files == 3 || print "8\n";
- X
- X# Make sure ONCE dbr database not disturbed by autocleaning, and, along
- X# the way, check that auto cleaning is correctly run.
- X
- X$level = $ENV{'LEVEL'};
- X`$mailagent -L $level -q -o 'autoclean: ON' 2>/dev/null`;
- X$? == 0 || print "9\n";
- X@new_files = <dbr/*/*>;
- X@new_files == @files || print "10\n";
- Xunlink 'one', 'two', 'three', 'four', "$user";
- X-f 'context' || print "11\n";
- X
- X`$cmd`;
- X$? == 0 || print "12\n";
- X-f "$user" && print "13\n";
- X-f 'one' && print "14\n";
- X-f 'two' && print "15\n";
- X-f 'three' && print "16\n";
- X-f 'four' || print "17\n";
- X-d 'dbr' || print "18\n";
- X
- X# Make sure autocleaning leaves things in a coherent state
- X
- X`$mailagent -q -L $level -o 'autoclean: ON' -o 'agemax: 0m' 2>/dev/null`;
- X-d 'dbr' && print "19\n";
- X-f 'context' || print "20\n";
- X
- X`$mailagent -q -L $level 2>/dev/null`;
- X-f 'context' && print "21\n";
- X
- Xunlink 'one', 'two', 'three', 'four', "$user", 'mail';
- Xprint "0\n";
- END_OF_FILE
- if test 1837 -ne `wc -c <'agent/test/cmd/once.t'`; then
- echo shar: \"'agent/test/cmd/once.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/cmd/once.t'
- fi
- if test -f 'agent/test/cmd/record.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/cmd/record.t'\"
- else
- echo shar: Extracting \"'agent/test/cmd/record.t'\" \(1845 characters\)
- sed "s/^X//" >'agent/test/cmd/record.t' <<'END_OF_FILE'
- X# The RECORD command
- X
- X# $Id: record.t,v 3.0 1993/11/29 13:49:42 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: record.t,v $
- X# Revision 3.0 1993/11/29 13:49:42 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/cmd.pl';
- Xunlink "$user.1", "$user.2", "$user.3";
- X
- X&add_header('X-Tag: record #1');
- X`rm -rf dbr` if -d 'dbr';
- X`$cmd`;
- X$? == 0 || print "1\n";
- X-f "$user.1" || print "2\n"; # Was saved, first time.
- Xunlink "$user.1";
- X
- X-d 'dbr' || print "3\n"; # Make sure history recording works
- X-f 'dbr/i/e' || print "4\n"; # Hashing done on domain name
- X
- X`$cmd`;
- X$? == 0 || print "5\n";
- X-f "$user.1" && print "6\n"; # We rejected this time, in SEEN mode
- X-f "$user.2" || print "7\n"; # And saved it here
- Xunlink "$user.2";
- X
- X&replace_header('X-Tag: record #2');
- X`$cmd`;
- X$? == 0 || print "8\n";
- X-f "$user.1" && print "9\n"; # We restarted this time
- X-f "$user.3" || print "10\n"; # And caught that rule in RECORD mode
- X-f "$user" && print "11\n"; # Nothing here
- Xunlink "$user.3";
- X
- X&replace_header('X-Tag: record #3');
- X`$cmd`;
- X$? == 0 || print "12\n";
- X-f "$user.1" && print "13\n"; # We aborted
- X-f "$user" || print "14\n"; # Must be there (aborted, no match)
- Xunlink "$user.1", "$user";
- X
- X&replace_header('X-Tag: record #4');
- X`$cmd`;
- X$? == 0 || print "15\n";
- X-f "$user.1" && print "16\n"; # We rejected
- X-f "$user.2" || print "17\n"; # Must be there (saved in mode RECORD)
- X-f "$user" && print "18\n";
- X
- X`rm -rf dbr` if -d 'dbr';
- Xunlink "$user", "$user.1", "$user.2", "$user.3", 'mail';
- Xprint "0\n";
- END_OF_FILE
- if test 1845 -ne `wc -c <'agent/test/cmd/record.t'`; then
- echo shar: \"'agent/test/cmd/record.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/cmd/record.t'
- fi
- if test -f 'agent/test/cmd/store.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/cmd/store.t'\"
- else
- echo shar: Extracting \"'agent/test/cmd/store.t'\" \(1804 characters\)
- sed "s/^X//" >'agent/test/cmd/store.t' <<'END_OF_FILE'
- X# The STORE command
- X
- X# $Id: store.t,v 3.0 1993/11/29 13:49:50 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: store.t,v $
- X# Revision 3.0 1993/11/29 13:49:50 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/cmd.pl';
- X$mbox = 'mbox';
- X
- X&add_header('X-Tag: store #1');
- X`$cmd`;
- X$? == 0 || print "1\n";
- X-f "$mbox" || print "2\n"; # Mail saved here
- X-f "$user" || print "3\n"; # Leave copy in mailbox
- X-s "$mbox" == -s "$user" || print "4\n"; # Same content
- X
- X# When mailbox protected against writing...
- Xunlink <emerg/*>;
- Xunlink "$user";
- X$size = -s "$mbox";
- Xchmod 0444, "$mbox";
- X`$cmd`;
- X$? == 0 || print "5\n";
- X-f "$mbox" || print "6\n"; # Must still be there
- X$size == -s "$mbox" || print "7\n"; # And not altered
- X-f "$user" || print "8\n"; # Left only copy in mailbox
- X$size == -s "$user" || print "9\n"; # Which must also match in size
- X@emerg = <emerg/*>;
- X@emerg == 1 || print "10\n"; # Emeregency as SAVE failed
- X
- X# There is no X-Filter mail in the emergency saving
- X`grep -v X-Filter: $mbox > ok`;
- X$? == 0 || print "11\n";
- X-s $emerg[0] eq -s 'ok' || print "12\n"; # Full mail saved, of course
- Xunlink "$mbox", "$user";
- X
- X# Make sure STORE creates full path when needed
- X&replace_header('X-Tag: store #2');
- X`rm -rf path` if -d 'path';
- X`$cmd`;
- X$? == 0 || print "13\n";
- X-f 'path/another/third/mbox' || print "14\n";
- X-f "$user" || print "15\n";
- X
- X`rm -rf path` if -d 'path';
- Xunlink <emerg/*>;
- Xunlink "$mbox", "$user", 'mail', 'ok';
- Xprint "0\n";
- END_OF_FILE
- if test 1804 -ne `wc -c <'agent/test/cmd/store.t'`; then
- echo shar: \"'agent/test/cmd/store.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/cmd/store.t'
- fi
- if test -f 'agent/test/cmd/strip.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/cmd/strip.t'\"
- else
- echo shar: Extracting \"'agent/test/cmd/strip.t'\" \(1847 characters\)
- sed "s/^X//" >'agent/test/cmd/strip.t' <<'END_OF_FILE'
- X# Test STRIP command
- X
- X# $Id: strip.t,v 3.0 1993/11/29 13:49:51 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: strip.t,v $
- X# Revision 3.0 1993/11/29 13:49:51 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/cmd.pl';
- Xunlink 'ok', 'no_resync';
- X
- Xopen(LIST, '>header-list') || print "17\n";
- Xprint LIST <<EOL;
- XUnusual-Header
- XX-Long*
- XEOL
- Xclose LIST;
- X
- X&add_header('X-Tag: strip');
- X&add_header('X-Long-Line: this is a long line and has a continuation');
- X&add_header(' right below it with a MARK token');
- X&add_header(' and another with the MARK token');
- X&add_header('X-Kept-Line: this is a long line and has a continuation');
- X&add_header(' right below it with another mark TOKEN');
- X&add_header(' and another with the mark TOKEN');
- X&add_header('unusual-header: None');
- X`$cmd`;
- X$? == 0 || print "1\n";
- X-f "$user" && print "2\n"; # Mail saved...
- X-f 'ok' || print "3\n"; # ...here
- X&get_log(4, 'ok');
- X¬_log('^Received:', 5); # Make sure Received: disappeared
- X&check_log('^To:', 6); # But To: still here
- X&check_log('^From:', 7);
- X&check_log('^Subject:', 8);
- X¬_log('^X-None:', 9);
- X¬_log('MARK', 10); # Continuation line must have been stripped too
- X¬_log('^X-Long-Line:', 11); # As well as its parent
- X&check_log('TOKEN', 12) == 2 || print "13\n"; # This one has been kept
- X&check_log('^X-Kept-Line:', 14);
- X¬_log('^unusual-header:', 16);
- X-f 'no_resync' || print "15\n"; # Ensure header not disturbed
- X
- X# Last: 17
- Xunlink 'ok', 'no_resync', 'mail', 'header-list';
- Xprint "0\n";
- END_OF_FILE
- if test 1847 -ne `wc -c <'agent/test/cmd/strip.t'`; then
- echo shar: \"'agent/test/cmd/strip.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/cmd/strip.t'
- fi
- if test -f 'agent/test/cmd/unique.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/cmd/unique.t'\"
- else
- echo shar: Extracting \"'agent/test/cmd/unique.t'\" \(1836 characters\)
- sed "s/^X//" >'agent/test/cmd/unique.t' <<'END_OF_FILE'
- X# The UNIQUE command
- X
- X# $Id: unique.t,v 3.0 1993/11/29 13:49:53 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: unique.t,v $
- X# Revision 3.0 1993/11/29 13:49:53 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/cmd.pl';
- Xunlink "$user.1", "$user.2", "$user.3";
- X
- X&add_header('X-Tag: unique #1');
- X`rm -rf dbr` if -d 'dbr';
- X`$cmd`;
- X$? == 0 || print "1\n";
- X-f "$user.1" || print "2\n"; # Was saved, first time.
- Xunlink "$user.1";
- X
- X-d 'dbr' || print "3\n"; # Make sure history recording works
- X-f 'dbr/i/e' || print "4\n"; # Hashing done on domain name
- X
- X`$cmd`;
- X$? == 0 || print "5\n";
- X-f "$user.1" && print "6\n"; # We rejected this time, NOT in SEEN mode
- X-f "$user.2" || print "7\n"; # And saved it here
- Xunlink "$user.2";
- X
- X&replace_header('X-Tag: unique #2');
- X`$cmd`;
- X$? == 0 || print "8\n";
- X-f "$user.1" && print "9\n"; # We restarted this time
- X-f "$user.3" || print "10\n"; # And caught that rule
- X-f "$user" && print "11\n"; # Nothing here
- Xunlink "$user.3";
- X
- X&replace_header('X-Tag: unique #3');
- X`$cmd`;
- X$? == 0 || print "12\n";
- X-f "$user.1" && print "13\n"; # We aborted
- X-f "$user" && print "14\n"; # Must not be there (tagged as saved)
- Xunlink "$user.1", "$user";
- X
- X&replace_header('X-Tag: unique #4');
- X`$cmd`;
- X$? == 0 || print "15\n";
- X-f "$user.1" && print "16\n"; # We rejected
- X-f "$user.2" || print "17\n"; # Must be there (saved in mode UNIQUE)
- X-f "$user" && print "18\n";
- X
- X`rm -rf dbr` if -d 'dbr';
- Xunlink "$user", "$user.1", "$user.2", "$user.3", 'mail';
- Xprint "0\n";
- END_OF_FILE
- if test 1836 -ne `wc -c <'agent/test/cmd/unique.t'`; then
- echo shar: \"'agent/test/cmd/unique.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/cmd/unique.t'
- fi
- if test -f 'agent/test/cmd/write.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/cmd/write.t'\"
- else
- echo shar: Extracting \"'agent/test/cmd/write.t'\" \(1840 characters\)
- sed "s/^X//" >'agent/test/cmd/write.t' <<'END_OF_FILE'
- X# The WRITE command
- X
- X# $Id: write.t,v 3.0 1993/11/29 13:49:55 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: write.t,v $
- X# Revision 3.0 1993/11/29 13:49:55 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/cmd.pl';
- X$mbox = 'mbox';
- X
- X&add_header('X-Tag: write #1');
- X`$cmd`;
- X$? == 0 || print "1\n";
- X-f "$mbox" || print "2\n"; # Mail saved here
- X-f "$user" && print "3\n"; # Must not exist (yet)
- X
- X# When mailbox protected against writing...
- Xunlink <emerg/*>;
- X$size = -s "$mbox";
- Xchmod 0444, "$mbox";
- X`$cmd`;
- X$? == 0 || print "4\n";
- X-f "$mbox" || print "5\n"; # Must still be there
- X$size == -s "$mbox" || print "6\n"; # And not altered
- X@emerg = <emerg/*>;
- X@emerg == 1 || print "7\n"; # Emeregency as SAVE failed
- X-f "$user" || print "8\n"; # Not saved -> leave in mbox
- X-s "$user" == -s "$mbox" || print "9\n";
- X
- X# There is no X-Filter mail in the emergency saving
- X`grep -v X-Filter: $mbox > ok`;
- X$? == 0 || print "10\n";
- X-s $emerg[0] eq -s 'ok' || print "11\n"; # Full mail saved, of course
- X
- X# Now verify WRITE actually overwrites the contentes
- Xunlink "$user";
- Xchmod 0644, "$mbox";
- X`$cmd`;
- X$? == 0 || print "12\n";
- X$size == -s "$mbox" || print "13\n";
- X-f "$user" && print "14\n";
- X
- X# Make sure WRITE creates full path when needed
- X&replace_header('X-Tag: write #2');
- X`rm -rf path` if -d 'path';
- X`$cmd`;
- X$? == 0 || print "15\n";
- X-f 'path/another/third/mbox' || print "16\n";
- X`rm -rf path` if -d 'path';
- X
- Xunlink <emerg/*>;
- Xunlink "$mbox", "$user", 'mail', 'ok';
- Xprint "0\n";
- END_OF_FILE
- if test 1840 -ne `wc -c <'agent/test/cmd/write.t'`; then
- echo shar: \"'agent/test/cmd/write.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/cmd/write.t'
- fi
- if test -f 'agent/test/misc/mh.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/misc/mh.t'\"
- else
- echo shar: Extracting \"'agent/test/misc/mh.t'\" \(2486 characters\)
- sed "s/^X//" >'agent/test/misc/mh.t' <<'END_OF_FILE'
- X# Test MH-style folders
- X
- X# $Id: mh.t,v 3.0 1993/11/29 13:50:09 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: mh.t,v $
- X# Revision 3.0 1993/11/29 13:50:09 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/misc.pl';
- Xunlink "$user", 'always';
- X
- X-d 'mh' || mkdir('mh', 0700) || print "1\n";
- X-d 'mh/tmp' || mkdir('mh/tmp', 0700) || print "2\n";
- Xunlink <mh/tmp/*>;
- Xopen(MSG, '>mh/tmp/3') || print "3\n";
- Xprint MSG <<'EOF';
- XFrom: mailagent
- XTo: ram
- XSubject: message #3
- X
- XMessage #3
- XEOF
- Xclose MSG;
- Xopen(MSG, '>mh/tmp/7') || print "4\n";
- Xprint MSG <<'EOF';
- XFrom: mailagent
- XTo: ram
- XSubject: message #7
- X
- XMessage #7
- XEOF
- Xclose MSG;
- Xopen(MSG, '>mh/tmp/.mh_sequences') || print "5\n";
- Xprint MSG <<'EOF';
- Xcur: 1
- Xpseq: 3 7
- Xunseen: 1 3-4 12
- Xanother: 1 3-7 12
- Xhole: 1 3 5 7 9
- Xfull: 1-9
- Xlast: 3-6 9-12
- XEOF
- Xclose MSG;
- Xopen(MSG, '>mh/tmp/.mh_seqnew') || print "6\n";
- Xprint MSG <<'EOF';
- Xcur: 1
- Xpseq: 3 7
- Xunseen: 1 3-4 8 12
- Xanother: 1 3-8 12
- Xhole: 1 3 5 7-8 9
- Xfull: 1-9
- Xlast: 3-6 8-12
- Xnew: 8
- XEOF
- Xclose MSG;
- Xopen(MSG, '>.mh_prof') || print "7\n";
- Xprint MSG <<'EOF';
- XPath: mh
- XUnseen-Sequence: unseen, another, hole, full, last, new
- XEOF
- Xclose MSG;
- X
- X-d 'dir' || mkdir('dir', 0700) || print "8\n";
- Xunlink <dir/*>;
- Xopen(MSG, '>dir/.prefix') || print "9\n";
- Xprint MSG "msg\nanother\n";
- Xclose MSG;
- Xopen(MSG, '>dir/msg4') || print "10\n";
- Xclose MSG;
- Xopen(MSG, '>dir/other5') || print "11\n";
- Xclose MSG;
- Xopen(MSG, '>dir/5') || print "12\n";
- Xclose MSG;
- X
- X`rm -rf mh/new`;
- X-d 'mh/new' && print "13\n";
- X
- X-d 'simple' || mkdir('simple', 0700) || print "14\n";
- Xopen(MSG, '>simple/3') || print "15\n";
- Xclose MSG;
- X
- Xunlink 'mh/tmp/8', 'dir/msg5', 'simple/4', $user;
- X
- X&add_option("-o 'mhprofile: ~/.mh_prof' -o 'msgprefix: .prefix'");
- X&add_header('X-Tag: mh');
- X`$cmd`;
- X$? == 0 || print "16\n";
- X-f "$user" && print "17\n";
- X-s 'mh/tmp/8' || print "18\n";
- Xsystem "cmp -s mh/tmp/.mh_sequences mh/tmp/.mh_seqnew >/dev/null 2>&1";
- X$? == 0 || print "19\n";
- X-f 'mh/new/1' || print "20\n";
- X-s 'mh/new/.mh_sequences' || print "21\n";
- X-s 'dir/msg5' || print "22\n";
- X-s 'simple/4' || print "23\n";
- X
- Xsystem "rm -rf mh dir simple >/dev/null 2>&1";
- Xunlink $user, 'mail';
- Xprint "0\n";
- END_OF_FILE
- if test 2486 -ne `wc -c <'agent/test/misc/mh.t'`; then
- echo shar: \"'agent/test/misc/mh.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/misc/mh.t'
- fi
- if test -f 'agent/test/misc/newcmd.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/misc/newcmd.t'\"
- else
- echo shar: Extracting \"'agent/test/misc/newcmd.t'\" \(2232 characters\)
- sed "s/^X//" >'agent/test/misc/newcmd.t' <<'END_OF_FILE'
- X# Test user-defined commands
- X
- X# $Id: newcmd.t,v 3.0 1993/11/29 13:50:10 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: newcmd.t,v $
- X# Revision 3.0 1993/11/29 13:50:10 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/misc.pl';
- Xunlink "$user", 'always', 'test';
- X
- X&add_option("-o 'newcmd: ~/.newcmd'");
- Xopen(NEWCMD, '>.newcmd') || print "1\n";
- Xprint NEWCMD <<EOF || print "2\n";
- XFIRST_CMD ~/commands first
- XSECOND_CMD ~/commands second
- XTHIRD_CMD ~/commands third
- XEOF
- Xclose NEWCMD || print "3\n";
- X
- Xopen(COM, '>commands') || print "4\n";
- Xprint COM <<'EOC' || print "5\n";
- Xsub first {
- X &mailhook'third_cmd('test'); # Make sure interface function is there
- X open(OUT, '>output1');
- X print OUT join(' ', @ARGV), "\n";
- X print OUT "$to\n";
- X close OUT;
- X 0;
- X}
- X
- Xsub second {
- X &main'add_log('second user-defined command ran ok');
- X open(OUT, '>output2');
- X print OUT "$from\n";
- X print OUT "$header{'Date'}\n";
- X close OUT;
- X 0;
- X}
- X
- Xsub third {
- X local($cmd) = @_;
- X local(@cmd) = split(' ', $cmd);
- X open(TEST, ">$cmd[1]");
- X print TEST "$cmd\n";
- X close TEST;
- X 0;
- X}
- XEOC
- Xclose COM || print "6\n";
- X
- X&add_header('X-Tag: newcmd');
- X`$cmd`;
- X$? == 0 || print "7\n";
- X-f "$user" && print "8\n"; # Has defaulted to LEAVE -> something's wrong
- X-f 'output1' || print "9\n";
- X-f 'output2' || print "10\n";
- X-f 'test' || print "11\n";
- X
- Xchop($test = `cat test 2>/dev/null`);
- X$test eq 'third_cmd test' || print "12\n";
- X
- Xchop(@test = `cat output1 2>/dev/null`);
- X$test[0] eq 'FIRST_CMD arg1 arg2' || print "13\n";
- X$test[1] eq 'ram@eiffel.com' || print "14\n";
- X
- Xchop(@test = `cat output2 2>/dev/null`);
- X$test[0] eq 'compilers-request@iecc.cambridge.ma.us' || print "15\n";
- X$test[1] eq '3 Jul 92 00:43:22 EDT (Fri)' || print "16\n";
- X
- X&get_log(17);
- X&check_log('second user-defined command ran ok', 18) == 1 || print "19\n";
- X
- Xunlink "$user", 'mail', 'test', 'output1', 'output2', 'commands', '.newcmd';
- Xprint "0\n";
- END_OF_FILE
- if test 2232 -ne `wc -c <'agent/test/misc/newcmd.t'`; then
- echo shar: \"'agent/test/misc/newcmd.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/misc/newcmd.t'
- fi
- if test -f 'agent/test/option/s.t' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'agent/test/option/s.t'\"
- else
- echo shar: Extracting \"'agent/test/option/s.t'\" \(2336 characters\)
- sed "s/^X//" >'agent/test/option/s.t' <<'END_OF_FILE'
- X# -s: report gathered statistics (special)
- X
- X# $Id: s.t,v 3.0 1993/11/29 13:50:20 ram Exp ram $
- X#
- X# Copyright (c) 1990-1993, Raphael Manfredi
- X#
- X# You may redistribute only under the terms of the Artistic License,
- X# as specified in the README file that comes with the distribution.
- X# You may reuse parts of this distribution only within the terms of
- X# that same Artistic License; a copy of which may be found at the root
- X# of the source tree for mailagent 3.0.
- X#
- X# $Log: s.t,v $
- X# Revision 3.0 1993/11/29 13:50:20 ram
- X# Baseline for mailagent 3.0 netwide release.
- X#
- X
- Xdo '../pl/init.pl';
- Xdo '../pl/logfile.pl';
- Xchdir '../out';
- Xunlink 'mailagent.st';
- X$out = `$mailagent -summary 2>/dev/null`;
- X$? == 0 || print "1\n";
- X`cp /dev/null mailagent.st`;
- X$mail_test = <<'EOM';
- XFrom ram Sat Jul 11 18:51:16 PDT 1992
- XFrom: ram
- XTo: ram
- XSubject: test
- X
- XThis is a test.
- XEOM
- X# First time creates new statistics, second time updates them.
- Xfor ($i = 0; $i < 2; $i++) {
- X open(MAILAGENT, "|$mailagent -e 'STRIP Nothing; LEAVE' 2>/dev/null") ||
- X print "2x$i\n";
- X print MAILAGENT $mail_test;
- X close MAILAGENT;
- X $? == 0 || print "3x$i\n";
- X sleep 1 while -f 'perl.lock'; # Wait for background process to finish
- X}
- X$user = $ENV{'USER'};
- X-s "$user" || print "4\n";
- X$out = `$mailagent -s 2>/dev/null`;
- X$out ne '' || print "5\n";
- X@out = split(/\n/, $out);
- X@leave = grep(/LEAVE/, @out);
- X@strip = grep(/STRIP/, @out);
- X@leave == @strip || print "6\n";
- X@leave == 1 || print "7\n";
- X$out = `$mailagent -sm 2>/dev/null`;
- X@out = split(/\n/, $out);
- X@leave = grep(/LEAVE/, @out);
- X@strip = grep(/STRIP/, @out);
- X@leave == @strip || print "8\n";
- X@leave == 2 || print "9\n";
- X$out = `$mailagent -sr 2>/dev/null`;
- X@out = split(/\n/, $out);
- Xgrep(/STRIP.*LEAVE/, @out) || print "10\n";
- X&get_log(11, 'mailagent.st');
- X&check_log('^---', 12) == 1 || print "13\n"; # Rules did not changed
- X&check_log('^\+\+\+', 14) == 1 || print "15\n";
- X
- X# Now change rules slightly
- Xopen(MAILAGENT, "|$mailagent -e 'STRIP Other; LEAVE' 2>/dev/null") ||
- Xprint "16\n";
- Xprint MAILAGENT $mail_test;
- Xclose MAILAGENT;
- X$? == 0 || print "17\n";
- Xsleep 1 while -f 'perl.lock'; # Wait for background process to finish
- X&get_log(18, 'mailagent.st');
- X&check_log('^---', 19) == 2 || print "20\n"; # Rules did changed
- X&check_log('^\+\+\+', 21) == 2 || print "22\n";
- X
- Xunlink 'mailagent.st', "$user";
- Xprint "0\n";
- END_OF_FILE
- if test 2336 -ne `wc -c <'agent/test/option/s.t'`; then
- echo shar: \"'agent/test/option/s.t'\" unpacked with wrong size!
- fi
- # end of 'agent/test/option/s.t'
- fi
- if test -f 'misc/unkit/rules' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'misc/unkit/rules'\"
- else
- echo shar: Extracting \"'misc/unkit/rules'\" \(379 characters\)
- sed "s/^X//" >'misc/unkit/rules' <<'END_OF_FILE'
- X# This rule will process any message containing the word 'kit #' in the subject
- X# and that is not a reply. Indded, each kit message has a subject looking like:
- X# package - kit #1 / 5
- X# The UNKIT command can be configured from the ~/.mailagent file, but defaults
- X# values are hardwired and should be ok most of the time.
- X
- X!Subject: /^Re:/, !/kit #/ { UNKIT; ABORT -t; LEAVE };
- END_OF_FILE
- if test 379 -ne `wc -c <'misc/unkit/rules'`; then
- echo shar: \"'misc/unkit/rules'\" unpacked with wrong size!
- fi
- # end of 'misc/unkit/rules'
- fi
- echo shar: End of archive 21 \(of 26\).
- cp /dev/null ark21isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 26 archives.
- echo "Now run 'sh PACKNOTES', then read README and type Configure.'"
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still must unpack the following archives:
- echo " " ${MISSING}
- fi
- exit 0
-
- exit 0 # Just in case...
-