allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc) (07/22/89)
Posting-number: Volume 7, Issue 92 Submitted-by: venta@i2ack.UUCP (Paolo Ventafridda) Archive-name: rna : # This is a shell archive, meaning: # 1. Remove everything above the : line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create: # README # version # RNA # This archive created: Wed Jul 12 14:21:18 1989 export PATH; PATH=/bin:/usr/bin:$PATH if test -f 'README' then echo shar: "will not over-write existing file 'README'" else cat << \SHAR_EOF > 'README' Remote Network Archive ---------------------- Hey, don't do it, don't go installing RNA without first reading these few lines! Lemme explain what RNA was made for, and what rna won't do. It won't take long, so forget about the keyboard for a while and read this tiny manual. GIVE ME A CHANCE! Thank you. Paolo Ventafridda WHAT IS RNA ----------- Suppose that your system has some software (any kind) that other people on the network sometimes request, and you are becoming crazy on uucp transfers, and mail such "please could you send me file xxx thx" etc. Rna will allow your neighbours to help themselves using simple mail commands such as "send me file xxx " just like if they were asking YOU. All files will travel through ANY network like mail, not like UUCP; this means that also BITNET, DECNET, FIDOnet users will be able to help themselves without bothering you anymore! There's a program around called NETLIB, developed by AT&T research centers, which already does this thing, and also very well; it's powerful, but also complicated to install, and anyway has bigger docs than rna ;-) If you don't need all of that power, and you want something really easy to install and to mantain,and eventually remove ;-( than have a look at rna. There are two good reasons for trying it: 1- it works fine 2- it's free. FEATURES -------- - Handles commands such as " please send tetris.Z to bob@usixth " , it doesn't care of where these commands are placed inside your mail, even the Subject will do. You can put multiple commands inside the same message. - If file does not exist, or is not readable, it gives a response about it. - If requested file is not ascii, it will uuencode it before shipping. - Index is available with " send index to .. " : index is a ls of your public directory, automatically done on request, so you don't need to spend time on your archive. If you want, create a "index" file in pubdir, containing full descriptions of your (some) files. This list will be appended to the "ls". - Help is available with "send help to ...". This is a trick: help is a common file like others. But don't tell it around. - Attention please: rna does not recognize in this version the address of the sender, in fact you have to specify "to: ..". This might cause some problems to someone. Trust your neighbours, or install netlib! Anyway, if someone enjoys sending big files to enemies through your rna, a copy of their letters will still be in your log. WHAT? A SHELL SCRIPT? --------------------- What's wrong, John, never seen a shell script? Well, rna IS written in standard Bourne Shell. People thinks that only C programs can do useful things; well, i think that Real Programmers don't use C, if they can do it in Shell. Now, RNA is NOT meant to run full time, but only once every while, launched by cron, just to see if there's something to do. So speed is not important, not at all! INSTALLATION ------------ You need a dedicated directory for the rna package. In this directory rna will keep its logs and its files. rna takes only a couple of temporary files, the rest is done with variables. You need a directory which will contain your "public" software (PUBDIR). RNA in this version only allows ONE public directory, and all files are taken there. You may put inside PUBDIR a file named "help"; that's the file that will be sent to your guests whenever they ask for it. If there's no help, RNA will say "no help available" (you bet it). You may put inside PUBDIR a file named "index"; when someone asks for an index, RNA does an ls -log , greps out eventual "index" and "help" files, and appends -if existing- this file. Usually it should contain full descriptions of files, warnings, greetings or whatever. You need a dummy login entry for the mail, say "rnalib", and put an alias like " netlib rnalib " ;-) _ Guests should send mail to this login, whose mailbox will be checked by RNA. Don't use root or other system accounts. Last but not least, go in /usr/lib/cron/crontabs and put an entry for executing RNA, say once every hour, or once a day. RNA starts, check if there's mail for it, and if there's nothing waiting it exits. No CPU load. For permissions: RNA wants to be owner of its working directory (of course), owner of it's own mail (of course) and able to go in usr/mail (/usr/spool/mail..) to cp and remove pending messages . RNA needs also PUBDIR to be readable. To configure RNA edit the program itself: at the beginning there's everything you need, and a comment for every variable, so it's really easy and would make this doc useless. Addendum: have a look at getmail() procedure: it set permissions as on my system, you may need to fit your own mail setup. ACCOUNTING ---------- RNA keeps a log of its actions ( file "xxx" sent to "yyy" ), and also keep a copy of all mails, so that you'll always be able to go and see what happened. If you want a "debug" view of what RNA does, set DEBUG inside configuration: debug occurs as stdout, and won't affect default log file. SYNTAX ------ RNA detects command lines by grepping out "@@" headers. Allowed syntax is in the form of: @@ [please] action argument [to] address where [please] and [to] (also To, to:, etc.) don't count; action is only "send" (or SEND etc.), and address is recognized in three forms: - UUCP address, containing a "!" - ARPA address, containing a "@" - local address UUCP and ARPA are checked to be made of at least two words (host and user..). In this case address is validated and passed to your mailer (its business then). Wildcards are not allowed. Security is accomplished by looking for "/" and similar chars. ARCHIVING --------- RNA recognizes non-ascii files by looking at file names. By default any file whose name contains: *.Z* *.z* *.tar* *.cpio* or NO "." at all will be considered non-ascii, and though uuencoded before mailing. Any file with other suffixes, such as .src, .any, .doc etc. will be left as-it-is. Remember that a file like "tetris", with no dots, will be uuencoded. If you want to change this behaviour, change the source, it's easy. COPYRIGHTS, AUTHOR'S NOTES ETC.ETC. ----------------------------------- This is of course freeware, so i don't ask money for it and you can't ask money TO me for any trouble it may cause you. This software may be freely distributed provided you don't make money out of it. This means that EUNET sites are not allowed to use it without explicit request to myself. For a free EUropean CONnection Paolo Ventafridda, July 1989 venta@altger.UUCP ({..}!altos86!altger!venta) venta@i2ack.UUCP (sublink/subnet/s.u.n.: EUcon networks only) {...}!ddsw1!deejay!i2ack!venta (USENET) desperation: pyramid!tmpmbx!deejay!i2ack!venta Don't send through mcvax/unido/i2unix since i am blacklisted, like all of the rest of EUcon. SHAR_EOF fi if test -f 'version' then echo shar: "will not over-write existing file 'version'" else cat << \SHAR_EOF > 'version' Version 1.0 july 1989 If there's some feedback, i can easily add multiple public directories ( send file from dir to user@host ) directory password protection ( send file from dir to user@host password= abcdefg ) and finally sender address. SHAR_EOF fi if test -f 'RNA' then echo shar: "will not over-write existing file 'RNA'" else cat << \SHAR_EOF > 'RNA' : # Remote Network Archive version 1.0 # by venta@i2ack.UUCP (EUcon) # # Before doing anything, Read the manual! # # --------------------------------------------- # setup these DEFines , and you are ready to go # --------------------------------------------- # Archive directory: this is were your archived files are stored. # All the stuff in/out going is merely taken here. Don't choose # other system dirs such as uucppublic. PUBDIR=/usr/spool/uucppublic/rna # # System directory: this is a dedicated directory for rna. System # files, log, and garbage will be put here. This directory will not # be public, and should be closed to others but root. WORKDIR=/usr/local/src/sendnews # # The login used as rna entry: tipically a dummy login, just to allow # mail spooling. Usually stuff like 'fserver', 'netserv', 'netlib' etc. LOGNAME=rnalib # # The local postmaster, i.e. the person which will eventually solve # remote users problems. # If you don't know what a Postmaster is, you are probably in the # wrong place. Put 'root' and go on, this is only a reference. POSTMASTER=root # # The mail file for LOGNAME, complete path. Usually: # /usr/spool/mail/$LOGNAME on Xenix systems # /usr/mail/$LOGNAME on Unix System V and BSD . MAIL=/usr/spool/mail/$LOGNAME # # The name of your machine, as of 'uname -n' or similar.. Hey, dont put # another one, use the correct local machine name. Don't cheat. UNAME=i2ack # # Name of the file containing all of rna logs, status etc. # also called "accounting".. LOGFILE=$WORKDIR/log # # Name of the file which is going to keep record of ALL incoming mails. # Sort of archive, needs to be cleaned up sometimes. MAILFILE=$WORKDIR/mail # # Debugging would occur on stdout, NOT on logfile # 1=debug (try it for fun once), nodebug= leave a SPACE, dont put a 0 DEBUG= # # some progs never in the same place... please tell where they are MAILER=/bin/mail ENCODE=/usr/local/bin/uuencode # # --- internal variables --- TMP=$WORKDIR/tmp CMDS=$WORKDIR/tmpcmds CMDLOG=$WORKDIR/commlog # -------------------- some procedures... ---- quit() { acc "shutdown requested" exit } acc() { echo "`date '+%d.%m.%y - %H:%M:%S` : $@" >>$LOGFILE test $DEBUG && echo "$@" } getmail() { rm $TMP 2>/dev/null mv $MAIL $TMP touch $MAIL; chown $LOGNAME $MAIL; chgrp mail $MAIL; chmod 620 $MAIL touch $MAILFILE; echo "`cat $TMP`\n===\n" >>$MAILFILE } clrfiles() { rm -f $CMDLOG 2>/dev/null; touch $CMDLOG rm -f $CMDS 2>/dev/null } parse() { # some pre-parsing for naughty characters.. grep @@ $TMP | sed 's/\*/ERR/g' >$CMDS if test -s $CMDS; then set `wc -l $CMDS`; cmds=$1 acc "mail contains $cmds command line(s)" test $DEBUG && echo "start parsing" strings="`cat $CMDS`" set -f $strings test $DEBUG && echo "$# words" # # main parse loop # error=0; position=0; action=""; argument=""; destination="" # while [ "$1" != "" ] do test $DEBUG && echo "parsing: $1" case $1 in @@) test $DEBUG && echo restart found action=""; argument=""; position=0; destination="" shift;; ERR) ( acc "parser: wildcards error" ) error=1;; [sS][eE][nN][dD]|[sS][eE][nN][Dd]:) test $DEBUG && echo send detected if test $position -eq 0 then action=send; position=1; shift if test -z "$1" then error=1; test $DEBUG && echo "eof while arg in send" else argument=$1; position=2 shift fi else error=1; test $DEBUG && echo send is in wrong position fi;; [tT][Oo]|[tT][oO]:) test $DEBUG && echo to detected if test $position -eq 2 then shift else test $DEBUG && echo to is in wrong position error=1 fi;; *[Pp]lease*) test $DEBUG && echo please detected if test $position -eq 0 -o $position -eq 2 then shift test $DEBUG && echo please shifted else test $DEBUG && echo error please error=1 fi;; *) if test $position -eq 2 then destination=$1; position=3 shift else test $DEBUG && echo unknown error=1 fi;; esac if test $error -gt 0 then test $DEBUG && echo recovering error while [ "$1" != "@@" ] do test -z "$1" && test $DEBUG && echo eof detected while recovering error test -z "$1" && break shift done error=0 test $DEBUG && echo end rewind fi test $DEBUG && echo action=$action argument=$argument dest=$destination if test $position -eq 3 then ( acc "parser: $action ($argument) to: ($destination)" ) echo $action $argument $destination >>$CMDLOG position=0; argument=""; destination=""; fi # end while done test $DEBUG && echo EOF else acc "parser: no command lines found" fi } interp() { if test -s $CMDLOG; then set `wc -l $CMDLOG`; cmds=$1 ( acc "interpreter: found $cmds command line(s)" ) strings="`cat $CMDLOG`" set -f $strings test $DEBUG && echo "$# words" # # main loop # while [ "$1" != "" ] do test $DEBUG && echo "parsing: $1" # action=""; argument=""; destination="" case $1 in help) action=send shift; shift argument=help destination=$1;; send) action=send shift; argument=$1 shift; destination=$1;; *) ( acc "interpreter error: token $1" ) shift; shift;; esac test $DEBUG && echo "ACTION=$action, ARG=$argument, DEST=$destination" # first we parse destination: if it's illegal, we dont waste # time parsing the argument if test `echo $destination | grep @` then test $DEBUG && echo arpa address if [ `echo $destination | sed 's/@/ /g' | wc -w` -eq 2 ]; then destype=ARPA test $DEBUG && echo valid arpa address else ( acc "interpreter: wrong arpa address \"$destination\" " ) destination=UNKNOWN fi elif test `echo $destination | grep !` then echo UUCP address if [ `echo $destination | sed 's/!/ /g' | wc -w` -ge 2 ]; then test $DEBUG && echo valid uucp address destype=UUCP else ( acc "interpreter: wrong uucp address \"$destination\" " ) destination=UNKNOWN fi else test $DEBUG && echo local delivery destype=LOCAL fi test $DEBUG && echo "status: dest=$destination , arg=$argument , destype=$destype" if test $destination != "UNKNOWN"; then # now we check if argument is valid test $DEBUG && echo destination OK if test "$argument" = "ERR"; then test $DEBUG && echo ERR detected in argument errarg="argument field contains wild characters" argument=ERROR elif test `echo $argument | grep /`; then test $DEBUG && echo ILLEGAL ARG errarg="\"$argument\" is not a valid argument" ( acc "interpreter: $errarg denied to $destination" ) argument=ERROR elif test -r $PUBDIR/$argument; then test $DEBUG && echo FILE $argument is ok ( acc "mailer: sending $argument to $destination" ) errarg=NONE elif test "$argument" = "index"; then test $DEBUG && echo this is an index request but no verbose index available argument=index else test $DEBUG && echo nonexistent $argument errarg="\"$argument\" is not available" ( acc "interpreter: $errarg for $destination" ) argument=ERROR fi # now we ship the stuff . ( echo "Subject: RNA mail from $UNAME"; echo echo "" echo "This is the RNA output for a request destinated to you." echo "Binary files have been uuencoded to an ASCII format." echo if test "$errarg" != "NONE"; then echo "Error: $errarg" echo echo "For more details on this RNA delivery please mail ${POSTMASTER}@${UNAME}." echo "If you need help on the RNA remote commands and usage, send mail" echo "to ${LOGNAME}@$UNAME containing: @@ send help to yourname@yourhost" echo else echo "RNA request: $action \"$argument\" to: \"$destination\" ($destype)" echo if test "$argument" = "index"; then echo; echo "List of available files at $UNAME :"; echo ( set `ls -l $PUBDIR | wc -l`; ls -log $PUBDIR | tail -`expr $1 - 1` | grep -v help | grep -v index ) if test -r $PUBDIR/$argument; then echo; cat $PUBDIR/$argument fi elif test "$argument" = "help"; then echo; if test -r $PUBDIR/$argument; then echo; cat $PUBDIR/$argument else echo "Sorry no help available" ( acc "no help file in public directory" ) fi else # some rules for detecting non-ascii data. ready="" if test `echo $argument | grep '\.Z'` ; then noready="compressed file" elif test `echo $argument | grep '\.z'`; then noready="crypted file" elif test `echo $argument | grep '\.tar'`; then noready="tar file" elif test `echo $argument | grep '\.cpio'`; then noready="cpio file" elif test ! "`echo $argument | grep '\.'`"; then noready="program file" else noready="ascii file" ready=OK fi echo "( $noready )" echo echo "+------ cut start of $argument ----------------------------------+" if test $ready ; then cat $PUBDIR/$argument else $ENCODE $PUBDIR/$argument $argument ( acc "encoding $noready" ) fi echo "+------ cut end of $argument ----------------------------------+" echo; fi fi ) | $MAILER $destination # fi shift # end while done #echo EOF else ( acc "interpreter: no valid commands found" ) fi } # ----------------------------------- # main program # ----------------------------------- touch $LOGFILE test -r $WORKDIR/shutdown && quit test -s $MAIL && ( acc "found mail"; clrfiles; getmail; parse; interp ) # end of RNA SHAR_EOF fi exit 0 # End of shell archive -- Paolo Ventafridda, Milano -Italy _ Sublink (EUcon): venta@i2ack.UUCP **** **** The SUBLINK Foundation _ +39-2-4035289 (300-2400 MNP4, 9600 PEP) . For a free EUropean CONnection .