home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-10-05 | 55.2 KB | 1,809 lines |
- Newsgroups: comp.sources.misc
- X-UNIX-From: otello!i2ack!venta@italy.sublink.org
- from: venta@i2ack.sublink.org (Paolo Ventafridda)
- subject: v15i013: RNALIB_20/part03
- Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
-
- Posting-number: Volume 15, Issue 13
- Submitted-by: venta@i2ack.sublink.org (Paolo Ventafridda)
- Archive-name: rnalib2/part03
-
- #!/bin/sh
- # This is part 03 of RNALIB_20
- if touch 2>&1 | fgrep '[-amc]' > /dev/null
- then TOUCH=touch
- else TOUCH=true
- fi
- # ============= RNA ==============
- echo "x - extracting RNA (Text)"
- sed 's/^X//' << 'SHAR_EOF' > RNA &&
- X# @(#)RNA 2.0 [revision A] 18 Sep 1990
- X#
- X# = WELCOME TO RNALIB CONFIGURATION =
- X# ------------------------------------------------------------------------
- X# Your attention please: we strongly suggest that you read carefully
- X# every comment in the following lines. This configuration comes together
- X# with necessary documents, step by step. Skip comments at your own
- X# risk: you may not understand the Operator's Guide later on!
- X# We all hate reading long docs. This is not long, it's just the minimum
- X# you need to know about the program. Consider these comments as
- X# part of the operator's manual. They are *not by any means 'optionals'.
- X# ------------------------------------------------------------------------
- X#
- X# PATH: rna looks for 'sed', 'head' and other usual unix utilities inside
- X# this path definition. Put here your usual paths, like..
- XPATH=/bin:/usr/bin:/usr/local/bin:/etc:/usr/local/etc:.
- X#
- X# Administrator's directory: this is a dedicated directory for rna. System
- X# files such as mail log, accounting etc. will be put here.
- X# This directory will not be public, and should be closed to others
- X# but rnalib owner. This directory will not contain garbage.
- X# You can put the home directory of LOGNAME (see forward).
- X# RNADIR=/usr/rnalib
- XRNADIR=/usr/rnalib
- X#
- X# Temporary directory: garbage stuff is going to be put here.
- X# You might choose a subdirectory of RNADIR; do not choose /tmp, you might
- X# get problems later on. Use a dedicated directory owned by rna.
- X# This folder is not going to take much space anyway.
- XTMPDIR=$RNADIR/tmp
- X#
- X# Temporary directory: IF you allow file compression, outgoing stuff will
- X# be put here and then compressed before ship. You might choose the same
- X# place of TMPDIR. USE a dedicated directory, do not use /tmp.
- XCONVDIR=$RNADIR/convert
- X#
- X# The login used as rna entry: tipically 'rnalib'. Create this entry inside
- X# /etc/passwd. Home directory is not really important: the only needed thing is
- X# that this user has to execute RNA and will receive query and rejected mail.
- X# You'll get more info on how to create this user inside OPER.GUIDE .
- X# By now, just pick up a name. Users will mail this name to access your
- X# libraries. But they could use aliases as well. Don't worry now.
- X#
- XLOGNAME=rnalib
- X#
- X# The name of your machine, as of 'uname -n' or similar.. Hey, dont put
- X# another one, use the correct local machine name. Don't cheat.
- X# If you are under some domain include it. Ex: i2ack.SUBLINK.ORG
- X#
- X#UNAME=host.domain
- XUNAME=i2ack.sublink.ORG
- X#
- X# The local postmaster, i.e. the person which will eventually solve
- X# remote user's problems.
- X# If you don't know what a Postmaster is, you are probably in the
- X# wrong place. Put 'root@$UNAME' and go on, this is only a reference.
- X# Remember to include username AND host (+ domain, if any), for instance
- X# venta@i2ack.SUBLINK.ORG . Postmaster need not to be on the same machine
- X# were RNALIB is placed! Just think of local networks...
- X#POSTMASTER=boss@host.domain
- XPOSTMASTER=venta@i2ack.sublink.org
- X#
- X# When (IF) 'compress 'is used to ship files, their names are extended with
- X# a '.Z'. If your UNIX is a System V, maximum file name lenght is 14; if you
- X# are on BSD, it's 256; if you are on a Olivetti LSX it's 128 etc.
- X# Subtract 2 from your maximum file name lenght and fill the following
- X# variable: for instance, if you have max 14 characters names, put (14-2)=12.
- XMAXLENGTH=12
- X#
- X# The mail file for LOGNAME, complete path. Usually:
- X# /usr/spool/mail/$LOGNAME on Xenix systems and SCO unix
- X# /usr/mail/$LOGNAME on Unix System V and BSD .
- XMAILBOX=/usr/mail/$LOGNAME
- X#
- X# Name of the file containing all of rna logs, status etc.
- X# also called "accounting"..
- X# Be tidy! Keep it inside RNADIR.
- XLOGFILE=$RNADIR/account
- X#
- X# Name of the file which is going to keep record of ALL incoming mails
- X# (NOT the rejected mails...that would be stupid!). You may use this
- X# file as a normal mail folder for programs like 'ELM'. Remember to
- X# clear it out once every while ;-)
- X# Be tidy! Keep it inside RNADIR.
- XMAIL_LOG=$RNADIR/mail
- X#
- X# Name of the public directory for transfers using 'uucp' or 'uusend'.
- X# We suggest a '~' (which leads to /usr/spool/uucppublic) as default;
- X# if you are going to change this, remember that remote sites need this
- X# path to be writable, or your files will be rejected!
- X# Do also consider that some UUCP emulators - such as UFgate or Waffle -
- X# do *not recognize "/usr/spool/uucppublic", but *accept "~".
- XPUBDIR=~
- X#
- X# Debugging would occure on stdout, NOT on LOGFILE.
- X# 1=debug (try it for fun), nodebug= leave it EMPTY, dont put a 0
- X# Debug is for interactive usage only. Do not set debug mode for daemon task.
- XDEBUG=1
- X#
- X# Some progs never in the same place... please tell me: where is the mailer?
- X# I mean the one you would use as 'mail user' to send mail to user.
- X# Ususally /bin/mail, though on some systems you could try /bin/rmail.
- X# Since RNA adds its own Subject line, be sure the mailer does not ask for it!
- X# If RNA messages comes without a Subject this is the reason..
- XMAILER=/bin/mail
- X#
- X# Where is 'uuencode'? I assume you have this utility. If you don't have this
- X# utility you are not likely to ship binary files via mail.
- X#
- XUUENCODE=/usr/local/bin/uuencode
- X#
- X# Where is 'btoa'? If you don't have it, leave it EMPTY (nothing after the = )
- X# Btoa is better than uuencode: it saves some 15% space. You don't really
- X# need it for RNA, but if you happen to have btoa put it here. Default encoding
- X# still will be the good-old uuencode. Beware: i am referring to the second
- X# version of btoa, the one that does not need 'atob' to convert back.
- X# Still this version is compatible with the old release, BUT syntax to use
- X# is quite different. If you have an old version of btoa, no problem: find
- X# the RNA procedure called 'Convert_File()'; there's a 'case' inside, and
- X# a notice about this matter.
- XBTOA=/usr/local/bin/btoa
- X#
- X# Where is 'compress'? If you don't have it, leave it EMPTY
- X# (nothing after the =). It sounds pretty strange to me an empty declaration
- X# here, since the whole world nowdays has compress. Ask for GNU-compress!
- XCOMPRESS=/usr/local/bin/compress
- X#
- X# Where do you keep 'uucp', the usual command?
- X# I know everybody has one. If you don't want files travelling over
- X# the network with 'uucp' then omit the declaration: files will be
- X# travelling in ascii format via normal e-mail.
- X# Caution: read Operator's Guide chapter 'Transmission layers'!
- XUUCP=/usr/bin/uucp
- X#
- X# Where is 'uusend'? If you don't have it, leave it EMPTY (nothing after
- X# the = ). This is a common utility which replaces 'uuto' and 'uucp' on
- X# some old (V7) uucp based systems.
- X# Caution: read Operator's Guide chapter 'Transmission layers'!
- XUUSEND=/usr/local/bin/uusend
- X#
- X# Where is 'file'? As you should know, this is a Berkeley utility now
- X# commonly distributed with almost *every serious unix system.
- X# 'file' examines a specified file and gives informations about it.
- X# Since RNA has to figure out by itself whether or not requested files
- X# are ASCII or BINARY, we definitively *need* the berklish 'file'.
- X# So know, com'on..
- XBKFILE=/bin/file
- X#
- X# Where is 'strings' ? we use it just a couple of times, to grep out
- X# blank lines from 'pathsize' (you'll learn about it later on).
- X# This command is pretty standard, however my 3B2 with Unix 3.2 is
- X# missing it (*sic)! I wrote a small 'strings.c' which you might
- X# compile and use in case there's no 'strings' on your system.
- XSTRINGS=/usr/local/bin/strings
- X#
- X# This is important (;-)). RNA needs an index file containing libraries'
- X# names along with their real paths. Since you are installing RNA for
- X# something, i assume you HAVE at least one 'library', don't you?
- X# With RNA distribution comes a file named 'libindex' which contains
- X# some more docs about its structure. "libindex" is my suggested name for..
- X# [ NOTE: inside OPER.GUIDE we always refer to this suggested name. ]
- XLIBIND=$RNADIR/libindex
- X#
- X# This file contains names/paths which are not allowed to use RNA.
- X# With RNA distribution comes a file named 'black' which contains some
- X# more docs about its structure. "black" is my suggested name for..
- X# [ NOTE: inside OPER.GUIDE we always refer to this suggested name. ]
- XBLACKLIST=$RNADIR/black
- X#
- X# This file contains names/paths which are authorized to forward RNA requests
- X# for others, i.e.: send files to other people. Normally RNA sends back to
- X# the original user/system who sent the mail.
- X# With RNA distribution comes a file named 'white' which contains some
- X# more docs about its structure. "white" is my suggested name for..
- X# [ NOTE: inside OPER.GUIDE we always refer to this suggested name. ]
- XWHITELIST=$RNADIR/white
- X#
- X# If something goes wrong with the mail, RNA will receive back its stuff
- X# from somewhere. Of course this is a dangerous situation, so RNA will
- X# recognize and skip this mail. A copy will be put inside..
- X# [ NOTE: inside OPER.GUIDE we always refer to this suggested name. ]
- XREJECTED=$RNADIR/rejected
- X#
- X#
- X# You may choose to limit rna activities within certain paths to
- X# a definite amount of bytes transmitted. For instance, you would
- X# like to keep an host under control: if that host asks for more than
- X# -say- 300.000 bytes, any further request should be denied. This is
- X# called 'pathsizing'. RNA will check that any request coming from somewhere
- X# has 'credits' before accepting its query; afterwards, its credits will be
- X# updated. Following variable contains the name of the file which is going
- X# to keep paths&credits notes.
- X# If you don't care about 'pathsizing', leave it blank.
- X# [ NOTE: inside OPER.GUIDE we always refer to this suggested name. ]
- XPATHSIZE=$RNADIR/pathsize
- X#
- X# (Needed only if you chose pathsizing above)
- X# If a path is not appearing inside pathsize, by default a no-limit credit
- X# is given. You may want RNA to automatically add any new path to its
- X# pathsize, with a default credit given. So...
- X# Put a 0 if you want that new sites ask to be registered before being
- X# authorized to use your RNA service. Any new path will be notified
- X# that a membership is required in order to use your service.
- X# Put a size in bytes -say 200000 (do not put any fullstops!)- as default
- X# credit limit for any new path. 'pathsize' will be updated with
- X# this new path and this number.
- X# Leave it BLANK if you don't want to limit new paths. This way only paths
- X# already included inside 'pathsize' will be affected by pathsizing.
- X# More info inside RNA Operator's Guide, chapter 'Pathsizing'.
- XCREDIT=300000
- X#
- X# You are done. No more variables to configure. You need to check for
- X# RNADIR TMPDIR CONVDIR and (if not '~') PUBDIR existance; remind!
- X# NOW search forward for ' %%FIX%% ' : these are entry points for
- X# possible configuration-dependent problems. Do check every %%FIX%%
- X# and be sure everything is ok. The last %%FIX%% has some more
- X# informations for you. Do carefully follow %%FIX%% (again) until
- X# the last one (it tell's you that you got to the final fix, don't
- X# worry). Happy 'tuning'!
- X#
- X# ==============================================================
- X#
- X# Internal tmp files.
- X# -------------------
- XMBOX_COPY=$TMPDIR/tmp
- XMBOX_CUT=$TMPDIR/cut
- XCMDS=$TMPDIR/tmpcmds
- XCMDLOG=$TMPDIR/commlog
- XPOINTERS=$TMPDIR/punt
- XERRSTAT=$TMPDIR/err
- XOUTFILE=$TMPDIR/outfile
- XUUCP_ADDRESS=$TMPDIR/address
- X# -------------------- some procedures... ----
- X
- X# %%FIX%%
- XGetMail() {
- X# This function does three things; 1st) moves rnalib mailbox into
- X# a temporary file. 2nd) creates back a new empty rnalib mailbox
- X# 3rd) archives the temporary files inside another mailbox file.
- X# You might need to fix JUST the 2ND thing..
- X rm $MBOX_COPY 2>/dev/null
- X mv $MAILBOX $MBOX_COPY
- X# .. here it is: we CREATE BACK THE ORIGINAL MAILBOX, for instance
- X# /usr/spool/mail/rnalib or /usr/mail/rnalib or whatever.
- X# A simple 'touch $MAILBOX' could do; HOWEVER be *very *sure that
- X# the new mailbox has the right owner/group permissions once created.
- X# This is all you need: a regular empty folder, just like a normal one.
- X# Here are some suggestions:
- X# '>$MAILBOX' (easy to start with)
- X# 'touch $MAILBOX; chown $LOGNAME $MAILBOX; chgrp mail $MAILBOX;
- X# chmod 620 $MAILBOX' etc. Watch out for that 620, you might need
- X# to change it; just an example!
- X# Don't panic and carefully fix the following line:
- X#
- X touch $MAILBOX; chown $LOGNAME $MAILBOX; chgrp mail $MAILBOX; chmod 666 $MAILBOX
- X#
- X# That's all. Leave the rest as-it-is. Go on for the next fix..
- X touch $MAIL_LOG; echo "`cat $MBOX_COPY`\n" >>$MAIL_LOG
- X}
- X
- XStartup() {
- X touch $LOGFILE
- X message=1
- X}
- X
- XClrTmpFiles() {
- X rm -f $CMDLOG 2>/dev/null; touch $CMDLOG
- X rm -f $ERRSTAT 2>/dev/null; touch $ERRSTAT
- X rm -f $CMDS 2>/dev/null
- X rm -f $CONVDIR/*.Z 2>/dev/null
- X rm -f $UUCP_ADDRESS 2>/dev/null; touch $UUCP_ADDRESS
- X rm -f $OUTFILE 2>/dev/null; touch $OUTFILE
- X ARPA_SENDER=""; UUCP_SENDER=""; REQUEST_DATE=""; UUCP_HOST=""
- X UUCP_DESTIN=""
- X}
- X
- XCutMail() {
- XNotTheFirst=0
- Xrm -f $POINTERS 2>/dev/null; touch $POINTERS
- X
- Xgrep -n '^From ' $MBOX_COPY | PrintSumm
- Xset `cat $MBOX_COPY | wc -l`; echo $1 >>$POINTERS
- X}
- X
- XPrintSumm()
- X{
- X IFSorg=$IFS
- X while read Linea
- X do
- X IFS=$IFSorg
- X set $Linea
- X
- X# %%FIX%%
- X# This is a VERY IMPORTANT FIX- watch out!
- X# Question: how many fields has the very first 'From' line of a
- X# mail message on YOUR system?
- X# To answer, do a shell escape from your editor NOW and mail yourself
- X# a message. Then edit your mailbox, and examine the first From, the
- X# one WITHOUT colons. Here's mine, for instance:
- X# From deejay!gear!marlor Wed Feb 21 12:32:44 1990
- X# 1 2 3 4 5 6 7
- X# So i know my mailer adds a 7-field From header.
- X# Your mailer could add a timezone as well, and you would get 8 fields.
- X# RNA does not trust by default any (apparently) valid header.
- X# We extract the beginning of a mail inside our mailbox looking for
- X# a 'From '(note the space) standing on a 7 (or whatever) fields line.
- X# [ELM 2.2 just looks for a From with a space and more than 2 fields]
- X# Replace the following number with the one you need:
- X
- X if [ $# = 7 ]
- X then
- X IFS=":$IFSorg"
- X set $Linea
- X NumDiLinea=$1
- X if [ $NotTheFirst != 0 ]
- X then
- X echo "`expr $NumDiLinea - 2`" >>$POINTERS
- X fi
- X echo "$NumDiLinea \c" >>$POINTERS
- X NotTheFirst=1
- X fi
- X done
- X
- X IFS=$IFSorg
- X}
- X
- XCut_Address() {
- X echo "$UUCP_SENDER" >> $UUCP_ADDRESS
- Xif [ "$destination" != "DEFAULT" ]; then
- X set `sed -e "s/@/@ /" $UUCP_ADDRESS`; UUCP_HOST=$2"!"
- Xelse
- X set `sed -e "s/[A-Za-z0-9]*$//g" $UUCP_ADDRESS`; UUCP_HOST=$1
- Xfi
- X}
- X
- XGetMessage() {
- X set `sed -n "$1 l" $POINTERS`
- X sed -n "$1,$2 l" $MBOX_COPY >$MBOX_CUT
- X}
- X
- XGetDir()
- X# this function gets a library name and returns its related path.
- X# If library does not exist, nothing is returned. An argument is
- X# expected. Lines containing " # " in $LIBIND are simply skipped.
- X{
- Xsearch=$1
- Xset -f `grep -v '^#' $LIBIND`
- Xwhile [ "$1" != "" ]
- Xdo
- X test "$1" = "$search" && shift && echo $1 && break
- X shift
- Xdone
- X}
- X
- X
- XStripPermAndLink()
- X{
- X while read line
- X do
- X set -- $line
- X echo "$3\t$4,$5\t$6\t$7"
- X done
- X}
- X
- X
- XFileType()
- X# Arg: file_path (full)
- X# Returns: null if file is ASCII-TEXT; output of "file" command if not.
- X{
- Xfilename=$1; IFSorg=$IFS
- XIFS=":"; set `echo "dummy"; $BKFILE $filename | grep -v text`; IFS=$IFSorg
- Xtest -n "$2" && echo $2
- X}
- X
- X
- X
- XGetFile()
- X# Parameters: static $argument $from
- X# Returns: path_to_file; null if file does not exist
- X{
- XGFpath=`GetDir $from`
- Xif [ "$GFpath" != "" ]; then
- X test -r $GFpath/$argument && echo $GFpath/$argument
- Xfi
- X}
- X
- XListLib()
- X# Parameters: library
- X{
- XLLlib=$1
- XLLpath=`GetDir $LLlib`
- Xecho "\nList of files inside \c"
- X
- Xif [ "$LLlib" = "DEFAULT" ]; then
- X echo "RNA system library:";
- Xelse
- X echo "\"$LLlib\" library:\n"
- Xfi
- X
- Xif [ "$LLpath" = "" ]
- Xthen
- X NoLibrary_Msg
- Xelse
- X ls -got $LLpath | StripPermAndLink
- Xfi
- X}
- X
- XFindFile()
- X# Parameters: characters to match in searched file
- X# Returns: matching libraries and files, if any
- X{
- XFFchars=$1; FFmatch=
- Xecho "\nREQUEST: search for file names containing <$FFchars>."
- Xecho " Look inside all available libraries, and\n\
- X try both lower/upper case combinations.\n"
- Xecho "=====================================================\n"
- Xset -f `grep -v '#' $LIBIND`
- Xwhile [ "$1" != "" ]
- Xdo
- X FFlib=$1; FFpath=$2;
- X# %%FIX%%
- X# On Unix V.3.2 (?) like the one from SCO, the 3B2 etc., grep's family
- X# commands follow Posix. Posix suppressed '-y' and added '-i'.
- X# Jesus, all we want is a non-case sensitive grep! If you run sco-xenix 386,
- X# 'grep -y' should work. If you are on SCO-unix, 'fgrep -y' will.
- X# Generally, 'fgrep -i' is a good chance (3B2 Unix 3.2)
- X# Have a look at your grep/fgrep and pick up the right one. Change the
- X# following line, if needed..................++++++++
- X ls -got $FFpath | StripPermAndLink | fgrep -i $FFchars && {
- X echo "\nfound inside library: \"$FFlib\""
- X echo "\n=====================================================\n"
- X FFmatch=ok
- X }
- X shift; shift
- Xdone
- Xtest -z "$FFmatch" && {
- X echo "\tNo matching files found - sorry"
- X echo "\n=====================================================\n"
- X }
- X
- X}
- X
- XCut_Ls()
- X# %%FIX%%
- X# We need to grep out of 'ls -log' the bytes number. Since the output
- X# of that 'ls' is: -rwxr-xr-x 1 33275 Feb 8 12:25 RNA
- X# we use 'cut' (a common text utility) to pick up the right field.
- X# On my system it came out from the 15th to 23th characters. Check yours too,
- X# and find the right "-cn-n" (n=number) which extracts bytes. Good luck.
- X# (Don't panic: on sco xenix386, sco unix, olivetti lsx, hp-ux and at&t 3b2
- X# the 15-23 was fine. Probably it's ok for your site also)
- X#
- X{
- Xcut -c15-23
- X}
- X
- XGetCat()
- X{
- Xlibr=$1
- Xif [ "`GetDir $libr`" = "" ]; then
- X NoLibrary_Msg
- Xelse
- X file="`GetDir $libr`/INDEX"
- X test -r $file && echo "\n`cat $file`" || echo "\n\
- XNo index available for \"$1\" library, sorry.\n\
- XHere comes a list of contents..."
- Xfi
- X}
- X
- XBlackList()
- X# Gets internal uucp-from path and checks if it's blacklisted.
- X# Returns: blacklist matching, or nothing at all.
- X{
- Xset -f `grep -v '#' $BLACKLIST`
- Xwhile [ "$1" != "" ]
- Xdo
- X test -n "`echo $UUCP_SENDER | grep $1`" && {
- X echo "<$1> is matched inside <$UUCP_SENDER>" && break; }
- X shift
- Xdone
- X}
- X
- XToCheck()
- X# checks if sender is authorized to use "To" or not.
- X# returns a string if it's ok, nothing if not.
- X{
- Xset -f `grep -v '#' $WHITELIST`
- X#while test -n "$1"
- Xwhile [ "$1" != "" ]
- Xdo
- X test -n "`echo $UUCP_SENDER | grep $1`" && {
- X echo "<$1> is matched inside <$UUCP_SENDER>" && break; }
- X shift
- Xdone
- X}
- X
- XWith_Type()
- X{
- Xencode_type="none"; compress_type="none"
- Xcase $with in
- X compr|Compr|COMPR|\
- X compress|COMPRESS|Compress)
- X encode_type="uuencode"
- X compress_type="compress"
- X ;;
- X
- X compr-btoa|Compr-Btoa|COMPR-BTOA|\
- X compress-btoa|COMPRESS-BTOA|\
- X Compress-Btoa)
- X encode_type="btoa"
- X compress_type="compress"
- X ;;
- X
- X compr-uuenc|Compr-Uuenc|COMPR-UUENC|\
- X compress-uuencode|COMPRESS-UUENCODE|\
- X compress-encode|COMPRESS-ENCODE|\
- X Compress-Uuencode|Compress-Encode)
- X encode_type="uuencode"
- X compress_type="compress"
- X ;;
- X
- X DEFAULT|UUENCODE|ENCODE|\
- X uuencode|encode|ascii|\
- X Uuencode|Encode|ASCII)
- X encode_type="uuencode"
- X compress_type="none"
- X ;;
- X
- X BTOA|btoa|Btoa)
- X encode_type="btoa"
- X compress_type="none"
- X ;;
- X
- X# %%FIX%%
- X# The sender used a strange "with" field; a default behaviour
- X# follows. Put 'reject' as encode_type if you do not want any mailing
- X# whenever there's an invalid 'with'.
- X# Currently this error is ignored (with a warning) and the stuff is
- X# shipped all the same using uuencode.
- X# This is just to let you know you can do it. No need to touch it
- X# for a normal usage.
- X
- X *)
- X encode_type="uuencode"
- X compress_type="none"
- X WithError_Msg >>$OUTFILE
- X NeedHelp_Msg >>$OUTFILE
- X ;;
- Xesac
- X
- Xif [ "$compress_type" != "none" ]; then
- Xset `echo $argument | wc -c`; length=`expr $1 - 1`
- X if [ "$length" -gt "$MAXLENGTH" ]; then
- X NoSuffix_Msg >> $OUTFILE
- X echo "\
- XSubject: WARNING, file name too long for RNA compress\n\n\
- X Please rename file: \"$fname\" if possible.\n\
- X Its name is longer than \"$MAXLENGTH\" characters and\n\
- X RNA users can't ask for \"$COMPRESS\" shippings.\n\n\
- X Your friendly RNALIB DAEMON\n" | $MAILER $POSTMASTER
- X return
- X else
- X FCPRNAME=$CONVDIR/$argument".Z"
- X argument=$argument".Z"
- X fi
- X# Check if 'compress' is available.
- X test $COMPRESS || { NoCompr_Msg >> $OUTFILE; return; } && $COMPRESS -c $fname > $FCPRNAME
- X test -s $FCPRNAME || { Already_Msg >> $OUTFILE; return; } && fname=$FCPRNAME
- X Compr_Msg >>$OUTFILE
- Xfi
- X
- X}
- X
- XConvert_File()
- X{
- Xftype=""; ftype="`FileType $fname`"
- X
- Xif [ "$viasped" != "NO_MAIL" ]; then
- X
- X# Did the sender request a special "with" for a simple ASCII file?
- X# If so, we reject his request and ship the file as-it-is.
- Xtest $with != "DEFAULT" && test "$ftype" = "" && NoNeed_Msg >>$OUTFILE
- X
- Xif [ "$ftype" = "" ]; then
- Xencode_type="none"
- Xfi
- X
- X# If user asked for btoa encoding, see if btoa is available.
- X# If btoa is not available we WON'T use uuencode; i suppose the sender had
- X# some reasons to choose btoa...
- Xif [ "$encode_type" = "btoa" ]; then
- X test $BTOA || { NoBtoa_Msg >>$OUTFILE; return; } && Convert_Msg >>$OUTFILE
- Xfi
- X# The following 'fi' refers to 'viasped != no_mail'.
- Xfi
- X
- Xtest "$encode_type" = "uuencode" && test "$viasped" != "NO_MAIL" && Convert_Msg >>$OUTFILE
- X
- X# We are about to ship the stuff; let's see if the destination address is
- X# different from the sender. If so, it's an authorized "external request"
- X# and we want to notify the destination about it.
- X# Beware of 'reject' encode_type: we want to be sure that the stuff is sent
- X# to the external destination only, in this case. Error announcements HAVE
- X# to go to the original sender (what a mess!).
- Xif [ "$encode_type" != "reject" ]; then
- X if [ "$destination" != "DEFAULT" ]; then
- X echo "\n\
- XNote: this is an external request forwarded by $ARPA_SENDER for you.\n\
- X Original mail path is: <$UUCP_SENDER> .\n\
- X " >>$OUTFILE
- X fi
- Xfi
- X
- Xtest "$viasped" != "NO_MAIL" &&
- X echo "\n-rnalib---------------------- cut here for \"$argument\" ------------" >>$OUTFILE
- X
- Xcase $encode_type in
- X
- X# syntax: uuencode path/file internal_filename
- X uuencode)
- X if [ "$viasped" = "NO_MAIL" ]; then
- X NoConv_Msg >> $OUTFILE
- X else
- X $UUENCODE $fname $argument >>$OUTFILE
- X fi ;;
- X
- X# %%FIX%%
- X# Syntax: btoa path/file -- warning: using old versions of btoa requires
- X# 'cat $fname | btoa >>$OUTFILE' or something like. Get the new release!
- X btoa)
- X if [ "$viasped" = "NO_MAIL" ]; then
- X NoConv_Msg >> $OUTFILE
- X else
- X $BTOA $fname >>$OUTFILE
- X fi ;;
- X
- X# encode_type equals "none" only if file is not binary, or if it
- X# going to be shipped with uusend or uucp (if available)
- X none)
- X if [ "$viasped" = "NO_MAIL" ]; then
- X NoConv_Msg >> $OUTFILE
- X else
- X cat $fname >>$OUTFILE
- X fi ;;
- X
- X# Configuration choice: if $with is not a valid argument don't ship
- X# the binary encoding with "uuencode"; notify the sender, though.
- X reject) echo "\nPlease re-submit your request with proper parameter\n" >>$OUTFILE;;
- X
- X *) echo "\nRNA INTERNAL ERROR inside procedure Convert_File\n" >>$OUTFILE
- X echo "WARNING: convert internal error (notified to operator)" >>$LOGFILE
- X test $DEBUG && echo "Internal error: encode_type=$encode_type";;
- X
- Xesac
- X
- Xtest "$viasped" != "NO_MAIL" &&
- X echo "\n-rnalib----------------------- end of file \"$argument\" ------------" >>$OUTFILE
- X
- X# Be *very sure we are not shipping errors to an external destination!
- Xif [ "$encode_type" != "reject" ]; then
- X if [ "$destination" != "DEFAULT" ]; then
- X
- X# change destination...and good luck for delivery!
- X
- X UUCP_SENDER=$destination
- X ARPA_SENDER=$destination
- X fi
- X echo "Sent < $argument from $from - via $via > to $ARPA_SENDER" >>$LOGFILE
- Xfi
- X
- X}
- X
- X
- XMail_File()
- X{
- Xtest $DEBUG && echo "Now mailing: $UUCP_SENDER"
- XSignature >>$OUTFILE
- X# %%FIX%%
- X# If you trust or need domain addressing, then change $UUCP_SENDER
- X# with $ARPA_SENDER. Think about this twice; let the bang routing
- X# unless you *know *what *you *are *doing.
- X# This won't work with external destinations, of course.
- X# If mail header did not contain an rfc822 arpa address then
- X# don't worry: arpa_sender will just be a copy of uucp_sender.
- Xcat $OUTFILE | $MAILER $UUCP_SENDER
- X# We need to grep out of 'ls -log' the bytes number.
- Xset `ls -log $OUTFILE | Cut_Ls`
- Xecho "Reply of $1 bytes sent to: $UUCP_SENDER" >>$LOGFILE
- X#
- Xtest -n "$PATHSIZE" && Bill $OUTFILE
- Xrm -f $OUTFILE 2>/dev/null; touch $OUTFILE
- X}
- X
- X
- XCheck_PathSize()
- X# $1 = path/user to check
- X# returns: null if unknown path; otherwise current credit size.
- X{
- Xps_origin=$1
- X# Warning: file 'pathsize' in this version of RNA needs a dummy line
- X# like ' user 0 ' or 'user@host 0' for the *very *first user update.
- X# In other words, if you are applying pathsizing, your 'pathsize'
- X# has to contain a first line to work on. Pathsize cannot be empty!
- X# Technically, what happens is that shell gets angry since it
- X# cannot shift 'ps_credit'. This will be fixed in future versions.
- Xset -f `grep -v '#' $PATHSIZE`
- Xwhile [ "$1" != "" ]; do
- X ps_path=$1; ps_credit=$2; shift; shift
- X test -n "`echo $ps_origin | grep $ps_path`" && echo $ps_credit && break
- Xdone
- X}
- X
- X
- XAdd_PathSize()
- X# It's named 'Add', but really it subtracts sizes!
- X# $1 = path/user to update; $2 = umount to subtract
- X{
- Xps_origin=$1; ps_size=$2;
- X# strip comments, as usual
- Xset -f `grep -v '#' $PATHSIZE`
- Xwhile [ "$1" != "" ]; do
- X ps_path=$1; ps_credit=$2; shift; shift
- X# Is this path matching the one we are checking?
- X test -n "`echo $ps_origin | grep $ps_path`" && {
- X# Yep. Let's calculate the new credit, and...
- X ps_size=`expr $ps_credit - $ps_size`
- X# ..update the pathsize database. Ugly 'ed' script!
- X ed - pathsize >/dev/null <<OoPs
- X /$ps_path.*$ps_credit/
- X s/\(.*\) \(.*\)/\1 $ps_size/
- X w
- X q
- XOoPs
- X# All done; get back!
- X return
- X }
- Xdone
- X# This path does not exist inside our pathsize database. Uhm..
- X# If CREDIT is defined, we add the new path to our database. We assume
- X# that CREDIT is not '0': a previous check on this value would have
- X# rejected any request and we wouldn't be here. So either 'credit' has
- X# a value different from zero, or it is not defined at all. Trust me!
- Xtest -n "$CREDIT" && {
- X ps_size=`expr $CREDIT - $ps_size`
- X echo "$ps_origin $ps_size" >>$PATHSIZE
- X }
- X}
- X
- XBill() {
- X
- Xif [ "$credit" != "UNLIMITED" ]; then
- X
- X# bill destination of $1 lenght
- X ( set `ls -log $1 | Cut_Ls`
- X Add_PathSize $UUCP_SENDER $1
- X )
- Xfi
- X}
- X
- X
- X#
- X# RNA 2.0 MESSAGES - Warning: change at your own risk!
- X#
- X
- XHeaders_Msg()
- X{
- X# DON'T CHANGE the 'X-Mailer' line by *any means. Future versions of
- X# RNA will talk to each other (sort-of networking!) and will need
- X# to know exactly which version is on the other side.
- Xspedresult=`Reference_Cmd`
- Xecho "\
- XX-Mailer: RNALIB 2.0 [Rev.A]\n\
- XX-Sender: $ARPA_SENDER\n\
- XSubject: RNA answer: $spedresult"
- X
- Xtest -s $RNADIR/notice && cat $RNADIR/notice
- X}
- X
- XNoHuman_Msg()
- X{
- Xecho "\
- XThis message has been generated by a program. To talk to a human,\n\
- Xsend mail to $POSTMASTER. Special requests of details on\n\
- XRNA delivers may be submitted to this address only."
- X}
- X
- XExample_Msg()
- X{
- Xecho "\
- XHere are some example requests, in case syntax is the problem:\n\
- X\n\
- X @@ help\n\
- X @@ index\n\
- X @@ index {library}\n\
- X @@ list {library}\n\
- X @@ find {filename}\n\
- X @@ credits\n\
- X @@ send {file} from {library}\n\
- X @@ send {file} from {library} with {compress-uuencode}\n\
- X @@ send {file} from {library} with {btoa} via {uucp}\n\
- X @@ send {file} from {library} with {uuencode} via {uusend}\n\
- Xetc.etc."
- X}
- X
- XNeedHelp_Msg()
- X{
- Xecho "\
- XIf you need help on RNA commands syntax, a doc file is available\n\
- Xhere. You might get it by mailing $LOGNAME@$UNAME , with either\n\
- Xmessage body or Subject containing: @@ help."
- X}
- X
- XNoFile_Msg()
- X# $1=LIBRARY $2=FILE-NAME
- X{
- Xif [ "$1" != "DEFAULT" ]; then
- X echo "\n\
- XSorry, no such file was found. Recheck library contents.\n\
- XTo do that, use the RNAlib command: @@ list $1\n\
- XFor a verbose description of files use: @@ index $1"
- Xelse
- X echo "\
- XSorry no such file was found inside RNALIB system directory.\n\
- XPlease recheck library contents with : @@ list\n\
- XFor a list of available libraries and description of \n\
- Xavailable system files try: @@ index "
- Xfi
- Xecho "\n\
- XYou may also scan the whole library system looking for a particular\n\
- Xfile-name or part of it; use: @@ find {chars}. Example: @@ find doc\n\
- Xwould list all available files whose names contain \"doc\". \n\
- XIf you insist on this file-name, then try: @@ find $2 \n\
- XIf all of this doesn't explain the problem, send a complaint\n\
- Xto postmaster here: $POSTMASTER"
- X}
- X
- XNoLibrary_Msg()
- X{
- Xecho "\
- XSorry, this library does not exist! Recheck the general index.\n\
- XTo do that, try the RNA command: @@ index \n\
- XIf that doesn't explain the problem, send a complaint\n\
- Xto: $POSTMASTER"
- X}
- X
- XCantAccess_Msg()
- X{
- Xecho "\
- XSorry, i could not read \"$argument\" inside selected library : \n\
- Xthere might be local problems with fileystem permissions here.\n\
- XTry contacting the postmaster for some explanations."
- X}
- X
- XYourMail_Msg()
- X{
- Xecho "\nYour mail, as received here, was...\n\
- X--------------------------------------------"
- Xcat -v $MBOX_CUT
- Xecho "\n--------------------------------------------"
- X}
- X
- XSyntax_Msg()
- X{
- Xecho "\
- XSorry, the RNAlib program could not understand your request.\n"
- XNeedHelp_Msg
- Xecho; Example_Msg; echo; YourMail_Msg
- X}
- X
- XBadChars_Msg()
- X{
- Xecho "\
- XYour request included shell magic characters inside $1 command line(s).\n\
- XSuch characters like \*, | , / , dots etc. are PROHIBITED for security\n\
- Xreasons: the whole message has been discarded for this reason."
- X}
- X
- XNoCommands_Msg()
- X{
- Xecho "\
- XRNAlib could not find any command-lines inside your mail-request.\n"
- XNeedHelp_Msg
- Xecho; Example_Msg; echo; YourMail_Msg
- X}
- X
- XNoTo_Msg()
- X{
- Xecho "\
- XSorry, you are not authorized to use the \"TO\" field inside RNA requests.\n\
- XSpecial permissions should be submitted to $POSTMASTER, along with\n\
- Xsome good reasons for such capability."
- X}
- X
- XBlackListed_Msg()
- X{
- Xecho "\
- XSorry, you cannot forward RNALIB-requests here: your site is off-limits.\n\
- XThere's also a chance that your site is placed on a blacklisted path,\n\
- Xand though rejected; it could also be that your address and/or name\n\
- Xjust looks exactly as a blacklisted one."
- X}
- X
- XDeliver_Msg()
- X{
- Xecho "\
- XThis is the RNALIB output for a request destinated to you.\n\
- XEnquiry was sent on $REQUEST_DATE by <$ARPA_SENDER>."
- X}
- X
- X
- XReference_Cmd()
- X{
- Xtest -z "$action" && echo "problems." && exit
- Xecho "\"$action\c"
- Xtest "$argument" != "DEFAULT" && echo " $argument\c"
- Xtest "$from" != "DEFAULT" && echo " [from] $from\c"
- Xtest "$destination" != "DEFAULT" && echo " [to] $destination\c"
- Xtest "$with" != "DEFAULT" && echo " [with] $with\c"
- Xtest "$via" != "DEFAULT" && echo " [via] $via\c"
- Xecho "\"\n"
- X}
- X
- XReference_Msg()
- X{
- Xecho "Command referenced: `Reference_Cmd`"
- X}
- X
- XConvert_Msg()
- X{
- Xecho "\
- XThis file appears to be a $ftype:\n\
- Xit has been transformed into an ASCII-format using \"$encode_type\".\n\
- X"
- X}
- X
- XNoNeed_Msg()
- X{
- Xecho "\
- XField \"with\" ignored: file is already ASCII-text."
- X}
- X
- XNoSuffix_Msg()
- X{
- Xecho "\
- XWARNING: requested file \"$fname\"\n\
- X has NOT been compressed since its longer than \"$MAXLENGHT\"\n\
- X characters permitted by \"$COMPRESS\". The problem has been\n\
- X notified to $POSTMASTER here. Sorry for the inconvenience.\n\
- X"
- X}
- X
- XNoConv_Msg()
- X{
- Xecho "\
- XField \"with\" ignored: file hasn't been converted since\n\
- Xit comes via \"$via\".\n\
- X"
- X}
- X
- XCompr_Msg()
- X{
- Xecho "\
- XThis file has been converted with utility \"$COMPRESS\"\n\
- XYou need to convert it back with something like \"uncompress\"\n\
- Xor \"compress -d\".\n\
- X"
- X}
- X
- XShip_Msg()
- X{
- Xecho "\
- XFile requested for \"$ARPA_SENDER\" and destinated to \"$UUCP_HOST\"\n\
- Xis coming inside your system public directory via \"$via\".\n\
- XCheck it out! It should already be there.\n\
- X"
- X}
- X
- XNoCompr_Msg()
- X{
- Xecho "\
- XWARNING: \"compress\" is not available here!\n\
- XYour file has been sent without any compression. Sorry.\n\
- X"
- X}
- X
- XAlready_Msg()
- X{
- Xecho "\n\
- XThis file hasn't been compressed since it ALREADY was compressed!\n\
- XAny file whose name terminates with a \".Z\" is compressed: take care!\n\
- XYou can get a list of file names inside a specific library\n\
- Xwith RNA command \"list library\".\n\
- X"
- X}
- X
- XViaError_Msg()
- X{
- Xecho "\
- XWarning! Field \"with\" ignored: <$with> is not a valid identifier.\n\
- XThis file has been sent via normal \"e-mail\".\n\
- X"
- X}
- X
- XPending_Msg() {
- Xecho "\
- XX-Mailer: RNALIB 2.0 [Rev.A]\n\
- XSubject: RNA is out of service on $UNAME\n\n\
- XHello. RNALIB on $UNAME is temporarily out of service.\n\
- XYour request of $REQUEST_DATE has been queued and will be processed\n\
- Xas soon as the service is resumed.\n\n\
- X`cat $RNADIR/hold`\n\n
- X`Signature`"
- X}
- X
- XWithError_Msg()
- X{
- Xecho "\
- XWarning! Field \"with\" ignored: <$with> is not a valid identifier.\n\
- XThis file has been transformed into an ASCII-format using \"uuencode\"."
- X}
- X
- XNoBtoa_Msg()
- X{
- Xecho "\n\
- XWARNING: \"btoa\" translation is not available here!\n\
- XPlease re-submit your request without further \"with\" field;\n\
- Xnon-ascii files will be treated with \"uuencode\"."
- X}
- X
- XSignature()
- X{
- Xecho "\n\
- X--\n\
- X|RNALIB|SERVER| | running at: \"$UNAME\"\n\
- X|rnalib|server| | postmaster: $POSTMASTER"
- X}
- X
- XNoCredit_Msg() {
- X echo "\
- XX-Mailer: RNALIB 2.0 [Rev.A]\n\
- XSubject: your path is out of RNA credits\n\n\
- XThe mail path you are coming from has exceeded its transmission's limits.\n\
- XIn order to keep network trafic under control, we fix a credit size for\n\
- Xcertain paths: currently your site results to be out of credits.\n\
- XYou may ask $POSTMASTER for a credit reset; until then, all\n\
- Xrnalib queries from your path are ignored.\n\
- XYou may in the future ask rnalib which is the current credit size which\n\
- Xapplies to your path, using: \"@@ credits\".\n"
- XYourMail_Msg
- XNoHuman_Msg
- XSignature
- X}
- X
- XSubScribe_Msg() {
- X echo "\
- XX-Mailer: RNALIB 2.0 [Rev.A]\n\
- XSubject: Please subscribe for rnalib service\n\n\
- XHello.\n\
- XRNALIB service here on $UNAME requires a subscription to the \n\
- Xauthorized user's list.\n\
- XPlease mail $POSTMASTER asking for registration before any further query.\n\
- X Thank You\n"
- XYourMail_Msg
- XNoHuman_Msg
- XSignature
- X}
- X
- X# End of messages-
- X
- Xparse() {
- Xecho "\n`date '+%d.%m.%y - %H:%M:%S'`" >>$LOGFILE
- Xtest $DEBUG && echo "Parsing message.."
- X# Watch out for rejected mails! Don't waste time..
- X
- Xrejected=""; grep "X-Mailer: RNALIB" $MBOX_CUT >/dev/null && rejected=1;
- Xif [ "$rejected" = "1" ]; then
- X test $DEBUG && echo "Skip this mail: it was rejected from remote"
- X echo "\n`cat $MBOX_CUT`" >>$REJECTED
- X
- X echo "Priority: all\nSubject: RNA delivery rejected\n\n\
- XAn RNA delivery was rejected from remote. A copy of the following\n\
- Xdiagnostic has been archived inside $REJECTED as usual.\n\
- XHere comes the stuff i received....\n\n\
- X`cat $MBOX_CUT`\n\n Your friendly RNALIB DAEMON" | $MAILER $POSTMASTER
- X
- X return
- Xfi
- X
- X# get the first From path for a (un)trustable bang-reply ;-)
- Xset `head -1 $MBOX_CUT`; UUCP_SENDER=$2
- Xecho "Request received from: $UUCP_SENDER" >>$LOGFILE
- X# get the ARPA address of the sender. A real hack upon rfc822..
- Xset `wc -l $MBOX_CUT`; end=$1; rline=2
- Xuntil [ "$rline" = "$end" ]
- Xdo
- X rrline=`sed -n "$rline l" $MBOX_CUT`
- X test -z "$rrline" && rline=$end && break
- X set -f $rrline
- X if [ "$1" = "From:" ]; then
- X# Here we are, trying to fit the (in)famous rfc822.
- X# Rule of dumb: if only one field, it's it.
- X if [ "$#" = "2" ]; then
- X ARPA_SENDER=$2
- X# Retry: if one of the fields contains "<>", it's it.
- X# We just check for the open '<'; we won't consider
- X# drunk mailers. We also assume that <address> is the
- X# last field on the line.
- X elif [ "`echo $@ | grep '<'" != "" ]; then
- X IFSorg=$IFS; IFS="<>"
- X set $@; ARPA_SENDER=$2;
- X elif [ "`echo $@ | grep '('" != "" ]; then
- X# Back on: if one of the fields contains "()", the other
- X# is the good one. We assume that (Full Name) is the last
- X# field on the line.
- X IFSorg=$IFS; IFS="( )"
- X set $@; ARPA_SENDER=$2
- X fi
- X# If this is not enough, you'll have to find out yourself
- X# the way to get arpa-addresses on your site. Send a copy of
- X# the object header to me, so that i'll add that
- X# specification for the next rna release.
- X IFS=$IFSorg
- X fi
- X test "$1" = "Date:" && REQUEST_DATE="$2 $3 $4"
- X rline=`expr $rline + 1`
- Xdone
- Xtest -z "$ARPA_SENDER" && ARPA_SENDER=$UUCP_SENDER
- Xtest -z "$REQUEST_DATE" && REQUEST_DATE="(unknown date)"
- X
- Xtest $DEBUG && echo "UUCP incoming address: $UUCP_SENDER"
- Xtest $DEBUG && echo "ARPA incoming address: $ARPA_SENDER"
- Xtest $DEBUG && echo "date of original mail: $REQUEST_DATE"
- X
- X# Now we know everything we need about our incoming message.
- X# Let's see if the rna service is on hold for some reason...
- Xtest -r $RNADIR/hold && {
- X# ..yep. We touch and fill 'pending'. An empty 'pending' should *never
- X# exist. Rna at startup would claim there are pending jobs.
- X touch $RNADIR/pending; echo "`cat $MBOX_CUT`\n" >>$RNADIR/pending
- X Pending_Msg | $MAILER $UUCP_SENDER
- X return
- X}
- X
- X
- X# get command lines from the message (if any)
- Xgrep '@@' $MBOX_CUT >$CMDS
- X
- X# Some pre-parsing for naughty characters.. If security problems are
- X# detected inside command lines belonging to the same message, the WHOLE
- X# message is rejected. We never know what these hackers can try nowadays ;-)
- X# BEWARE: what we do is searching with egrep for these characters:
- X# * | ? " . / '
- X# I gave up trying to grep also: ` and \ (egrep gives errors).
- X# Using these characters, though, gives no results from the "hacker's point
- X# of view". So the stuff should be quite secure right now.
- X# %%FIX%%
- X# We use 'egrep' here. If you don't have a 'egrep' try using the normal
- X# 'grep' with some hacks. The aim is to fit the 'if' condition whenever
- X# magic characters are detected inside command lines.
- X# If you can't come to anything working, then replace the following line
- X# with 'error=0' and watch out for enemies on the net!
- Xerror=`egrep -c "\*|\||\?|\"|/|\'" $CMDS`
- Xif [ "$error" != "0" ]; then
- X test $DEBUG && echo "WARNING: security problems, mail rejected"
- X echo "SECURITY problems with $ARPA_SENDER" >>$LOGFILE
- X BadChars_Msg $error >$ERRSTAT
- X# We need this so the interpreter will stop arguing about external dest.
- X destination=DEFAULT
- X return
- Xfi
- X
- Xif test -s $CMDS; then
- X set `wc -l $CMDS`; cmds=$1
- X test $DEBUG && echo "this message contains $cmds command line(s)"
- X echo "Found $cmds command line(s)" >>$LOGFILE
- X strings="`cat $CMDS`"
- X set -f $strings
- X#
- X# This is the MAIN PARSE loop
- X#
- Xerror=0; position=0; action=""; argument=""; destination="DEFAULT"; from="";
- Xwith=""; via=""
- X#
- Xwhile [ "$1" != "" ]
- Xdo
- X case $1 in
- X @@)
- X test $DEBUG && echo "restart of command line"
- X if test $position -gt 0
- X then
- X echo $action $argument $from $destination $with $via >>$CMDLOG
- X fi
- X action=""; argument=""; from="DEFAULT"; destination="DEFAULT"
- X with="DEFAULT"; via="DEFAULT"; position=0
- X shift;;
- X
- X [sS][eE][nN][dD])
- X test $DEBUG && echo "found \"send\""
- X if test $position -eq 0
- X then
- X action=send
- X shift
- X if test -z "$1"
- X then
- X argument="DEFAULT"
- X position=1
- X else
- X if [ "$1" = "@@" ]; then
- X argument="DEFAULT"
- X position=1
- X else
- X argument=$1; position=1
- X shift
- X fi
- X fi
- X fi;;
- X
- X
- X [lL][iI][sS][tT])
- X test $DEBUG && echo "found \"list\""
- X if test $position -eq 0
- X then
- X action=list
- X shift
- X if test -z "$1"
- X then
- X argument="DEFAULT"
- X position=1
- X else
- X if [ "$1" = "@@" ]; then
- X argument="DEFAULT"
- X position=1
- X else
- X argument=$1; position=1
- X shift
- X fi
- X fi
- X fi;;
- X
- X
- X [iI][nN][dD][eE][xX])
- X test $DEBUG && echo "found \"index\""
- X if test $position -eq 0
- X then
- X action=index
- X shift
- X if test -z "$1"
- X then
- X argument="DEFAULT"
- X position=1
- X else
- X if [ "$1" = "@@" ]; then
- X argument="DEFAULT"
- X position=1
- X else
- X argument=$1; position=1
- X shift
- X fi
- X fi
- X fi;;
- X
- X [fF][iI][nN][dD])
- X test $DEBUG && echo "found \"find\""
- X if test $position -eq 0
- X then
- X action=find
- X shift
- X if test -z "$1"
- X then
- X argument="DEFAULT"
- X position=1
- X else
- X if [ "$1" = "@@" ]; then
- X argument="DEFAULT"
- X position=1
- X else
- X argument=$1; position=1
- X shift
- X fi
- X fi
- X fi;;
- X
- X [hH][eE][lL][pP]|hilfe|HILFE|aiuto|AIUTO|aled|ALED)
- X test $DEBUG && echo "found \"help\""
- X if test $position -eq 0
- X then
- X action=help
- X shift
- X if test -z "$1"
- X then
- X argument="DEFAULT"
- X position=1
- X else
- X if [ "$1" = "@@" ]; then
- X argument="DEFAULT"
- X position=1
- X else
- X argument=$1; position=1
- X shift
- X fi
- X fi
- X fi;;
- X
- X [cC]redits|[cC]redit)
- X test $DEBUG && echo "found \"credits\""
- X if test $position -eq 0
- X then
- X action=credits
- X shift
- X if test -z "$1"
- X then
- X argument="DEFAULT"
- X position=1
- X else
- X if [ "$1" = "@@" ]; then
- X argument="DEFAULT"
- X position=1
- X else
- X argument=$1; position=1
- X shift
- X fi
- X fi
- X fi;;
- X
- X
- X [fF][rR][oO][mM]|inside|[iI][nN])
- X test $DEBUG && echo "found \"from\""
- X shift
- X if test "$1"
- X then
- X test "$1" != "@@" && from=$1 && shift
- X fi;;
- X
- X
- X to|To:)
- X test $DEBUG && echo "found \"to\""
- X shift
- X if test "$1"
- X then
- X test "$1" != "@@" && destination=$1 && shift
- X fi;;
- X
- X with|With|using|USING)
- X test $DEBUG && echo "found \"with\""
- X shift
- X if test "$1"
- X then
- X test "$1" != "@@" && with=$1 && shift
- X fi;;
- X
- X [vV][iI][aA]|over|OVER|through|THROUGH)
- X test $DEBUG && echo "found \"via\""
- X shift
- X if test "$1"
- X then
- X test "$1" != "@@" && via=$1 && shift
- X fi;;
- X
- X# These words are skipped if found before a @@ or after
- X# a valid argument shift.
- X *[Pp]lease*|hello|do|[Ss]ubject:|[Aa]ction:)
- X test $DEBUG && echo "junk \"$1\" skipped"
- X shift;;
- X
- X *)
- X test $DEBUG && echo "unknown command: \"$1\""
- X echo "\nParser error: unknown command \"$1\"" >>$ERRSTAT
- X error=1
- X ;;
- X esac
- X
- X if test $error -gt 0
- X then
- X test $DEBUG && echo "looking for a new command line"
- X while [ "$1" != "@@" ]
- X do
- X test -z "$1" && test $DEBUG && echo "no more command lines in this message"
- X test -z "$1" && break
- X shift
- X done
- X error=0; position=0
- X test $DEBUG && echo "found a new command line"
- X fi
- X
- X
- X# end while
- Xdone
- X
- Xif test $position -gt 0
- Xthen
- X echo $action $argument $from $destination $with $via>>$CMDLOG
- Xfi
- X
- X# these three lines refer to the test $CMDS at the beginning of parse()
- X
- Xelse
- Xdestination=DEFAULT
- Xtest $DEBUG && echo "this message does not contain any command line"
- Xfi
- X
- X}
- X
- Xinterp() {
- X
- X# If pathsizing is activated, look for credits..
- Xtest -n "$PATHSIZE" && {
- X if [ "$STRINGS" != "" ]; then
- X $STRINGS $PATHSIZE > $TMPDIR/pathstr
- X cat $TMPDIR/pathstr > $PATHSIZE
- X fi
- X if [ "$destination" != "DEFAULT" ]; then
- X UUCP_DESTIN=$destination
- X credit="`Check_PathSize $UUCP_DESTIN`"
- X else
- X credit="`Check_PathSize $UUCP_SENDER`"
- X fi
- X if [ "$credit" = "UNLIMITED" ]; then
- X test $DEBUG && echo "Your path: has no limits!"
- X echo "Your path: has no limits!" >> $LOGFILE
- X else
- X if [ "$credit" = "" ]; then
- X# Unknown path inside pathsize:
- X if [ "$CREDIT" = "0" ]; then
- X# New paths need to subscribe!
- X test $DEBUG && echo "New path: needs to subscribe!"
- X echo "New path: needs to subscribe!" >> $LOGFILE
- X SubScribe_Msg | $MAILER $UUCP_SENDER
- X rejected=1
- X fi
- X elif [ "$credit" -le "0" ]; then
- X rejected=1
- X echo "No more credits for this account" >> $LOGFILE
- X NoCredit_Msg | $MAILER $UUCP_SENDER
- X fi
- X fi
- X}
- X
- Xtest $DEBUG && echo "Interpreter: \c"
- X
- Xif [ "$rejected" = "1" ]; then
- X test $DEBUG && echo "Remote rejected or no-credits path: skipping."
- X echo "Message from $ARPA_SENDER discarded" >>$LOGFILE
- X return;
- Xfi
- X
- Xtest -s $RNADIR/hold && {
- X test $DEBUG && echo "holding message as pending job"
- X echo "Holding message from $ARPA_SENDER" >>$LOGFILE
- X return;
- X}
- X
- X# First we check if the sender is blacklisted.
- Xif [ "`BlackList`" != "" ]; then
- X test $DEBUG && echo "origin is blacklisted!\nDiagnostic: `BlackList`"
- X echo "Origin is Blacklisted: $ARPA_SENDER" >>$LOGFILE
- X Headers_Msg >>$OUTFILE
- X Deliver_Msg >>$OUTFILE
- X echo "\nWARNING, BLACKLIST PROBLEMS!\n`BlackList`\n" >>$OUTFILE
- X BlackListed_Msg >>$OUTFILE
- X YourMail_Msg >>$OUTFILE
- X NoHuman_Msg >>$OUTFILE
- X Mail_File
- X# I'm done with this message; next one, please..
- X return
- Xfi
- X
- X# Then we check if the sender used "to" field with authorization
- Xif [ "$destination" != "DEFAULT" ]; then
- X test $DEBUG && echo "external destination for <$destination>\nChecking for privileges...\c"
- X if test -z "`ToCheck`"; then
- X test $DEBUG && echo "NO privileges. Request denied!"
- X echo "External request denied: $ARPA_SENDER" >>$LOGFILE
- X Headers_Msg >>$OUTFILE
- X Deliver_Msg >>$OUTFILE
- X echo "\nWARNING: no privilege for external destinations\n" >>$OUTFILE
- X NoTo_Msg >>$OUTFILE
- X YourMail_Msg >>$OUTFILE
- X NoHuman_Msg >>$OUTFILE
- X Mail_File
- X# I'm done with this message; next one, please..
- X return
- X fi
- Xtest $DEBUG && echo "OK, origin is authorized!\nDiagnostic: `ToCheck`"
- Xecho "External Request OK: $ARPA_SENDER" >>$LOGFILE
- Xfi
- X
- X# And now we check if the parser reported errors..
- Xif test -s $ERRSTAT; then
- X test $DEBUG && echo "errors were detected by the parser.\nNotify origin and skip this message."
- X echo "Parser rejects: $ARPA_SENDER" >>$LOGFILE
- X Headers_Msg >>$OUTFILE
- X Deliver_Msg >>$OUTFILE
- X cat $ERRSTAT >>$OUTFILE
- X Syntax_Msg >>$OUTFILE
- X NoHuman_Msg >>$OUTFILE
- X Mail_File
- X# I'm done with this message; next one, please..
- X return
- Xfi
- X
- X# Work for us?
- Xif test -s $CMDLOG; then
- X set `wc -l $CMDLOG`; cmds=$1
- X test $DEBUG && echo "working on $cmds valid request(s)"
- X echo "Found $cmds valid request(s)" >>$LOGFILE
- X# following two lines are very important
- Xstrings="`cat $CMDLOG`"
- Xset -f $strings
- Xaction=""; argument=""; destination=""; via=""; with=""; tok=""
- X#
- X# * INTERPRETER LOOP *
- X# we parse standard 6-fields command lines whose fields are
- X# <action> <argument> <from-lib> <destination> <with> <via>
- X#
- Xwhile [ "$1" != "" ]
- Xdo
- X
- Xaction=$1; shift; argument=$1; shift; from=$1; shift; destination=$1
- Xshift; with=$1; shift; via=$1
- X
- Xrm -f $OUTFILE 2>/dev/null
- X# the following bracket starts the restricted environment of the interpreter:
- X# since we are using a streamed handling of a "cat", we *need to be sure that
- X# no procedure is executed within the same environment; so status variables
- X# won't change and RNA won't loose control of its job. Basically, the main
- X# effect of such lack is a message like "RNA: cannot shift" . Which takes
- X# RNA to forget about any command line - and any subsequent mail - aside the
- X# very first one of the very first income mail.
- X(
- Xtest $DEBUG && Reference_Msg
- XHeaders_Msg >$OUTFILE
- X
- Xcase $action in
- X
- Xsend)
- X Deliver_Msg >>$OUTFILE
- X if [ "$argument" = "DEFAULT" ]; then
- X test $DEBUG && echo "Missing argument for \"send\""
- X echo "\nERROR: command \"send\" requires an argument!\n" >>$OUTFILE
- X Syntax_Msg >>$OUTFILE
- X NoHuman_Msg >>$OUTFILE
- X Mail_File
- X# I'm done with this message; next one, please..
- X return
- X fi
- X Reference_Msg >>$OUTFILE
- X# Let's see if library and file do really exist
- X fname=""; fname="`GetFile $argument $from`"
- X if [ "$fname" != "" ]; then
- X
- X# If we are here, file/lib exists , "to" is ok
- X# (if there's one), so we may try to ship the stuff.
- X# We need to know HOW, first!
- X
- X# Check the field "via". Sorry for the bad indentation. We all need
- X# 160 columns monitors nowadays ;-)
- X
- Xcase $via in
- X
- Xuusend|UUSEND|Uusend)
- X With_Type
- X viasped="NO_MAIL"
- X Convert_File
- X Cut_Address
- X Ship_Msg >> $OUTFILE
- X test $DEBUG && echo "Now sending file with uusend to :$UUCP_HOST"
- X echo "File sent: $argument via $via to: $UUCP_SENDER">>$LOGFILE
- X# if you don't want to 'bill' uusend shippings, comment next line
- X test -n "$PATHSIZE" && Bill $fname
- X $UUSEND -r -f -m 666 $fname $UUCP_HOST$PUBDIR"/"$argument ;;
- X
- Xuucp|UUCP|Uucp)
- X With_Type
- X viasped="NO_MAIL"
- X Convert_File
- X Cut_Address
- X Ship_Msg >> $OUTFILE
- X test $DEBUG && echo "Now send file using uucp to :$UUCP_HOST"
- X echo "File sent: $argument via $via to: $UUCP_SENDER">>$LOGFILE
- X# if you don't want to 'bill' uucp shippings, comment next line
- X test -n "$PATHSIZE" && Bill $fname
- X $UUCP -r -C $fname $UUCP_HOST$PUBDIR"/"$argument ;;
- X
- XDEFAULT|default|mail|\
- XMAIL|Mail|email|EMAIL|E-Mail|\
- Xe-mail|E-MAIL)
- X test $DEBUG && echo "Now send file using e-mail to :$UUCP_SENDER"
- X With_Type
- X viasped=""
- X Convert_File
- X echo "File sent: $argument via $via to: $UUCP_SENDER">>$LOGFILE
- X ;;
- X
- X*)
- X via="DEFAULT"
- X With_Type
- X viasped=""
- X Convert_File
- X ViaError_Msg >> $OUTFILE
- X test $DEBUG && echo "Now send file using e-mail to :$UUCP_SENDER"
- X echo "File sent: $argument via $via to: $UUCP_SENDER">>$LOGFILE
- X
- Xesac
- X
- X
- X else
- X# Something wrong with object file, Scotland Yards investigates..
- X if [ "`GetDir $from`" = "" ]; then
- X test $DEBUG && echo "Nonexistent library: \"$from\""
- X echo "NO library found: $from" >>$LOGFILE
- X NoLibrary_Msg >>$OUTFILE
- X elif [ "`GetFile $argument $from`" = "" ]; then
- X test $DEBUG && echo "Nonexistent file: \"$argument\" inside library \"$from\""
- X echo "NO file found: $argument" >>$LOGFILE
- X NoFile_Msg $from $argument >>$OUTFILE
- X else
- X CantAccess_Msg >>$OUTFILE
- X echo "CANT ACCESS $argument from $from" >>$LOGFILE
- X test $DEBUG && echo "WARNING: cannot open \"`GetFile $argument $from`\""
- X fi
- X fi
- X Mail_File ;;
- X
- Xlist) Deliver_Msg >>$OUTFILE
- X Reference_Msg >>$OUTFILE
- X ListLib $argument >>$OUTFILE
- X echo "\nPLEASE use command \"index\" to get more details\n\
- X on library: $argument">>$OUTFILE
- X echo "Command executed: list $argument : $ARPA_SENDER" >>$LOGFILE
- X Mail_File ;;
- X
- Xindex) Deliver_Msg >>$OUTFILE
- X Reference_Msg >>$OUTFILE
- X GetCat $argument >>$OUTFILE
- X ListLib $argument >>$OUTFILE
- X echo "Command executed: index and list $argument : $ARPA_SENDER" >>$LOGFILE
- X Mail_File ;;
- X
- Xcredits) Deliver_Msg >>$OUTFILE
- X Reference_Msg >>$OUTFILE
- X if test -n "$PATHSIZE" ; then
- X credit="`Check_PathSize $UUCP_SENDER`"
- X if [ "$credit" = "" ]; then
- X if [ "$CREDIT" != "0" ]; then
- X echo "\nYou are a new user; credits: $CREDIT (bytes)\n" >>$OUTFILE
- X echo "(This request will be billed as well, normally about 800 bytes)\n" >>$OUTFILE
- X fi
- X else
- X if [ "$credit" = "UNLIMITED" ]; then
- X echo "\nYour path has no limitations.\n" >>$OUTFILE
- X else
- X echo "\nCredits remaining: $credit out of $CREDIT (bytes)\n" >>$OUTFILE
- X echo "(This request will be billed as well, normally about 800 bytes)\n"
- X fi
- X fi
- X else
- X echo "\nPathsizing not running here. No limits!\n" >>$OUTFILE
- X fi
- Xecho "Command executed: credits for $UUCP_SENDER" >> $LOGFILE
- X Mail_File ;;
- X
- X
- Xfind) Deliver_Msg >>$OUTFILE
- X Reference_Msg >>$OUTFILE
- X if [ "$argument" = "DEFAULT" ]; then
- X test $DEBUG && echo "Missing argument for \"find\""
- X echo "\nERROR: command \"find\" needs a valid argument!\n" >>$OUTFILE
- X NeedHelp_Msg >>$OUTFILE
- X NoHuman_Msg >>$OUTFILE
- X else
- X echo "Command executed: find $argument : $ARPA_SENDER" >>$LOGFILE
- X FindFile $argument >>$OUTFILE
- X fi
- X Mail_File ;;
- Xhelp) Deliver_Msg >>$OUTFILE
- X Reference_Msg >>$OUTFILE
- X if [ "$argument" != "DEFAULT" ]; then
- X echo "\n\
- XHELP is not available for \"$argument\": try a simple @@ help" >>$OUTFILE
- X else
- X argument="HELP"; from="DEFAULT";
- X hname=""; hname="`GetFile $argument $from`"
- X if [ "$hname" != "" ]; then
- X cat $hname >>$OUTFILE
- X echo "Command executed: help : $ARPA_SENDER" >>$LOGFILE
- X else
- X echo "WARNING: NO HELP for $ARPA_SENDER" >>$LOGFILE
- X echo "\n\
- XCannot open help file inside RNA system directory - sorry" >>$OUTFILE
- X fi
- X Mail_File
- X fi ;;
- X *) test $DEBUG && echo "WARNING: interpreter error with token $1"
- X echo "WARNING: interp error token $1" >>$LOGFILE
- X shift; shift;;
- X
- Xesac
- X# the following bracket close the restricted environment of the interpreter
- X)
- X# recycle next command line (if any)
- Xshift
- X# end while, recycle
- Xdone
- Xelse
- X# CMDLOG empty: no commands found inside current message
- X test $DEBUG && echo "no commands found, notify origin."
- X echo "Current message is empty : $ARPA_SENDER" >>$LOGFILE
- X Headers_Msg >>$OUTFILE
- X Deliver_Msg >>$OUTFILE
- X echo "" >>$OUTFILE
- X NoCommands_Msg >>$OUTFILE
- X Mail_File
- Xfi
- X}
- X# End of interpreter
- X
- X# -----------------------------------
- X# main program
- X# -----------------------------------
- X
- Xtest -n "$PATHSIZE" && {
- X test -r $PATHSIZE || {
- X test $DEBUG && echo "ERROR: cannot open $PATHSIZE"
- X exit
- X }
- X}
- X
- X# Are we out of service?
- Xtest -r $RNADIR/hold || {
- X# No. Check if we just came out of 'holding' state: in this case we
- X# might have a 'pending' file with old jobs to process.
- X test -r $RNADIR/pending && {
- X# That's it: old requests.. We append them to our current
- X# mailbox. New ones are stored before these, i know.
- X# It makes little sense to spend time reordering...
- X cat $RNADIR/pending >>$MAILBOX
- X# %%FIX%%
- X# check out that every mail is separated by a null line, in the previous
- X# cat. Normally, it should. Well, if not, add it.
- X rm $RNADIR/pending
- X }
- X}
- X
- Xtest -s $MAILBOX && {
- XStartup
- XGetMail
- XCutMail
- Xset `wc -l $POINTERS`
- Xtest $DEBUG && echo "New mail found: $1 message(s)"
- Xecho "\n FOUND $1 MESSAGE(S)" >>$LOGFILE
- Xuntil [ "$message" -gt "$1" ]
- Xdo
- X test $DEBUG && echo "Now working on message n.$message"
- X ( ClrTmpFiles
- X GetMessage $message
- X parse
- X interp )
- X test $DEBUG && echo "message n.$message is over"
- X message=`expr $message + 1`
- Xdone
- Xtest $DEBUG && echo "RNA SESSION COMPLETED SUCCESSFULLY"
- X}
- X
- X
- X# End of RNA
- X# %%FIX%%
- X# Congratulations, you got to the end of RNAlib configuration. If you
- X# followed indications now you have a working copy of RNA 2.0.
- X# Before attempting to execute, however, remember you need to create at
- X# least an index file (libindex) for libraries.
- X# In order to make RNA run faster and better, we need to cut off all
- X# comments from the original configured version. So i strongly recommend
- X# you make your configuration and modifications on a COMPLETE version of
- X# RNA, but RUN ALWAYS an extracted rna called 'XRNA'. How do you get
- X# XRNA out of your RNA? Easy: run 'MAKE_RNA'.
- X# Every time you need to change something inside RNA, edit RNA and then
- X# re-run MAKE_RNA. -- Paolo
- X#
- X# RNALIB 2.0 Revision A - END OF CONFIGURATION
- SHAR_EOF
- $TOUCH -am 0918180790 RNA &&
- chmod 0644 RNA ||
- echo "restore of RNA failed"
- set `wc -c RNA`;Wc_c=$1
- if test "$Wc_c" != "53931"; then
- echo original size 53931, current size $Wc_c
- fi
- exit 0
-
-