venta@otello.sublink.org (Paolo Ventafridda) (02/11/91)
Archive-name: RNALIB-22_b1/part04 ---- Cut Here and unpack ---- #!/bin/sh # this is z-rnalib.04 (part 4 of RNALIB-22_b1) # do not concatenate these parts, unpack them in order with /bin/sh # file RNA continued # if touch 2>&1 | fgrep '[-amc]' > /dev/null then TOUCH=touch else TOUCH=true fi if test ! -r shar3_seq_.tmp; then echo "Please unpack part 1 first!" exit 1 fi (read Scheck if test "$Scheck" != 4; then echo "Please unpack part $Scheck next!" exit 1 else exit 0 fi ) < shar3_seq_.tmp || exit 1 echo "x - Continuing file RNA" sed 's/^X//' << 'zXqzXqzXq' >> RNA && X============================================================" Xcat $search Xecho "============================================================\n" X} X XRevEmpty_Msg() { X echo "\ XThere are currently NO members of the \"$argument\" mailing-list!\nSorry.\n" X} X XRevNotAv_Msg() { X echo "\ XThe mailing-list of \"$argument\" is not available!\n\ XProbably it is empty, or it is never been used.\n\ XSorry!\n" XAskLstMan_Msg X} X XRevClosed_Msg() { X echo "\n\ XSorry, you can't list subscribed users inside \"$argument\"\n\ Xsince this mailing list is read-protected.\n" XAskLstMan_Msg X} X XSigClosed_Msg() { X echo "\n\ XSorry, the \"$argument\" mailing list is write-protected:\n\ Xyou can't subscribe yourself automatically.\n\ XPlease consult the list-index informations about subscription\n\ Xwith command: @@ lindex $argument \n" XAskLstMan_Msg X} X X XRelease_Msg() { X echo "\n\ XRNALIB MAIL SERVER RELEASE 2.2 Revision A (beta)- Feb 1991 , Public Domain SW\n\ XDeveloped by Paolo Ventafridda and Marco Lorenzini, Sublink Network, ITALY\n\ X(venta@i2ack.sublink.org and marlor@gear.sublink.org) (c) 1989,1990,1991\n\n" Xtest -r $RNADIR/release && grep -v '#' $RNADIR/release Xtest -r $RNADIR/release || echo "== No system configuration available ==" Xecho X} X X XSplit_Msg() { X echo "\ XThis file will be shipped in $SPLIT_PARTS parts of $N_KBYTES Kbytes each \n\ XYou must unpack them in sequence using \"/bin/sh\" \n" XNoHuman_Msg XSignature X} X XNoMail_Msg() { X echo "\ XWARNING: requested file \"$argument\"\n\ X(size $N_KBYTES Kbytes) has NOT been sent since it is longer\n\ Xthan ($MAIL_LIMIT Kbytes) permitted by our e-mail policy.\n\n\ XYou should try another deliver with :\n\ X\"@@ send {file} from {library} via uusend\" or\n\ X\"@@ send {file} from {library} via uucp\" or\n\ Xif you could not use uusend or uucp, the smaller:\n\ X\"@@ send {file} from {library} with btoa\".\n\n\ XThe problem has been notified to $POSTMASTER here,\n\ Xand your account hasn't been charged.\n\ XSorry for the inconvenience.\n" XSignature X} X X# End of messages- X X# --- THE PARSER --- XParse() { X# Since we use IFS with "set", we start saving the original one. XIFSorg=$IFS Xecho "\nXQT `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 "BNGFRM $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 "" X# Under bash the following line is correct, according to Vince. X# Will now work under bourne shell anyway. X# set -f - $rrline X# We use this one instead. 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# The following line was missing a ` ... X# elif [ "`echo $@ | grep '<'" != "" ]; then X# X elif [ "`echo $@ | grep '<'`" != "" ]; then X IFS="<>" ; 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 IFS="( )" ; 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# In any case we reset IFS to its original values. X# We had so many problems with this IFS... X IFS=$IFSorg X fi X test "$1" = "Date:" && REQUEST_DATE="$2 $3 $4" X rline=`expr $rline + 1` Xdone Xecho "ARPFRM $ARPA_SENDER\nREQDATE <$REQUEST_DATE>" >>$LOGFILE 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# In rnalib 2.0 interpreter could toss about external destinations. X# This line was in fact needed. X destination="DEFAULT" 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### Not needed, but let's keep it for a while as a comment X### IFS=$IFSorg 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 "CMDLINES $cmds\n`cat $CMDS`" >>$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]|[Gg][eE][Tt]|sendme|SENDME|take|pick) 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 [Ss][Uu][Bb]scribe|[Ss][Ii][Gg][Nn][Oo][Nn]|[Ss][Uu][Bb]|SIGNUP|signup) X test $DEBUG && echo "found \"signon\"" X if test $position -eq 0 X then X action=signon 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 [Uu][Nn][Ss]|[Uu][Nn][Ss]ubscribe|[Ss][Ii][Gg][Nn][Oo][Ff][Ff]|UNSUB|unsub) X test $DEBUG && echo "found \"signoff\"" X if test $position -eq 0 X then X action=signoff 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 [Ll][iI][Nn][dD][eE][Xx]|[lL][lL][Ii][sS][tT]) X test $DEBUG && echo "found \"lindex\"" X if test $position -eq 0 X then X action=lindex 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]ind[Mm]e|[Ll]ist[Mm]e|[Ww]here) X test $DEBUG && echo "found \"findme\"" X if test $position -eq 0 X then X action=findme 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 [Rr][ee][Vv][Ii][Ee][Ww]|[Mm]embers) X test $DEBUG && echo "found \"review\"" X if test $position -eq 0 X then X action=review 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 [Rr]elease|[Vv]ersion|RELEASE) X test $DEBUG && echo "found \"release\"" X if test $position -eq 0 X then X action=release 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 [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]|[Ss][Ee][Aa][Rr][Cc][Hh]) 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|[Ii]nfo) 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][Rr][Ee][Dd][Ii][Tt][Ss]|[cC][Rr][Ee][Dd][Ii][Tt]) 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 [sS][pP][lL][iI][tT]) X test $DEBUG && echo "found \"split\"" X if test $position -eq 0 X then X action=split 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]|[Pp][Ww]|[Pp]assword) X test $DEBUG && echo "found \"from\"" X shift X if test "$1" X then X test "$1" != "@@" && from=$1 && shift X fi;; X X [Tt][Oo]|[tT][oO]:) X test $DEBUG && echo "found \"to\"" X shift X if test "$1" X then X test "$1" != "@@" && destination=$1 && shift X fi;; X X [Ww][Ii][Tt][Hh]|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# Warning: read "RRJP" chapter inside OPER.GUIDE! X# This command is a potential system security hole! X exec) X test $DEBUG && echo "found \"exec\"" X if test $position -eq 0 X then X action=exec 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# 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 X# --- THE INTERPRETER --- 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 test $DEBUG && echo "External destination old credits=$credit" X else X credit="`Check_PathSize $UUCP_SENDER`" X test $DEBUG && echo "Default destination old credits=$credit" X fi X if [ "$credit" = "UNLIMITED" ]; then X test $DEBUG && echo "This path is marked UNLIMITED and though has no limits." X echo "This path is unlimited" >> $LOGFILE X else X if [ "$credit" = "" ]; then X test $DEBUG && echo "This path does not appear inside pathsize" X# Unknown path inside pathsize: X if [ "$CREDIT" = "0" ]; then X# New paths need to subscribe! X test $DEBUG && echo "New paths need to subscribe here!" 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 test $DEBUG && echo "No credits for this path (value=$credit)" 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 X# test -s $RNADIR/hold && { X# This ^^ test (wrong) in rna 2.0 was giving a lot of troubles... Xtest -r $RNADIR/hold && { X test $DEBUG && echo "holding message as pending job" X echo "HOLDON $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 "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 "EXTDENIED $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 "EXTACCEPT $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 "CMDVALID $cmds" >>$LOGFILE X# Indentation here is simply forgotten.. X# Following two lines are very important: Xstrings="`cat $CMDLOG`" Xset -f $strings Xaction=""; argument=""; destination=""; via=""; with=""; tok="" X# X# * INTERPRETER MAIN LOOP * X# We parse standard 6-fields command lines whose fields are X# <action> <argument> <from-lib> <destination> <with> <via> X# These lines are generated by the Parser, and can be really different X# from the user request; content usually is sortof tokenized. X# Xwhile [ "$1" != "" ] Xdo X Xaction=$1; shift; argument=$1; shift; from=$1; shift; destination=$1 Xshift; with=$1; shift; via=$1 Xecho "TOKEN $action $argument $from $destination $with $via" >>$LOGFILE 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 Xsplit) X test $SPLIT || { echo "N" >> $SPLITLOG; return; } && X if [ "$argument" -ge "$MIN_SPLIT" ] && [ "$argument" -le "$MAX_SPLIT" ]; then X N_KBYTES=$argument X else X N_KBYTES=$DEF_SPLIT X test $DEBUG && echo "The dimension for splitting is not permitted: setting default" X fi X echo $N_KBYTES >>$SPLITLOG X test $DEBUG && echo "This file will be split in parts of $N_KBYTES Kbytes" X echo "This file will be split in parts of $N_KBYTES Kbytes" >>$LOGFILE X ;; 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 "NOLIBRARY $from" >>$LOGFILE X NoLibrary_Msg >>$OUTFILE X elif [ "`GetFile $argument $from`" = "" ]; then X test $DEBUG && echo "Nonexistent file: \"$argument\" inside library \"$from\"" X echo "NOFILE $argument" >>$LOGFILE X NoFile_Msg $from $argument >>$OUTFILE X else X CantAccess_Msg >>$OUTFILE X echo "WARNING cannot 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 Xlindex) Deliver_Msg >>$OUTFILE X Reference_Msg >>$OUTFILE X if test -n "$LSTIND" ; then X GetCatLst $argument >>$OUTFILE X else X NotUsingList_Msg >>$OUTFILE X fi X echo "Command executed: lindex $argument : $ARPA_SENDER" >>$LOGFILE X Mail_File ;; X Xfindme) Deliver_Msg >>$OUTFILE X Reference_Msg >>$OUTFILE X if test -n "$LSTIND" ; then X FindMe >>$OUTFILE X AskLstMan_Msg >>$OUTFILE X else X NotUsingList_Msg >>$OUTFILE X fi X echo "Command executed: findme" >>$LOGFILE X Mail_File ;; X X Xsignon) Deliver_Msg >>$OUTFILE X Reference_Msg >>$OUTFILE X if test -n "$LSTIND" ; then X# Does this mailing list exist? X lstpth="`GetDirLst $argument`" X if test -n "$lstpth" ; then X# Yes. Let's check and eventually initialize the mailing list X CreaLst $lstpth X# This is already done by the parser, actually. X test -z "$ARPA_SENDER" && ARPA_SENDER=$UUCP_SENDER X# Is this an already subscribed user? X chkusr="`ChkUsrLst $lstpth`" X if test -n "$chkusr" ; then X# YES. Notify this situation to remote user. X test $DEBUG && echo "Already subscribed: matching <$chkusr>" X AlreadyLst_Msg $chkusr >>$OUTFILE X else X# We MIGHT subscribe this user, but first let's be sure the mailing list is not write-protected. X if test -r "$lstpth/status" ; then X test $DEBUG && echo "Status file found inside \"$lstpth/status\"" X grep -v '#' "$lstpth/status" | grep "W-CLOSED" >/dev/null && { X# That's it, this is a write-protected list. X SigClosed_Msg >>$OUTFILE X test $DEBUG && echo "Signon for \"$argument\" is protected" X echo "Signon for \"$argument\" is protected." >>$LOGFILE X lstpth="CLOSED" X } X fi X test "$lstpth" != "CLOSED" && { X# Subscribe the user and acknowledge his message. X# We use ARPA_SENDER if available; otherwise UUCP_SENDER. X# Currently the parser copies uucp_sender inside arpa_sender if the latter is not X# found inside mail's headers. This might be changed later on. X InLst_Msg $ARPA_SENDER >>$OUTFILE X AddUsrLst $ARPA_SENDER $lstpth X } X fi X else X# This mailing list does not exist at all! X test $DEBUG && echo "Mailing list \"$argument\" does not exist!" X NoList_Msg >>$OUTFILE X NoHuman_Msg >>$OUTFILE X fi X else X# We are not using mailing lists here; are you crazy? X NotUsingList_Msg >>$OUTFILE X fi X echo "Command executed: signon $argument : $ARPA_SENDER" >>$LOGFILE X Mail_File ;; X Xsignoff) Deliver_Msg >>$OUTFILE X Reference_Msg >>$OUTFILE X if test -n "$LSTIND" ; then X# Does this mailing list exist? X lstpth="`GetDirLst $argument`" X if test -n "$lstpth" ; then X# Yes. Let's check and eventually initialize the mailing list X CreaLst $lstpth X test -z "$ARPA_SENDER" && ARPA_SENDER=$UUCP_SENDER X# Is this user really subscribed ? X chkusr="`ChkUsrLst $lstpth`" X if test -z "$chkusr" ; then X# NO. Notify this situation to remote user. X test $DEBUG && echo "This user is NOT subscribed, signoff useless" X NotLst_Msg >>$OUTFILE X NoHuman_Msg >>$OUTFILE X else X# Unsubscribe the user and acknowledge his message. X RmvUsrLst "$chkusr" $lstpth X OutLst_Msg "$chkusr" >>$OUTFILE X fi X else X# This mailing list does not exist at all! X test $DEBUG && echo "Mailing list \"$argument\" does not exist!" X NoList_Msg >>$OUTFILE X fi X else X# We are not using mailing lists here; helloooo macfly?!? X NotUsingList_Msg >>$OUTFILE X fi X echo "Command executed: signon $argument : $ARPA_SENDER" >>$LOGFILE X Mail_File ;; X Xreview) Deliver_Msg >>$OUTFILE X Reference_Msg >>$OUTFILE X if test -n "$LSTIND" ; then X# Does this mailing list exist? X lstpth="`GetDirLst $argument`" X if test -n "$lstpth" ; then X if test -r "$lstpth/users" ; then X if test -s "$lstpth/users" ; then X if test -r "$lstpth/status" ; then X test $DEBUG && echo "Status file found inside \"$lstpth/status\"" X grep -v '#' "$lstpth/status" | grep "R-CLOSED" >/dev/null && { X RevClosed_Msg >>$OUTFILE X test $DEBUG && echo "Userlist for \"$argument\" is protected" X echo "Userlist for \"$argument\" is protected." >>$LOGFILE X lstpth="CLOSED" X } X fi X test "$lstpth" != "CLOSED" && { X Review_Msg "$lstpth/users" >>$OUTFILE X test $DEBUG && echo "Userslist for \"$argument\" sent" X echo "Userlist for \"$argument\" is available" >>$LOGFILE X } X else X RevEmpty_Msg >>$OUTFILE X test $DEBUG && echo "Userslist for \"$argument\" is empty!" X echo "Userlist for \"$argument\" is empty!" >>$LOGFILE X fi X else X RevNotAv_Msg >>$OUTFILE X test $DEBUG && echo "Userslist for \"$argument\" is not readable!" X echo "Userlist for \"$argument\" is not readable!" >>$LOGFILE X fi X else X test $DEBUG && echo "Mailing list \"$argument\" does not exist at all!" X NoList_Msg >>$OUTFILE X NoHuman_Msg >>$OUTFILE X fi X else X# We are not using mailing lists here; are you crazy? X NotUsingList_Msg >>$OUTFILE X fi X echo "Command executed: review $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" = "" ]; then X echo "\nBy default, users have NO limitations here." >>$OUTFILE X echo "This might changed for your path later on.\n" >>$OUTFILE X elif [ "$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 less than 1000 bytes)\n" >>$OUTFILE X fi X else X if [ "$credit" = "UNLIMITED" ]; then X echo "\nYour path is privileged and 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 less than 1000 bytes)\n" >>$OUTFILE 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 ;; X Xhelp) Deliver_Msg >>$OUTFILE X Reference_Msg >>$OUTFILE X if [ "$argument" != "DEFAULT" ]; then X if test -n "$HELPDIR" ; then X if test -r $HELPDIR/$argument ; then X test $DEBUG && echo "Help \"$argument\" ok" X cat $HELPDIR/$argument >>$OUTFILE X else X test $DEBUG && echo "Help not available for \"$argument\"" X echo "NOHELP $argument" >>$LOGFILE X NoHelpFor_Msg >>$OUTFILE X NoHuman_Msg >>$OUTFILE X fi X else X test $DEBUG && echo "HELPDIR not available" X echo "Helpdir not available" >>$LOGFILE X NoHelpDir_Msg >>$OUTFILE X NoHuman_Msg >>$OUTFILE X fi X 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 "NOHELP DEFAULT" >>$LOGFILE X echo "WARNING: no default help for $ARPA_SENDER" >>$LOGFILE X echo "\n\ XCannot open HELP file inside RNA system directory - sorry" >>$OUTFILE X fi X X fi X Topics >>$OUTFILE X Mail_File ;; X Xrelease) Deliver_Msg >>$OUTFILE X Reference_Msg >>$OUTFILE X Release_Msg >>$OUTFILE X echo "Command executed: release" >>$LOGFILE X Mail_File ;; X X# RRJP - RNA REMOTE JOBS PROCESSOR release 1.0 X# Access to the RRJP should only be given to trusted people. Brothers, X# sisters, mom and dad for instance ;-) X# See the RRJP chapter inside OPER.GUIDE for details. Xexec) Deliver_Msg >>$OUTFILE X Reference_Msg >>$OUTFILE X# As you can see, if "execfile" does not exist there's no way of running 'exec'. X# No need to worry about rrjp so; by default it does not run. Trust me, this is X# not a trojan horse :-) X if test -r execfile ; then X# Ok, execfile exists. Let's see if the incoming path is authorized. If UUCP_SENDER is not found X# inside execfile, request is refused. X grep $UUCP_SENDER $RNADIR/execfile >/dev/null && { X# Well well, the path seems ok. Let's see if the PASSWORD (which is coming as a $from argument) X# is ok as well..otherwise request is refused. X grep $from $RNADIR/execfile >/dev/null && { X# YEP. Have a nice time on rrjp... X echo "RRJP REQUEST AUTHORIZED" >>$LOGFILE X test $DEBUG && echo "RRJP: work authorized" X grep "^~ " $MBOX_CUT | tr -d "~" >/tmp/$argument X chmod 777 /tmp/$argument X echo "\n\fRRJP-1A READY\nHELLO $ARPA_SENDER" >>$OUTFILE X echo "REMOTE JOB: \"$argument\"\nSIZE: \c" >>$OUTFILE X wc -l /tmp/$argument | cut -d"/" -f1 | tr -d " " >>$OUTFILE X echo "LANGUAGE : $with" >>$OUTFILE X echo "EXECUTION STARTS `date`\nOUTPUT FOLLOWS:" >>$OUTFILE X echo "RRJP EXEC START `date`" >>$LOGFILE X test $DEBUG && echo "RRJP: executing \"$argument\"" X# Have a copy of the job... X touch $RNADIR/jobs; echo "RRJP $argument [$ARPA_SENDER `date`]" >>$RNADIR/jobs X cat /tmp/$argument >>$RNADIR/jobs X# Which interpreter should we use? X# It's pretty easy to configure RRJP to act as a full C compiler from remote.. X case $with in X DEFAULT) /tmp/$argument $OUTFILE 1>>$OUTFILE 2>&1 X ;; X *) X test $DEBUG && echo "Attempting to execute through \"$with\"" X $with /tmp/$argument $OUTFILE 1>>$OUTFILE 2>&1 X ;; X esac X test $DEBUG && echo "RRJP: end of execution" X echo "RRJP EXEC STOP `date`" >>$LOGFILE X echo "EXECUTION STOPS `date`" >>$OUTFILE X echo "CPU CONSUMED (user system): \c" >>$OUTFILE X echo "RRJP CPU: \c" >>$LOGFILE X# We cant use `times` in the previous echo, since it would be calculated on a new X# subshell executing just nothing, thus giving always 0m00s as a result. X times >>$OUTFILE ; times >>$LOGFILE X echo "GOODBYE $ARPA_SENDER - RRJP END" >>$OUTFILE X from="ok" X } X } X if [ "$from" != "ok" ] ; then X echo "You are NOT AUTHORIZED to use this command!\n" >>$OUTFILE X test $DEBUG && echo "NOT AUTHORIZED TO USE EXEC COMMAND" X echo "RRJP NOT AUTHORIZED" >>$LOGFILE X fi X else X echo "System authorization failure\n" >>$OUTFILE X test $DEBUG && echo "Authorization failure: execfile missing" X echo "RRJP IS DISABLED (no execfile)" >>$LOGFILE X fi X X echo "Command executed: exec $argument [pw]=$from" >>$LOGFILE X Mail_File ;; X X X *) X test $DEBUG && echo "WARNING: INTERPRETER ERROR WITH TOKEN \"$action\"" X test $DEBUG && echo "(act=$action - arg=$argument - dest=$destination - via=$via - with=$with - tok=$tok )" X test $DEBUG && echo "Apparently, parser knows of \"$action\" but interpreter doesn't !" X echo "WARNING: INTERNAL INTERPRETER ERROR with token $action" >>$LOGFILE X# Inside rnalib 2.0 we were using TWO shift; this was giving (sometimes) 'cannot shift' errors. X# Now this was fixed, however we'll leave it commented for a while.. X# shift; shift;; X shift;; X Xesac X# the following bracket closes 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 "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 (phew!) X X# =========================================================================================== X# MAIN PROGRAM (main) X# =========================================================================================== X X# First of all, if "stop" is found, RNA quits immediatly; NO OUTPUT! X# This is different from going 'on hold': used for emergencies only. Xtest $DEBUG && test -r $RNADIR/stop && echo "$RNAVERS FORCED EXIT (found \"$RNADIR/stop\")" Xtest -r $RNADIR/stop && exit X Xtest $DEBUG && echo "$RNAVERS DEBUG STARTUP on `date`\nSystem-id: `uname -a`" X X# Now we look for arguments. Xcase "$#" in X 0) ;; X *) X test $DEBUG && echo "EXECUTING \"$@\"" X Export X# should you need to "source" rnalib's environment inside X# another program, you can uncomment the following line. X# set >$RNADIR/Environment X# X# We clear the status file for each external execution. X >$TMPDIR/status X# Now we execute the whole command (with any parameter). X# This is searched inside PATH, which has BINDIR ahead. X# External programs - like shell scripts for rnalib - X# normally resides inside BINDIR. We don't redirect i/o X# since we let the external program take care of it. X $* X# only if we find a tmpdir/status file containing a 'RRUN' we X# will keep on executing rnalib; otherwise we simply drop the X# whole session (mail untouched). X test "`cat $TMPDIR/status`" != "RRUN" && { X test $DEBUG && echo "EXEC TERMINATED - QUIT RNALIB" X exit X } X test $DEBUG && echo "EXEC TERMINATED- CONTINUE RNALIB" X ;; Xesac 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 test $DEBUG && echo "Out of hold-state, there are pending requests.." 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 && { X Startup X GetMail X CutMail X set `wc -l $POINTERS` X test $DEBUG && echo "New mail found: $1 message(s)" X echo "\nMAILFOUND $1 `date '+%d/%m/%y'`" >>$LOGFILE X until [ "$message" -gt "$1" ] X do X test $DEBUG && echo "Now working on message n.$message" X ( X ClrTmpFiles X GetMessage $message X Parse X Interp X ) X test $DEBUG && echo "message n.$message is over" X message=`expr $message + 1` X done X test $DEBUG && echo "RNA SESSION COMPLETED" X } || { X# %%FIX%% X# We need the following dummy command, otherwise MAKE with no DEBUG X# mode would produce a } || {\n} sequence, which causes shell to X# say "unexpected symbol". Use 'true', or anything which has NO X# output- (beware...) X true X test $DEBUG && echo "RNA SESSION COMPLETED (NO WORK)" X } X X X# End of RNA X# %%FIX%% X# As in the ads, rnalib makes the coffee. If you want, uncomment X# the next line and choose the kind of coffee you like ;-)) X# echo "Black & Strong" >$RNADIR/coffee X# X# Congratulations, you got to the end of RNAlib configuration. If you X# followed indications now you have a working copy of RNALIB. 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 SERVER - END OF CONFIGURATION zXqzXqzXq echo "File RNA is complete" && $TOUCH -am 0210184091 RNA && chmod 0777 RNA || echo "restore of RNA failed" set `wc -c RNA`;Wc_c=$1 if test "$Wc_c" != "91110"; then echo original size 91110, current size $Wc_c fi rm -f shar3_seq_.tmp echo "You have unpacked the last part" exit 0 -- Paolo Ventafridda -*- INTERNET: venta@otello.sublink.org TELEMATIX MILANO - Via C.Gomes 10, 20124 Milano - +39-2-6706012