home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume15 / rnalib2 / part03 < prev    next >
Encoding:
Text File  |  1990-10-05  |  55.2 KB  |  1,809 lines

  1. Newsgroups: comp.sources.misc
  2. X-UNIX-From: otello!i2ack!venta@italy.sublink.org
  3. from: venta@i2ack.sublink.org (Paolo Ventafridda)
  4. subject: v15i013: RNALIB_20/part03
  5. Sender: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  6.  
  7. Posting-number: Volume 15, Issue 13
  8. Submitted-by: venta@i2ack.sublink.org (Paolo Ventafridda)
  9. Archive-name: rnalib2/part03
  10.  
  11. #!/bin/sh
  12. # This is part 03 of RNALIB_20
  13. if touch 2>&1 | fgrep '[-amc]' > /dev/null
  14.  then TOUCH=touch
  15.  else TOUCH=true
  16. fi
  17. # ============= RNA ==============
  18. echo "x - extracting RNA (Text)"
  19. sed 's/^X//' << 'SHAR_EOF' > RNA &&
  20. X# @(#)RNA 2.0 [revision A]  18 Sep 1990
  21. X#
  22. X#                 = WELCOME TO RNALIB CONFIGURATION = 
  23. X# ------------------------------------------------------------------------
  24. X# Your attention please: we strongly suggest that you read carefully
  25. X# every comment in the following lines. This configuration comes together
  26. X# with necessary documents, step by step. Skip comments at your own
  27. X# risk: you may not understand the Operator's Guide later on!
  28. X# We all hate reading long docs. This is not long, it's just the minimum
  29. X# you need to know about the program. Consider these comments as 
  30. X# part of the operator's manual. They are *not by any means 'optionals'.
  31. X# ------------------------------------------------------------------------
  32. X#
  33. X# PATH: rna looks for 'sed', 'head' and other usual unix utilities inside
  34. X# this path definition. Put here your usual paths, like..
  35. XPATH=/bin:/usr/bin:/usr/local/bin:/etc:/usr/local/etc:.
  36. X#
  37. X# Administrator's directory: this is a dedicated directory for rna. System
  38. X# files such as mail log, accounting etc. will be put here. 
  39. X# This directory will not be public, and should be closed to others 
  40. X# but  rnalib owner. This directory will not contain garbage.
  41. X# You can put the home directory of LOGNAME (see forward).
  42. X# RNADIR=/usr/rnalib
  43. XRNADIR=/usr/rnalib
  44. X#
  45. X# Temporary directory: garbage stuff is going to be put here. 
  46. X# You might choose a subdirectory of RNADIR; do not choose /tmp, you might
  47. X# get problems later on. Use a dedicated directory owned by rna.
  48. X# This folder is not going to take much space anyway.
  49. XTMPDIR=$RNADIR/tmp
  50. X#
  51. X# Temporary directory: IF you allow file compression, outgoing stuff will 
  52. X# be put here and then compressed before ship. You might choose the same
  53. X# place of TMPDIR. USE a dedicated directory, do not use /tmp.
  54. XCONVDIR=$RNADIR/convert
  55. X#
  56. X# The login used as rna entry: tipically 'rnalib'. Create this entry inside
  57. X# /etc/passwd. Home directory is not really important: the only needed thing is 
  58. X# that this user has to execute RNA and will receive query and rejected mail.
  59. X# You'll get more info on how to create this user inside OPER.GUIDE .
  60. X# By now, just pick up a name. Users will mail this name to access your
  61. X# libraries. But they could use aliases as well. Don't worry now.
  62. X# 
  63. XLOGNAME=rnalib
  64. X#
  65. X# The name of your machine, as of 'uname -n' or similar.. Hey, dont put
  66. X# another one, use the correct local machine name. Don't cheat.
  67. X# If you are under some domain include it. Ex: i2ack.SUBLINK.ORG
  68. X# 
  69. X#UNAME=host.domain
  70. XUNAME=i2ack.sublink.ORG
  71. X#
  72. X# The local postmaster, i.e. the person which will eventually solve
  73. X# remote user's problems.
  74. X# If you don't know what a Postmaster is, you are probably in the
  75. X# wrong place. Put 'root@$UNAME' and go on, this is only a reference.
  76. X# Remember to include username AND host (+ domain, if any), for instance
  77. X# venta@i2ack.SUBLINK.ORG . Postmaster need not to be on the same machine
  78. X# were RNALIB is placed! Just think of local networks...
  79. X#POSTMASTER=boss@host.domain
  80. XPOSTMASTER=venta@i2ack.sublink.org
  81. X#
  82. X# When (IF) 'compress 'is used to ship files, their names are extended with
  83. X# a '.Z'. If your UNIX is a System V, maximum file name lenght is 14; if you
  84. X# are on BSD, it's 256; if you are on a Olivetti LSX it's 128 etc.
  85. X# Subtract 2 from your maximum file name lenght and fill the following 
  86. X# variable: for instance, if you have max 14 characters names, put (14-2)=12.
  87. XMAXLENGTH=12
  88. X# 
  89. X# The mail file for LOGNAME, complete path. Usually:
  90. X# /usr/spool/mail/$LOGNAME  on Xenix systems and SCO unix
  91. X# /usr/mail/$LOGNAME  on Unix System V and BSD .
  92. XMAILBOX=/usr/mail/$LOGNAME
  93. X#
  94. X# Name of the file containing all of rna logs, status etc. 
  95. X# also called "accounting"..
  96. X# Be tidy! Keep it inside RNADIR.
  97. XLOGFILE=$RNADIR/account
  98. X#
  99. X# Name of the file which is going to keep record of ALL incoming mails 
  100. X# (NOT the rejected mails...that would be stupid!). You may use this
  101. X# file as a normal mail folder for programs like 'ELM'. Remember to
  102. X# clear it out once every while ;-)
  103. X# Be tidy! Keep it inside RNADIR.
  104. XMAIL_LOG=$RNADIR/mail
  105. X#
  106. X# Name of the public directory for transfers using 'uucp' or 'uusend'.
  107. X# We suggest a '~' (which leads to /usr/spool/uucppublic) as default;
  108. X# if you are going to change this, remember that remote sites need this
  109. X# path to be writable, or your files will be rejected!
  110. X# Do also consider that some UUCP emulators - such as UFgate or Waffle -
  111. X# do *not recognize "/usr/spool/uucppublic", but *accept "~".
  112. XPUBDIR=~
  113. X#
  114. X# Debugging would occure on stdout, NOT on LOGFILE.
  115. X# 1=debug (try it for fun), nodebug= leave it EMPTY, dont put a 0
  116. X# Debug is for interactive usage only. Do not set debug mode for daemon task.
  117. XDEBUG=1
  118. X#
  119. X# Some progs never in the same place... please tell me: where is the mailer?
  120. X# I mean the one you would use as 'mail user' to send mail to user. 
  121. X# Ususally /bin/mail, though on some systems you could try /bin/rmail.
  122. X# Since RNA adds its own Subject line, be sure the mailer does not ask for it!
  123. X# If RNA messages comes without a Subject this is the reason..
  124. XMAILER=/bin/mail
  125. X#
  126. X# Where is 'uuencode'? I assume you have this utility. If you don't have this
  127. X# utility you are not likely to ship binary files via mail. 
  128. X# 
  129. XUUENCODE=/usr/local/bin/uuencode
  130. X#
  131. X# Where is 'btoa'? If you don't have it, leave it EMPTY  (nothing after the = )
  132. X# Btoa is better than uuencode: it saves some 15% space. You don't really
  133. X# need it for RNA, but if you happen to have btoa put it here. Default encoding
  134. X# still will be the good-old uuencode. Beware: i am referring to the second
  135. X# version of btoa, the one that does not need 'atob' to convert back.
  136. X# Still this version is compatible with the old release, BUT syntax to use
  137. X# is quite different. If you have an old version of btoa, no problem: find
  138. X# the RNA procedure called 'Convert_File()'; there's a 'case' inside, and
  139. X# a notice about this matter.
  140. XBTOA=/usr/local/bin/btoa
  141. X#
  142. X# Where is 'compress'? If you don't have it, leave it EMPTY 
  143. X# (nothing after the =). It sounds pretty strange to me an empty declaration
  144. X# here, since the whole world nowdays has compress. Ask for GNU-compress!
  145. XCOMPRESS=/usr/local/bin/compress
  146. X#
  147. X# Where do you keep 'uucp', the usual command?
  148. X# I know everybody has one. If you don't want files travelling over
  149. X# the network with 'uucp' then omit the declaration: files will be
  150. X# travelling in ascii format via normal e-mail. 
  151. X# Caution: read Operator's Guide chapter 'Transmission layers'!
  152. XUUCP=/usr/bin/uucp
  153. X#
  154. X# Where is 'uusend'? If you don't have it, leave it EMPTY (nothing after 
  155. X# the = ). This is a common utility which replaces 'uuto' and 'uucp' on
  156. X# some old (V7) uucp based systems. 
  157. X# Caution: read Operator's Guide chapter 'Transmission layers'!
  158. XUUSEND=/usr/local/bin/uusend
  159. X#
  160. X# Where is 'file'? As you should know, this is a Berkeley utility now
  161. X# commonly distributed with almost *every serious unix system.
  162. X# 'file' examines a specified file and gives informations about it.
  163. X# Since RNA has to figure out by itself whether or not requested files
  164. X# are ASCII or BINARY, we definitively *need* the berklish 'file'.
  165. X# So know, com'on..
  166. XBKFILE=/bin/file
  167. X#
  168. X# Where is 'strings' ? we use it just a couple of times, to grep out
  169. X# blank lines from 'pathsize' (you'll learn about it later on).
  170. X# This command is pretty standard, however my 3B2 with Unix 3.2 is
  171. X# missing it (*sic)! I wrote a small 'strings.c' which you might
  172. X# compile and use in case there's no 'strings' on your system.
  173. XSTRINGS=/usr/local/bin/strings
  174. X# 
  175. X# This is important (;-)). RNA needs an index file containing libraries'
  176. X# names along with their real paths. Since you are installing RNA for
  177. X# something, i assume you HAVE at least one 'library', don't you?
  178. X# With RNA distribution comes a file named 'libindex' which contains
  179. X# some more docs about its structure. "libindex" is my suggested name for..
  180. X# [ NOTE: inside OPER.GUIDE we always refer to this suggested name. ]
  181. XLIBIND=$RNADIR/libindex
  182. X#
  183. X# This file contains names/paths which are not allowed to use RNA.
  184. X# With RNA distribution comes a file named 'black' which contains some
  185. X# more docs about its structure. "black" is my suggested name for..
  186. X# [ NOTE: inside OPER.GUIDE we always refer to this suggested name. ]
  187. XBLACKLIST=$RNADIR/black
  188. X#
  189. X# This file contains names/paths which are authorized to forward RNA requests
  190. X# for others, i.e.: send files to other people. Normally RNA sends back to
  191. X# the original user/system who sent the mail.
  192. X# With RNA distribution comes a file named 'white' which contains some
  193. X# more docs about its structure. "white" is my suggested name for..
  194. X# [ NOTE: inside OPER.GUIDE we always refer to this suggested name. ]
  195. XWHITELIST=$RNADIR/white
  196. X#
  197. X# If something goes wrong with the mail, RNA will receive back its stuff
  198. X# from somewhere. Of course this is a dangerous situation, so RNA will
  199. X# recognize and skip this mail. A copy will be put inside..
  200. X# [ NOTE: inside OPER.GUIDE we always refer to this suggested name. ]
  201. XREJECTED=$RNADIR/rejected
  202. X#
  203. X#
  204. X# You may choose to limit rna activities within certain paths to
  205. X# a definite amount of bytes transmitted. For instance, you would
  206. X# like to keep an host under control: if that host asks for more than
  207. X# -say- 300.000 bytes, any further request should be denied. This is
  208. X# called 'pathsizing'. RNA will check that any request coming from somewhere
  209. X# has 'credits' before accepting its query; afterwards, its credits will be
  210. X# updated. Following variable contains the name of the file which is going
  211. X# to keep paths&credits notes. 
  212. X# If you don't care about 'pathsizing', leave it blank.
  213. X# [ NOTE: inside OPER.GUIDE we always refer to this suggested name. ]
  214. XPATHSIZE=$RNADIR/pathsize
  215. X#
  216. X# (Needed only if you chose pathsizing above) 
  217. X# If a path is not appearing inside pathsize, by default a no-limit credit
  218. X# is given. You may want RNA to automatically add any new path to its
  219. X# pathsize, with a default credit given. So...
  220. X# Put a  0   if you want that new sites ask to be registered before being
  221. X#            authorized to use your RNA service. Any new path will be notified
  222. X#            that a membership is required in order to use your service.
  223. X# Put a size in bytes -say 200000 (do not put any fullstops!)- as default
  224. X#            credit limit for any new path. 'pathsize' will be updated with
  225. X#            this new path and this number.
  226. X# Leave it BLANK if you don't want to limit new paths. This way only paths
  227. X#            already included inside 'pathsize' will be affected by pathsizing.
  228. X# More info inside RNA Operator's Guide, chapter 'Pathsizing'.
  229. XCREDIT=300000
  230. X#
  231. X# You are done. No more variables to configure. You need to check for
  232. X# RNADIR TMPDIR CONVDIR and (if not '~') PUBDIR existance; remind!
  233. X# NOW search forward for ' %%FIX%% ' : these are entry points for
  234. X# possible configuration-dependent problems. Do check every %%FIX%%
  235. X# and be sure everything is ok. The last %%FIX%% has some more 
  236. X# informations for you. Do carefully follow %%FIX%% (again) until
  237. X# the last one (it tell's you that you got to the final fix, don't
  238. X# worry). Happy 'tuning'!
  239. X# 
  240. X# ==============================================================
  241. X#
  242. X# Internal tmp files.
  243. X# -------------------
  244. XMBOX_COPY=$TMPDIR/tmp
  245. XMBOX_CUT=$TMPDIR/cut
  246. XCMDS=$TMPDIR/tmpcmds
  247. XCMDLOG=$TMPDIR/commlog
  248. XPOINTERS=$TMPDIR/punt
  249. XERRSTAT=$TMPDIR/err
  250. XOUTFILE=$TMPDIR/outfile
  251. XUUCP_ADDRESS=$TMPDIR/address
  252. X# -------------------- some procedures... ----
  253. X
  254. X# %%FIX%%
  255. XGetMail() {
  256. X#    This function does three things; 1st) moves rnalib mailbox into
  257. X#    a temporary file. 2nd) creates back a new empty rnalib mailbox
  258. X#    3rd) archives the temporary files inside another mailbox file.
  259. X#    You might need to fix JUST the 2ND thing..
  260. X    rm $MBOX_COPY 2>/dev/null
  261. X    mv $MAILBOX $MBOX_COPY
  262. X#    .. here it is: we CREATE BACK THE ORIGINAL MAILBOX, for instance
  263. X#    /usr/spool/mail/rnalib   or  /usr/mail/rnalib  or whatever.
  264. X#    A simple 'touch $MAILBOX' could do; HOWEVER be *very *sure that
  265. X#    the new mailbox has the right owner/group permissions once created.
  266. X#    This is all you need: a regular empty folder, just like a normal one.
  267. X#    Here are some suggestions:
  268. X#    '>$MAILBOX'    (easy to start with)
  269. X#    'touch $MAILBOX; chown $LOGNAME $MAILBOX; chgrp mail $MAILBOX;
  270. X#     chmod 620 $MAILBOX'   etc. Watch out for that 620, you might need
  271. X#    to change it; just an example!
  272. X#    Don't panic and carefully fix the following line:
  273. X#
  274. X    touch $MAILBOX; chown $LOGNAME $MAILBOX; chgrp mail $MAILBOX; chmod 666 $MAILBOX
  275. X#
  276. X#    That's all. Leave the rest as-it-is. Go on for the next fix..    
  277. X    touch $MAIL_LOG; echo "`cat $MBOX_COPY`\n" >>$MAIL_LOG 
  278. X}
  279. X
  280. XStartup() {
  281. X    touch $LOGFILE
  282. X    message=1
  283. X}
  284. X
  285. XClrTmpFiles() {
  286. X    rm -f $CMDLOG 2>/dev/null; touch $CMDLOG
  287. X    rm -f $ERRSTAT 2>/dev/null; touch $ERRSTAT
  288. X    rm -f $CMDS 2>/dev/null
  289. X    rm -f $CONVDIR/*.Z 2>/dev/null
  290. X    rm -f $UUCP_ADDRESS 2>/dev/null; touch $UUCP_ADDRESS
  291. X    rm -f $OUTFILE 2>/dev/null; touch $OUTFILE
  292. X    ARPA_SENDER=""; UUCP_SENDER=""; REQUEST_DATE=""; UUCP_HOST=""
  293. X    UUCP_DESTIN=""
  294. X}
  295. X
  296. XCutMail() {
  297. XNotTheFirst=0
  298. Xrm -f $POINTERS 2>/dev/null; touch $POINTERS
  299. X
  300. Xgrep -n '^From ' $MBOX_COPY | PrintSumm
  301. Xset `cat $MBOX_COPY | wc -l`; echo $1 >>$POINTERS
  302. X}
  303. X
  304. XPrintSumm()
  305. X{
  306. X    IFSorg=$IFS
  307. X    while read Linea
  308. X    do
  309. X    IFS=$IFSorg
  310. X    set $Linea
  311. X
  312. X# %%FIX%%
  313. X#     This is a VERY IMPORTANT FIX- watch out!
  314. X#    Question: how many fields has the very first 'From' line of a
  315. X#              mail message on YOUR system? 
  316. X#    To answer, do a shell escape from your editor NOW and mail yourself
  317. X#    a message. Then edit your mailbox, and examine the first From, the
  318. X#    one WITHOUT colons. Here's mine, for instance:
  319. X#       From deejay!gear!marlor Wed Feb 21 12:32:44 1990
  320. X#     1            2          3   4  5     6       7
  321. X#    So i know my mailer adds a 7-field From header.
  322. X#    Your mailer could add a timezone as well, and you would get 8 fields.
  323. X#    RNA does not trust by default any (apparently) valid header.
  324. X#    We extract the beginning of a mail inside our mailbox looking for
  325. X#    a 'From '(note the space) standing on a 7 (or whatever) fields line.
  326. X#    [ELM 2.2 just looks for a From with a space and more than 2 fields]
  327. X#    Replace the following number with the one you need:
  328. X
  329. X    if [ $# = 7 ]
  330. X    then
  331. X        IFS=":$IFSorg"
  332. X        set $Linea
  333. X        NumDiLinea=$1
  334. X        if [ $NotTheFirst != 0 ]
  335. X        then
  336. X        echo "`expr $NumDiLinea - 2`" >>$POINTERS
  337. X        fi
  338. X        echo "$NumDiLinea \c" >>$POINTERS
  339. X        NotTheFirst=1
  340. X    fi
  341. X    done
  342. X
  343. X    IFS=$IFSorg
  344. X}
  345. X
  346. XCut_Address() {
  347. X    echo "$UUCP_SENDER" >> $UUCP_ADDRESS
  348. Xif [ "$destination" != "DEFAULT" ]; then
  349. X    set `sed -e "s/@/@ /" $UUCP_ADDRESS`; UUCP_HOST=$2"!"
  350. Xelse
  351. X    set `sed -e "s/[A-Za-z0-9]*$//g" $UUCP_ADDRESS`; UUCP_HOST=$1
  352. Xfi
  353. X}
  354. X
  355. XGetMessage() {
  356. X    set `sed -n "$1 l" $POINTERS`
  357. X    sed -n "$1,$2 l" $MBOX_COPY  >$MBOX_CUT
  358. X}
  359. X
  360. XGetDir()
  361. X# this function gets a library name and returns its related path.
  362. X# If library does not exist, nothing is returned. An argument is
  363. X# expected. Lines containing " # " in $LIBIND are simply skipped.
  364. X{
  365. Xsearch=$1
  366. Xset -f `grep -v '^#' $LIBIND`
  367. Xwhile [ "$1" != "" ]
  368. Xdo
  369. X    test "$1" = "$search" && shift && echo $1 && break
  370. X    shift
  371. Xdone
  372. X}
  373. X
  374. X
  375. XStripPermAndLink()
  376. X{
  377. X    while read line
  378. X    do
  379. X    set -- $line
  380. X    echo "$3\t$4,$5\t$6\t$7"
  381. X    done
  382. X}
  383. X
  384. X
  385. XFileType()
  386. X# Arg: file_path  (full)
  387. X# Returns: null if file is ASCII-TEXT; output of "file" command if not.
  388. X{
  389. Xfilename=$1; IFSorg=$IFS
  390. XIFS=":"; set `echo "dummy"; $BKFILE $filename | grep -v text`; IFS=$IFSorg
  391. Xtest -n "$2" && echo $2
  392. X}
  393. X
  394. X
  395. X
  396. XGetFile()
  397. X# Parameters: static $argument $from
  398. X# Returns:  path_to_file; null if file does not exist
  399. X{
  400. XGFpath=`GetDir $from`
  401. Xif [ "$GFpath" != "" ]; then
  402. X    test -r $GFpath/$argument && echo $GFpath/$argument 
  403. Xfi    
  404. X}
  405. X
  406. XListLib()
  407. X# Parameters: library
  408. X{
  409. XLLlib=$1
  410. XLLpath=`GetDir $LLlib`
  411. Xecho "\nList of files inside \c"
  412. X
  413. Xif [ "$LLlib" = "DEFAULT" ]; then
  414. X    echo "RNA system library:";
  415. Xelse
  416. X    echo "\"$LLlib\" library:\n"
  417. Xfi
  418. X
  419. Xif [ "$LLpath" = "" ] 
  420. Xthen
  421. X    NoLibrary_Msg
  422. Xelse
  423. X    ls -got $LLpath | StripPermAndLink
  424. Xfi
  425. X}
  426. X
  427. XFindFile()
  428. X# Parameters: characters to match in searched file
  429. X# Returns: matching libraries and files, if any
  430. X{
  431. XFFchars=$1; FFmatch=
  432. Xecho "\nREQUEST: search for file names containing <$FFchars>."
  433. Xecho "         Look inside all available libraries, and\n\
  434. X         try  both  lower/upper case combinations.\n"
  435. Xecho "=====================================================\n"
  436. Xset -f `grep -v '#' $LIBIND`
  437. Xwhile [ "$1" != "" ]
  438. Xdo
  439. X    FFlib=$1; FFpath=$2;
  440. X# %%FIX%%
  441. X# On Unix V.3.2 (?) like the one from SCO, the 3B2 etc., grep's family
  442. X# commands follow Posix. Posix suppressed '-y' and added '-i'.
  443. X# Jesus, all we want is a non-case sensitive grep! If you run sco-xenix 386,
  444. X# 'grep -y' should work. If you are on SCO-unix, 'fgrep -y' will.
  445. X# Generally, 'fgrep -i' is a good chance (3B2 Unix 3.2)
  446. X# Have a look at your grep/fgrep and pick up the right one. Change the
  447. X# following line, if needed..................++++++++
  448. X    ls -got $FFpath | StripPermAndLink | fgrep -i $FFchars && {
  449. X        echo "\nfound inside library: \"$FFlib\""
  450. X        echo "\n=====================================================\n"
  451. X        FFmatch=ok
  452. X        }
  453. X    shift; shift
  454. Xdone
  455. Xtest -z "$FFmatch" && {
  456. X    echo "\tNo matching files found - sorry"
  457. X    echo "\n=====================================================\n"
  458. X    }
  459. X
  460. X}
  461. X
  462. XCut_Ls()
  463. X# %%FIX%%
  464. X# We need to grep out of 'ls -log' the bytes number. Since the output
  465. X# of that 'ls' is:   -rwxr-xr-x   1   33275 Feb  8 12:25 RNA
  466. X# we use 'cut' (a common text utility) to pick up the right field.
  467. X# On my system it came out from the 15th to 23th characters. Check yours too,
  468. X# and find the right "-cn-n" (n=number) which extracts bytes. Good luck.
  469. X# (Don't panic: on sco xenix386, sco unix, olivetti lsx, hp-ux and at&t 3b2
  470. X#  the 15-23 was fine. Probably it's ok for your site also)
  471. X#
  472. X{
  473. Xcut -c15-23
  474. X}
  475. X
  476. XGetCat()
  477. X{
  478. Xlibr=$1
  479. Xif [ "`GetDir $libr`" = "" ]; then
  480. X    NoLibrary_Msg
  481. Xelse
  482. X    file="`GetDir $libr`/INDEX"
  483. X    test -r $file && echo "\n`cat $file`" || echo "\n\
  484. XNo index available for \"$1\" library, sorry.\n\
  485. XHere comes a list of contents..."
  486. Xfi
  487. X}
  488. X
  489. XBlackList()
  490. X# Gets internal uucp-from path and checks if it's blacklisted.
  491. X# Returns: blacklist matching, or nothing at all.
  492. X{
  493. Xset -f `grep -v '#' $BLACKLIST`
  494. Xwhile [ "$1" != "" ]
  495. Xdo
  496. X    test -n "`echo $UUCP_SENDER | grep $1`" && {
  497. X    echo "<$1> is matched inside <$UUCP_SENDER>" && break; }
  498. X    shift
  499. Xdone
  500. X}
  501. X
  502. XToCheck()
  503. X# checks if sender is authorized to use "To" or not.
  504. X# returns a string if it's ok, nothing if not.
  505. X{
  506. Xset -f `grep -v '#' $WHITELIST`
  507. X#while test -n "$1"
  508. Xwhile [ "$1" != "" ]
  509. Xdo
  510. X    test -n "`echo $UUCP_SENDER | grep $1`" && {
  511. X    echo "<$1> is matched inside <$UUCP_SENDER>" && break; }
  512. X    shift
  513. Xdone
  514. X}
  515. X
  516. XWith_Type() 
  517. X{
  518. Xencode_type="none"; compress_type="none" 
  519. Xcase $with in 
  520. X    compr|Compr|COMPR|\
  521. X    compress|COMPRESS|Compress)
  522. X        encode_type="uuencode"
  523. X        compress_type="compress" 
  524. X        ;;
  525. X
  526. X    compr-btoa|Compr-Btoa|COMPR-BTOA|\
  527. X    compress-btoa|COMPRESS-BTOA|\
  528. X    Compress-Btoa)
  529. X        encode_type="btoa"
  530. X        compress_type="compress" 
  531. X        ;;
  532. X    
  533. X    compr-uuenc|Compr-Uuenc|COMPR-UUENC|\
  534. X    compress-uuencode|COMPRESS-UUENCODE|\
  535. X    compress-encode|COMPRESS-ENCODE|\
  536. X    Compress-Uuencode|Compress-Encode)
  537. X        encode_type="uuencode"
  538. X        compress_type="compress" 
  539. X        ;;
  540. X
  541. X    DEFAULT|UUENCODE|ENCODE|\
  542. X    uuencode|encode|ascii|\
  543. X    Uuencode|Encode|ASCII)
  544. X        encode_type="uuencode"
  545. X        compress_type="none"
  546. X        ;;
  547. X
  548. X    BTOA|btoa|Btoa)    
  549. X            encode_type="btoa"
  550. X        compress_type="none"
  551. X        ;;
  552. X
  553. X#    %%FIX%%
  554. X#    The sender used a strange "with" field; a default behaviour
  555. X#    follows. Put 'reject' as encode_type if you do not want any mailing
  556. X#    whenever there's an invalid 'with'. 
  557. X#    Currently this error is ignored (with a warning) and the stuff is
  558. X#    shipped all the same using uuencode.
  559. X#    This is just to let you know you can do it. No need to touch it
  560. X#    for a normal usage.
  561. X
  562. X    *)    
  563. X            encode_type="uuencode"
  564. X        compress_type="none"
  565. X        WithError_Msg >>$OUTFILE
  566. X        NeedHelp_Msg >>$OUTFILE
  567. X        ;;
  568. Xesac
  569. X
  570. Xif [ "$compress_type" != "none" ]; then
  571. Xset `echo $argument | wc -c`; length=`expr $1 - 1`
  572. X    if [ "$length" -gt "$MAXLENGTH" ]; then
  573. X    NoSuffix_Msg >> $OUTFILE
  574. X    echo "\
  575. XSubject: WARNING, file name too long for RNA compress\n\n\
  576. X    Please rename file: \"$fname\" if possible.\n\
  577. X    Its name is longer than \"$MAXLENGTH\" characters and\n\
  578. X    RNA users can't ask for \"$COMPRESS\" shippings.\n\n\
  579. X                          Your friendly RNALIB DAEMON\n" | $MAILER $POSTMASTER 
  580. X    return
  581. X    else
  582. X    FCPRNAME=$CONVDIR/$argument".Z"
  583. X    argument=$argument".Z"
  584. X    fi
  585. X#    Check if 'compress' is available.
  586. X    test $COMPRESS || { NoCompr_Msg >> $OUTFILE; return; } && $COMPRESS -c $fname > $FCPRNAME
  587. X    test -s $FCPRNAME || { Already_Msg >> $OUTFILE; return; } && fname=$FCPRNAME 
  588. X    Compr_Msg >>$OUTFILE
  589. Xfi
  590. X
  591. X}
  592. X
  593. XConvert_File()
  594. X{
  595. Xftype=""; ftype="`FileType $fname`"
  596. X
  597. Xif [ "$viasped" != "NO_MAIL" ]; then
  598. X
  599. X# Did the sender request a special "with" for a simple ASCII file?
  600. X# If so, we reject his request and ship the file as-it-is.
  601. Xtest $with != "DEFAULT"  && test "$ftype" = ""  && NoNeed_Msg >>$OUTFILE 
  602. X
  603. Xif [ "$ftype" = "" ]; then
  604. Xencode_type="none"
  605. Xfi
  606. X
  607. X# If user asked for btoa encoding, see if btoa is available.
  608. X# If btoa is not available we WON'T use uuencode; i suppose the sender had 
  609. X# some reasons to choose btoa...
  610. Xif [ "$encode_type" = "btoa" ]; then
  611. X    test $BTOA || { NoBtoa_Msg >>$OUTFILE; return; } && Convert_Msg >>$OUTFILE
  612. Xfi
  613. X# The following 'fi' refers to 'viasped != no_mail'.
  614. Xfi
  615. X
  616. Xtest "$encode_type" = "uuencode" && test "$viasped" != "NO_MAIL" && Convert_Msg >>$OUTFILE
  617. X
  618. X# We are about to ship the stuff; let's see if the destination address is 
  619. X# different from the sender. If so, it's an authorized "external request"
  620. X# and we want to notify the destination about it. 
  621. X# Beware of 'reject' encode_type: we want to be sure that the stuff is sent
  622. X# to the external destination only, in this case. Error announcements HAVE
  623. X# to go to the original sender (what a mess!).
  624. Xif [ "$encode_type" != "reject" ]; then
  625. X    if [ "$destination" != "DEFAULT" ]; then
  626. X        echo "\n\
  627. XNote: this is an external request forwarded by $ARPA_SENDER for you.\n\
  628. X      Original mail path is: <$UUCP_SENDER> .\n\
  629. X             " >>$OUTFILE
  630. X    fi
  631. Xfi
  632. X
  633. Xtest "$viasped" != "NO_MAIL" &&
  634. X    echo "\n-rnalib---------------------- cut here for \"$argument\" ------------" >>$OUTFILE
  635. X
  636. Xcase $encode_type in
  637. X
  638. X#    syntax: uuencode path/file internal_filename
  639. X    uuencode)
  640. X        if [ "$viasped" = "NO_MAIL" ]; then
  641. X            NoConv_Msg >> $OUTFILE
  642. X        else
  643. X            $UUENCODE $fname $argument >>$OUTFILE
  644. X        fi ;;
  645. X
  646. X#    %%FIX%%
  647. X#    Syntax: btoa path/file -- warning: using old versions of btoa requires
  648. X#    'cat $fname | btoa >>$OUTFILE' or something like. Get the new release!
  649. X    btoa)
  650. X        if [ "$viasped" = "NO_MAIL" ]; then
  651. X            NoConv_Msg >> $OUTFILE
  652. X        else
  653. X            $BTOA $fname >>$OUTFILE
  654. X        fi ;;
  655. X
  656. X#    encode_type equals "none" only if file is not binary, or if it
  657. X#    going to be shipped with uusend or uucp (if available)
  658. X    none)
  659. X        if [ "$viasped" = "NO_MAIL" ]; then
  660. X            NoConv_Msg >> $OUTFILE
  661. X        else
  662. X            cat $fname >>$OUTFILE
  663. X        fi ;;
  664. X
  665. X#    Configuration choice: if $with is not a valid argument don't ship
  666. X#    the binary encoding with "uuencode"; notify the sender, though.
  667. X    reject) echo "\nPlease re-submit your request with proper parameter\n" >>$OUTFILE;;
  668. X    
  669. X    *) echo "\nRNA INTERNAL ERROR inside procedure Convert_File\n" >>$OUTFILE
  670. X    echo "WARNING: convert internal error (notified to operator)" >>$LOGFILE
  671. X    test $DEBUG && echo "Internal error: encode_type=$encode_type";;
  672. X
  673. Xesac
  674. X
  675. Xtest "$viasped" != "NO_MAIL" &&
  676. X    echo "\n-rnalib----------------------- end of file \"$argument\" ------------" >>$OUTFILE
  677. X
  678. X#    Be *very sure we are not shipping errors to an external destination!
  679. Xif [ "$encode_type" != "reject" ]; then
  680. X    if [ "$destination" != "DEFAULT" ]; then
  681. X
  682. X#        change destination...and good luck for delivery!
  683. X
  684. X        UUCP_SENDER=$destination    
  685. X        ARPA_SENDER=$destination
  686. X    fi
  687. X    echo "Sent < $argument from $from - via $via > to $ARPA_SENDER" >>$LOGFILE
  688. Xfi
  689. X       
  690. X}
  691. X
  692. X
  693. XMail_File()
  694. X{
  695. Xtest $DEBUG && echo "Now mailing: $UUCP_SENDER"
  696. XSignature >>$OUTFILE
  697. X# %%FIX%%
  698. X# If you trust or need domain addressing, then change $UUCP_SENDER
  699. X# with $ARPA_SENDER. Think about this twice; let the bang routing
  700. X# unless you *know *what *you *are *doing. 
  701. X# This won't work with external destinations, of course.
  702. X# If mail header did not contain an rfc822 arpa address then
  703. X# don't worry: arpa_sender will just be a copy of uucp_sender.
  704. Xcat $OUTFILE | $MAILER $UUCP_SENDER
  705. X# We need to grep out of 'ls -log' the bytes number. 
  706. Xset `ls -log $OUTFILE | Cut_Ls`
  707. Xecho "Reply of $1 bytes sent to: $UUCP_SENDER" >>$LOGFILE
  708. X#
  709. Xtest -n "$PATHSIZE" && Bill $OUTFILE
  710. Xrm -f $OUTFILE 2>/dev/null; touch $OUTFILE
  711. X}
  712. X
  713. X
  714. XCheck_PathSize()
  715. X# $1 = path/user to check
  716. X# returns: null if unknown path; otherwise current credit size.
  717. X{
  718. Xps_origin=$1
  719. X# Warning: file 'pathsize' in this version of RNA needs a dummy line
  720. X# like ' user 0 '  or 'user@host 0' for the *very *first user update.
  721. X# In other words, if you are applying pathsizing, your 'pathsize'
  722. X# has to contain a first line to work on. Pathsize cannot be empty!
  723. X# Technically, what happens is that shell gets angry since it
  724. X# cannot shift 'ps_credit'. This will be fixed in future versions.
  725. Xset -f `grep -v '#' $PATHSIZE`
  726. Xwhile [ "$1" != "" ]; do
  727. X    ps_path=$1; ps_credit=$2; shift; shift
  728. X     test -n "`echo $ps_origin | grep $ps_path`" && echo $ps_credit && break
  729. Xdone
  730. X}
  731. X
  732. X
  733. XAdd_PathSize()
  734. X# It's named 'Add', but really it subtracts sizes! 
  735. X# $1 = path/user to update; $2 = umount to subtract
  736. X{
  737. Xps_origin=$1; ps_size=$2;
  738. X# strip comments, as usual
  739. Xset -f `grep -v '#' $PATHSIZE`
  740. Xwhile [ "$1" != "" ]; do
  741. X    ps_path=$1; ps_credit=$2; shift; shift
  742. X#    Is this path matching the one we are checking?
  743. X     test -n "`echo $ps_origin | grep $ps_path`" && {
  744. X#        Yep. Let's calculate the new credit, and...
  745. X         ps_size=`expr $ps_credit - $ps_size`
  746. X#        ..update the pathsize database. Ugly 'ed' script!
  747. X        ed - pathsize >/dev/null <<OoPs
  748. X            /$ps_path.*$ps_credit/
  749. X            s/\(.*\) \(.*\)/\1 $ps_size/
  750. X            w
  751. X            q
  752. XOoPs
  753. X#        All done; get back!
  754. X        return
  755. X     }
  756. Xdone
  757. X# This path does not exist inside our pathsize database. Uhm..
  758. X# If CREDIT is defined, we add the new path to our database. We assume
  759. X# that CREDIT is not '0': a previous check on this value would have
  760. X# rejected any request and we wouldn't be here. So either 'credit' has
  761. X# a value different from zero, or it is not defined at all. Trust me!
  762. Xtest -n "$CREDIT" && {
  763. X    ps_size=`expr $CREDIT - $ps_size`
  764. X    echo "$ps_origin $ps_size" >>$PATHSIZE
  765. X    }
  766. X}
  767. X
  768. XBill() {
  769. X
  770. Xif [ "$credit" != "UNLIMITED" ]; then
  771. X
  772. X# bill destination of $1 lenght
  773. X    ( set `ls -log $1 | Cut_Ls`
  774. X    Add_PathSize $UUCP_SENDER $1
  775. X    )
  776. Xfi
  777. X}
  778. X
  779. X
  780. X#
  781. X# RNA 2.0 MESSAGES - Warning: change at your own risk!
  782. X#
  783. X
  784. XHeaders_Msg()
  785. X{
  786. X# DON'T CHANGE the 'X-Mailer' line by *any means. Future versions of
  787. X# RNA will talk to each other (sort-of networking!) and will need
  788. X# to know exactly which version is on the other side.
  789. Xspedresult=`Reference_Cmd`
  790. Xecho "\
  791. XX-Mailer: RNALIB 2.0 [Rev.A]\n\
  792. XX-Sender: $ARPA_SENDER\n\
  793. XSubject: RNA answer: $spedresult"
  794. X
  795. Xtest -s $RNADIR/notice && cat $RNADIR/notice 
  796. X}
  797. X
  798. XNoHuman_Msg()
  799. X{
  800. Xecho "\
  801. XThis message has been generated by a program. To talk to a human,\n\
  802. Xsend mail to $POSTMASTER. Special requests of details on\n\
  803. XRNA delivers may be submitted to this address only."
  804. X}
  805. X
  806. XExample_Msg()
  807. X{
  808. Xecho "\
  809. XHere are some example requests, in case syntax is the problem:\n\
  810. X\n\
  811. X    @@ help\n\
  812. X    @@ index\n\
  813. X    @@ index {library}\n\
  814. X    @@ list {library}\n\
  815. X    @@ find {filename}\n\
  816. X    @@ credits\n\
  817. X    @@ send {file} from {library}\n\
  818. X    @@ send {file} from {library} with {compress-uuencode}\n\
  819. X    @@ send {file} from {library} with {btoa} via {uucp}\n\
  820. X    @@ send {file} from {library} with {uuencode} via {uusend}\n\
  821. Xetc.etc."
  822. X}
  823. X
  824. XNeedHelp_Msg()
  825. X{
  826. Xecho "\
  827. XIf you need help on RNA commands syntax, a doc file is available\n\
  828. Xhere. You might get it by mailing  $LOGNAME@$UNAME , with either\n\
  829. Xmessage body or Subject containing:  @@ help."
  830. X}
  831. X
  832. XNoFile_Msg()
  833. X# $1=LIBRARY  $2=FILE-NAME
  834. X{
  835. Xif [ "$1" != "DEFAULT" ]; then 
  836. X    echo "\n\
  837. XSorry, no such file was found. Recheck library contents.\n\
  838. XTo do that, use the RNAlib command:   @@ list $1\n\
  839. XFor a verbose description of files use:   @@ index $1" 
  840. Xelse
  841. X    echo "\
  842. XSorry no such file was found inside RNALIB system directory.\n\
  843. XPlease recheck library contents with :   @@ list\n\
  844. XFor a list of available libraries and description of \n\
  845. Xavailable system files try: @@ index " 
  846. Xfi
  847. Xecho "\n\
  848. XYou may also scan the whole library system looking for a particular\n\
  849. Xfile-name or part of it; use: @@ find {chars}. Example: @@ find doc\n\
  850. Xwould list all available files whose names contain \"doc\". \n\
  851. XIf you insist on this file-name, then try: @@ find $2  \n\
  852. XIf all of this doesn't explain the problem, send a complaint\n\
  853. Xto postmaster here: $POSTMASTER"
  854. X}
  855. X
  856. XNoLibrary_Msg()
  857. X{
  858. Xecho "\
  859. XSorry, this library does not exist! Recheck the general index.\n\
  860. XTo do that, try the RNA command: @@ index \n\
  861. XIf that doesn't explain the problem, send a complaint\n\
  862. Xto: $POSTMASTER"
  863. X}
  864. X
  865. XCantAccess_Msg()
  866. X{
  867. Xecho "\
  868. XSorry, i could not read \"$argument\" inside selected library : \n\
  869. Xthere might be local problems with fileystem permissions here.\n\
  870. XTry contacting the postmaster for some explanations."
  871. X}
  872. X
  873. XYourMail_Msg()
  874. X{
  875. Xecho "\nYour mail, as received here, was...\n\
  876. X--------------------------------------------"
  877. Xcat -v $MBOX_CUT
  878. Xecho "\n--------------------------------------------"
  879. X}
  880. X
  881. XSyntax_Msg()
  882. X{
  883. Xecho "\
  884. XSorry, the RNAlib program could not understand your request.\n"
  885. XNeedHelp_Msg
  886. Xecho; Example_Msg; echo; YourMail_Msg
  887. X}
  888. X
  889. XBadChars_Msg()
  890. X{
  891. Xecho "\
  892. XYour request included shell magic characters inside $1 command line(s).\n\
  893. XSuch characters like \*, | , / , dots etc. are PROHIBITED for security\n\
  894. Xreasons: the whole message has been discarded for this reason."
  895. X}
  896. X
  897. XNoCommands_Msg()
  898. X{
  899. Xecho "\
  900. XRNAlib could not find any command-lines inside your mail-request.\n"
  901. XNeedHelp_Msg
  902. Xecho; Example_Msg; echo; YourMail_Msg
  903. X}
  904. X
  905. XNoTo_Msg()
  906. X{
  907. Xecho "\
  908. XSorry, you are not authorized to use the \"TO\" field inside RNA requests.\n\
  909. XSpecial permissions should be submitted to $POSTMASTER, along with\n\
  910. Xsome good reasons for such capability."
  911. X}
  912. X
  913. XBlackListed_Msg()
  914. X{
  915. Xecho "\
  916. XSorry, you cannot forward RNALIB-requests here: your site is off-limits.\n\
  917. XThere's also a chance that your site is placed on a blacklisted path,\n\
  918. Xand though rejected;  it could also be that your address and/or name\n\
  919. Xjust looks exactly as a blacklisted one."
  920. X}
  921. X
  922. XDeliver_Msg()
  923. X{
  924. Xecho "\
  925. XThis is the RNALIB output for a request destinated to you.\n\
  926. XEnquiry was sent on $REQUEST_DATE  by <$ARPA_SENDER>."
  927. X}
  928. X
  929. X
  930. XReference_Cmd()
  931. X{
  932. Xtest -z "$action" && echo "problems." && exit
  933. Xecho "\"$action\c"
  934. Xtest "$argument" != "DEFAULT" && echo " $argument\c"
  935. Xtest "$from" != "DEFAULT" && echo " [from] $from\c"
  936. Xtest "$destination" != "DEFAULT" && echo " [to] $destination\c"
  937. Xtest "$with" != "DEFAULT" && echo " [with] $with\c"
  938. Xtest "$via" != "DEFAULT" && echo " [via] $via\c"
  939. Xecho "\"\n"
  940. X}    
  941. X
  942. XReference_Msg()
  943. X{
  944. Xecho "Command referenced: `Reference_Cmd`" 
  945. X}
  946. X
  947. XConvert_Msg()
  948. X{
  949. Xecho "\
  950. XThis file appears to be a $ftype:\n\
  951. Xit has been transformed into an ASCII-format using \"$encode_type\".\n\
  952. X"
  953. X}
  954. X
  955. XNoNeed_Msg()
  956. X{
  957. Xecho "\
  958. XField \"with\" ignored: file is already ASCII-text."
  959. X}
  960. X
  961. XNoSuffix_Msg()
  962. X{
  963. Xecho "\
  964. XWARNING: requested file \"$fname\"\n\
  965. X         has NOT been compressed since its longer than \"$MAXLENGHT\"\n\
  966. X         characters permitted by \"$COMPRESS\". The problem has been\n\
  967. X         notified to $POSTMASTER here. Sorry for the inconvenience.\n\
  968. X"
  969. X}
  970. X
  971. XNoConv_Msg()
  972. X{
  973. Xecho "\
  974. XField \"with\" ignored: file hasn't been converted since\n\
  975. Xit comes via \"$via\".\n\
  976. X"
  977. X}
  978. X
  979. XCompr_Msg()
  980. X{
  981. Xecho "\
  982. XThis file has been converted with utility \"$COMPRESS\"\n\
  983. XYou need to convert it back with something like \"uncompress\"\n\
  984. Xor \"compress -d\".\n\
  985. X"
  986. X}
  987. X
  988. XShip_Msg()
  989. X{
  990. Xecho "\
  991. XFile requested for \"$ARPA_SENDER\" and destinated to \"$UUCP_HOST\"\n\
  992. Xis coming inside your system public directory via \"$via\".\n\
  993. XCheck it out! It should already be there.\n\
  994. X"
  995. X}
  996. X
  997. XNoCompr_Msg()
  998. X{
  999. Xecho "\
  1000. XWARNING: \"compress\" is not available here!\n\
  1001. XYour file has been sent without any compression. Sorry.\n\
  1002. X"
  1003. X}
  1004. X
  1005. XAlready_Msg()
  1006. X{
  1007. Xecho "\n\
  1008. XThis file hasn't been compressed since it ALREADY was compressed!\n\
  1009. XAny file whose name terminates with a \".Z\" is compressed: take care!\n\
  1010. XYou can get a list of file names inside a specific library\n\
  1011. Xwith RNA command \"list library\".\n\
  1012. X"
  1013. X}
  1014. X
  1015. XViaError_Msg()
  1016. X{
  1017. Xecho "\
  1018. XWarning! Field \"with\" ignored: <$with> is not a valid identifier.\n\
  1019. XThis file has been sent via normal \"e-mail\".\n\
  1020. X"
  1021. X}
  1022. X
  1023. XPending_Msg() {
  1024. Xecho "\
  1025. XX-Mailer: RNALIB 2.0 [Rev.A]\n\
  1026. XSubject: RNA is out of service on $UNAME\n\n\
  1027. XHello. RNALIB on $UNAME is temporarily out of service.\n\
  1028. XYour request of $REQUEST_DATE has been queued and will be processed\n\
  1029. Xas soon as the service is resumed.\n\n\
  1030. X`cat $RNADIR/hold`\n\n
  1031. X`Signature`"
  1032. X}
  1033. X
  1034. XWithError_Msg()
  1035. X{
  1036. Xecho "\
  1037. XWarning! Field \"with\" ignored: <$with> is not a valid identifier.\n\
  1038. XThis file has been transformed into an ASCII-format using \"uuencode\"."
  1039. X}
  1040. X
  1041. XNoBtoa_Msg()
  1042. X{
  1043. Xecho "\n\
  1044. XWARNING: \"btoa\" translation is not available here!\n\
  1045. XPlease re-submit your request without further \"with\" field;\n\
  1046. Xnon-ascii files will be treated with \"uuencode\"."
  1047. X}
  1048. X
  1049. XSignature()
  1050. X{
  1051. Xecho "\n\
  1052. X--\n\
  1053. X|RNALIB|SERVER|  | running at: \"$UNAME\"\n\
  1054. X|rnalib|server|  | postmaster: $POSTMASTER"
  1055. X}
  1056. X
  1057. XNoCredit_Msg() {
  1058. X    echo "\
  1059. XX-Mailer: RNALIB 2.0 [Rev.A]\n\
  1060. XSubject: your path is out of RNA credits\n\n\
  1061. XThe mail path you are coming from has exceeded its transmission's limits.\n\
  1062. XIn order to keep network trafic under control, we fix a credit size for\n\
  1063. Xcertain paths: currently your site results to be out of credits.\n\
  1064. XYou may ask $POSTMASTER for a credit reset; until then, all\n\
  1065. Xrnalib queries from your path are ignored.\n\
  1066. XYou may in the future ask rnalib which is the current credit size which\n\
  1067. Xapplies to your path, using: \"@@ credits\".\n"
  1068. XYourMail_Msg
  1069. XNoHuman_Msg
  1070. XSignature    
  1071. X}
  1072. X
  1073. XSubScribe_Msg() {
  1074. X    echo "\
  1075. XX-Mailer: RNALIB 2.0 [Rev.A]\n\
  1076. XSubject: Please subscribe for rnalib service\n\n\
  1077. XHello.\n\
  1078. XRNALIB service here on $UNAME requires a subscription to the \n\
  1079. Xauthorized user's list.\n\
  1080. XPlease mail $POSTMASTER asking for registration before any further query.\n\
  1081. X        Thank You\n"
  1082. XYourMail_Msg
  1083. XNoHuman_Msg
  1084. XSignature
  1085. X}
  1086. X
  1087. X# End of messages- 
  1088. X
  1089. Xparse() {
  1090. Xecho "\n`date '+%d.%m.%y - %H:%M:%S'`" >>$LOGFILE
  1091. Xtest $DEBUG && echo "Parsing message.."
  1092. X# Watch out for rejected mails! Don't waste time..
  1093. X
  1094. Xrejected=""; grep "X-Mailer: RNALIB" $MBOX_CUT >/dev/null && rejected=1; 
  1095. Xif [ "$rejected" = "1" ]; then
  1096. X    test $DEBUG && echo "Skip this mail: it was rejected from remote"
  1097. X    echo "\n`cat $MBOX_CUT`" >>$REJECTED
  1098. X
  1099. X    echo "Priority: all\nSubject: RNA delivery rejected\n\n\
  1100. XAn RNA delivery was rejected from remote. A copy of the following\n\
  1101. Xdiagnostic has been archived inside $REJECTED as usual.\n\
  1102. XHere comes the stuff i received....\n\n\
  1103. X`cat $MBOX_CUT`\n\n   Your friendly RNALIB DAEMON" | $MAILER $POSTMASTER
  1104. X
  1105. X    return
  1106. Xfi
  1107. X
  1108. X# get the first From path for a (un)trustable bang-reply ;-)
  1109. Xset `head -1 $MBOX_CUT`; UUCP_SENDER=$2
  1110. Xecho "Request received from: $UUCP_SENDER" >>$LOGFILE
  1111. X# get the ARPA address of the sender. A real hack upon rfc822..
  1112. Xset `wc -l $MBOX_CUT`; end=$1; rline=2
  1113. Xuntil [ "$rline" = "$end" ]
  1114. Xdo
  1115. X    rrline=`sed -n "$rline l" $MBOX_CUT`
  1116. X    test -z "$rrline" && rline=$end && break
  1117. X    set -f $rrline
  1118. X    if [ "$1" = "From:" ]; then
  1119. X#        Here we are, trying to fit the (in)famous rfc822.
  1120. X#        Rule of dumb: if only one field, it's it.    
  1121. X        if [ "$#" = "2" ]; then
  1122. X            ARPA_SENDER=$2
  1123. X#            Retry: if one of the fields contains "<>", it's it.
  1124. X#            We just check for the open '<'; we won't consider
  1125. X#            drunk mailers. We also assume that <address> is the
  1126. X#            last field on the line.
  1127. X        elif [ "`echo $@ | grep '<'" != "" ]; then 
  1128. X            IFSorg=$IFS; IFS="<>"    
  1129. X            set $@; ARPA_SENDER=$2;
  1130. X        elif [ "`echo $@ | grep '('" != "" ]; then 
  1131. X#            Back on: if one of the fields contains "()", the other 
  1132. X#            is the good one. We assume that (Full Name) is the last
  1133. X#            field on the line.
  1134. X            IFSorg=$IFS; IFS="( )"
  1135. X            set $@; ARPA_SENDER=$2
  1136. X        fi
  1137. X#        If this is not enough, you'll have to find out yourself
  1138. X#        the way to get arpa-addresses on your site. Send a copy of
  1139. X#        the object header to me, so that i'll add that
  1140. X#        specification for the next rna release.
  1141. X        IFS=$IFSorg
  1142. X    fi    
  1143. X    test "$1" = "Date:" && REQUEST_DATE="$2 $3 $4"    
  1144. X    rline=`expr $rline + 1`
  1145. Xdone    
  1146. Xtest -z "$ARPA_SENDER" && ARPA_SENDER=$UUCP_SENDER
  1147. Xtest -z "$REQUEST_DATE" && REQUEST_DATE="(unknown date)"
  1148. X
  1149. Xtest $DEBUG && echo "UUCP incoming address: $UUCP_SENDER"
  1150. Xtest $DEBUG && echo "ARPA incoming address: $ARPA_SENDER"
  1151. Xtest $DEBUG && echo "date of original mail: $REQUEST_DATE"
  1152. X
  1153. X# Now we know everything we need about our incoming message.
  1154. X# Let's see if the rna service is on hold for some reason...
  1155. Xtest -r $RNADIR/hold && {
  1156. X# ..yep. We touch and fill 'pending'. An empty 'pending' should *never
  1157. X# exist. Rna at startup would claim there are pending jobs.
  1158. X    touch $RNADIR/pending; echo "`cat $MBOX_CUT`\n" >>$RNADIR/pending
  1159. X    Pending_Msg | $MAILER $UUCP_SENDER
  1160. X    return
  1161. X}
  1162. X
  1163. X
  1164. X# get command lines from the message (if any)
  1165. Xgrep '@@' $MBOX_CUT >$CMDS
  1166. X
  1167. X# Some pre-parsing for naughty characters.. If security problems are
  1168. X# detected inside command lines belonging to the same message, the WHOLE
  1169. X# message is rejected. We never know what these hackers can try nowadays ;-)
  1170. X# BEWARE: what we do is searching with egrep for these characters:
  1171. X#        * | ? " . /  '
  1172. X# I gave up trying to grep also:   `  and \  (egrep gives errors).
  1173. X# Using these characters, though, gives no results from the "hacker's point
  1174. X# of view". So the stuff should be quite secure right now.
  1175. X# %%FIX%%
  1176. X# We use 'egrep' here. If you don't have a 'egrep' try using the normal
  1177. X# 'grep' with some hacks. The aim is to fit the 'if' condition whenever
  1178. X# magic characters are detected inside command lines.
  1179. X# If you can't come to anything working, then replace the following line
  1180. X# with 'error=0' and watch out for enemies on the net!
  1181. Xerror=`egrep -c "\*|\||\?|\"|/|\'" $CMDS`
  1182. Xif [ "$error" != "0" ]; then
  1183. X    test $DEBUG && echo "WARNING: security problems, mail rejected"
  1184. X    echo "SECURITY problems with $ARPA_SENDER" >>$LOGFILE
  1185. X    BadChars_Msg $error >$ERRSTAT
  1186. X#    We need this so the interpreter will stop arguing about external dest.
  1187. X    destination=DEFAULT
  1188. X    return
  1189. Xfi
  1190. X
  1191. Xif test -s $CMDS; then
  1192. X    set `wc -l $CMDS`; cmds=$1
  1193. X    test $DEBUG && echo "this message contains $cmds command line(s)"
  1194. X    echo "Found $cmds command line(s)" >>$LOGFILE
  1195. X    strings="`cat $CMDS`"
  1196. X    set -f $strings
  1197. X#
  1198. X# This is the MAIN PARSE loop
  1199. X#
  1200. Xerror=0; position=0; action=""; argument=""; destination="DEFAULT"; from="";
  1201. Xwith=""; via=""
  1202. X#
  1203. Xwhile [ "$1" != "" ]
  1204. Xdo
  1205. X    case $1 in
  1206. X        @@) 
  1207. X        test $DEBUG && echo "restart of command line"
  1208. X        if test $position -gt 0
  1209. X        then
  1210. X            echo $action $argument $from $destination $with $via >>$CMDLOG
  1211. X        fi
  1212. X        action=""; argument=""; from="DEFAULT"; destination="DEFAULT"
  1213. X        with="DEFAULT"; via="DEFAULT"; position=0
  1214. X        shift;;
  1215. X
  1216. X        [sS][eE][nN][dD])
  1217. X            test $DEBUG && echo "found \"send\""
  1218. X            if test $position -eq 0
  1219. X            then
  1220. X                action=send
  1221. X                shift
  1222. X                if test -z "$1"
  1223. X                then
  1224. X                    argument="DEFAULT"
  1225. X                    position=1
  1226. X                else
  1227. X                    if [ "$1" = "@@" ]; then
  1228. X                        argument="DEFAULT"
  1229. X                        position=1
  1230. X                    else
  1231. X                        argument=$1; position=1
  1232. X                        shift
  1233. X                    fi
  1234. X                fi    
  1235. X            fi;;
  1236. X                        
  1237. X
  1238. X        [lL][iI][sS][tT])
  1239. X            test $DEBUG && echo "found \"list\""
  1240. X            if test $position -eq 0
  1241. X            then
  1242. X                action=list
  1243. X                shift
  1244. X                if test -z "$1"
  1245. X                then
  1246. X                    argument="DEFAULT"
  1247. X                    position=1
  1248. X                else
  1249. X                    if [ "$1" = "@@" ]; then
  1250. X                        argument="DEFAULT"
  1251. X                        position=1
  1252. X                    else
  1253. X                        argument=$1; position=1
  1254. X                        shift
  1255. X                    fi
  1256. X                fi    
  1257. X            fi;;
  1258. X                        
  1259. X
  1260. X        [iI][nN][dD][eE][xX])
  1261. X            test $DEBUG && echo "found \"index\""
  1262. X            if test $position -eq 0
  1263. X            then
  1264. X                action=index
  1265. X                shift
  1266. X                if test -z "$1"
  1267. X                then
  1268. X                    argument="DEFAULT"
  1269. X                    position=1
  1270. X                else
  1271. X                    if [ "$1" = "@@" ]; then
  1272. X                        argument="DEFAULT"
  1273. X                        position=1
  1274. X                    else
  1275. X                        argument=$1; position=1
  1276. X                        shift
  1277. X                    fi
  1278. X                fi    
  1279. X            fi;;
  1280. X
  1281. X        [fF][iI][nN][dD])
  1282. X            test $DEBUG && echo "found \"find\""
  1283. X            if test $position -eq 0
  1284. X            then
  1285. X                action=find
  1286. X                shift
  1287. X                if test -z "$1"
  1288. X                then
  1289. X                    argument="DEFAULT"
  1290. X                    position=1
  1291. X                else
  1292. X                    if [ "$1" = "@@" ]; then
  1293. X                        argument="DEFAULT"
  1294. X                        position=1
  1295. X                    else
  1296. X                        argument=$1; position=1
  1297. X                        shift
  1298. X                    fi
  1299. X                fi    
  1300. X            fi;;
  1301. X
  1302. X        [hH][eE][lL][pP]|hilfe|HILFE|aiuto|AIUTO|aled|ALED)
  1303. X            test $DEBUG && echo "found \"help\""
  1304. X            if test $position -eq 0
  1305. X            then
  1306. X                action=help
  1307. X                shift
  1308. X                if test -z "$1"
  1309. X                then
  1310. X                    argument="DEFAULT"
  1311. X                    position=1
  1312. X                else
  1313. X                    if [ "$1" = "@@" ]; then
  1314. X                        argument="DEFAULT"
  1315. X                        position=1
  1316. X                    else
  1317. X                        argument=$1; position=1
  1318. X                        shift
  1319. X                    fi
  1320. X                fi    
  1321. X            fi;;
  1322. X
  1323. X        [cC]redits|[cC]redit)
  1324. X            test $DEBUG && echo "found \"credits\""
  1325. X            if test $position -eq 0
  1326. X            then
  1327. X                action=credits
  1328. X                shift
  1329. X                if test -z "$1"
  1330. X                then
  1331. X                    argument="DEFAULT"
  1332. X                    position=1
  1333. X                else
  1334. X                    if [ "$1" = "@@" ]; then
  1335. X                        argument="DEFAULT"
  1336. X                        position=1
  1337. X                    else
  1338. X                        argument=$1; position=1
  1339. X                        shift
  1340. X                    fi
  1341. X                fi    
  1342. X            fi;;
  1343. X                        
  1344. X
  1345. X        [fF][rR][oO][mM]|inside|[iI][nN])
  1346. X            test $DEBUG && echo "found \"from\""
  1347. X            shift
  1348. X            if test "$1"
  1349. X            then
  1350. X                test "$1" != "@@" && from=$1 && shift
  1351. X            fi;;
  1352. X            
  1353. X
  1354. X        to|To:)    
  1355. X            test $DEBUG && echo "found \"to\""
  1356. X            shift
  1357. X            if test "$1"
  1358. X            then
  1359. X                test "$1" != "@@" && destination=$1 && shift
  1360. X            fi;;
  1361. X
  1362. X        with|With|using|USING)    
  1363. X            test $DEBUG && echo "found \"with\""
  1364. X            shift
  1365. X            if test "$1"
  1366. X            then
  1367. X                test "$1" != "@@" && with=$1 && shift
  1368. X            fi;;
  1369. X
  1370. X        [vV][iI][aA]|over|OVER|through|THROUGH)    
  1371. X            test $DEBUG && echo "found \"via\""
  1372. X            shift
  1373. X            if test "$1"
  1374. X            then
  1375. X                test "$1" != "@@" && via=$1 && shift
  1376. X            fi;;
  1377. X
  1378. X#        These words are skipped if found before a @@ or after
  1379. X#        a valid argument shift. 
  1380. X        *[Pp]lease*|hello|do|[Ss]ubject:|[Aa]ction:)
  1381. X            test $DEBUG &&    echo "junk \"$1\" skipped"
  1382. X            shift;;
  1383. X
  1384. X        *)
  1385. X            test $DEBUG &&    echo "unknown command: \"$1\""
  1386. X            echo "\nParser error: unknown command \"$1\"" >>$ERRSTAT
  1387. X            error=1
  1388. X            ;;
  1389. X    esac            
  1390. X
  1391. X    if test $error -gt 0
  1392. X    then
  1393. X        test $DEBUG && echo "looking for a new command line"
  1394. X        while [ "$1" != "@@" ]
  1395. X        do
  1396. X            test -z "$1" && test $DEBUG && echo "no more command lines in this message"
  1397. X            test -z "$1" && break
  1398. X            shift
  1399. X        done
  1400. X        error=0; position=0
  1401. X        test $DEBUG &&    echo "found a new command line"
  1402. X    fi
  1403. X
  1404. X
  1405. X# end while
  1406. Xdone
  1407. X
  1408. Xif test $position -gt 0
  1409. Xthen
  1410. X    echo $action $argument $from $destination $with $via>>$CMDLOG
  1411. Xfi
  1412. X        
  1413. X# these three lines refer to the test $CMDS at the beginning of parse()
  1414. X
  1415. Xelse  
  1416. Xdestination=DEFAULT
  1417. Xtest $DEBUG && echo "this message does not contain any command line"
  1418. Xfi
  1419. X
  1420. X}    
  1421. X
  1422. Xinterp() {
  1423. X
  1424. X# If pathsizing is activated, look for credits.. 
  1425. Xtest -n "$PATHSIZE" && {
  1426. X    if [ "$STRINGS" != "" ]; then 
  1427. X    $STRINGS $PATHSIZE > $TMPDIR/pathstr
  1428. X    cat $TMPDIR/pathstr > $PATHSIZE
  1429. X    fi
  1430. X    if [ "$destination" != "DEFAULT" ]; then
  1431. X    UUCP_DESTIN=$destination
  1432. X    credit="`Check_PathSize $UUCP_DESTIN`"
  1433. X    else
  1434. X    credit="`Check_PathSize $UUCP_SENDER`"
  1435. X    fi
  1436. X    if [ "$credit" = "UNLIMITED" ]; then
  1437. X    test $DEBUG && echo "Your path: has no limits!"
  1438. X    echo "Your path: has no limits!" >> $LOGFILE
  1439. X    else
  1440. X    if [ "$credit" = "" ]; then
  1441. X#        Unknown path inside pathsize:
  1442. X        if [ "$CREDIT" = "0" ]; then
  1443. X#            New paths need to subscribe!
  1444. X            test $DEBUG && echo "New path: needs to subscribe!"
  1445. X            echo "New path: needs to subscribe!" >> $LOGFILE
  1446. X            SubScribe_Msg | $MAILER $UUCP_SENDER
  1447. X            rejected=1
  1448. X        fi
  1449. X    elif [ "$credit" -le "0" ]; then
  1450. X        rejected=1
  1451. X        echo "No more credits for this account" >> $LOGFILE
  1452. X        NoCredit_Msg | $MAILER $UUCP_SENDER
  1453. X    fi
  1454. X    fi
  1455. X}
  1456. X
  1457. Xtest $DEBUG && echo "Interpreter: \c"
  1458. X
  1459. Xif [ "$rejected" = "1" ]; then
  1460. X    test $DEBUG && echo "Remote rejected or no-credits path: skipping."
  1461. X    echo "Message from $ARPA_SENDER discarded" >>$LOGFILE
  1462. X    return;
  1463. Xfi
  1464. X
  1465. Xtest -s $RNADIR/hold && {
  1466. X    test $DEBUG && echo "holding message as pending job"
  1467. X    echo "Holding message from $ARPA_SENDER" >>$LOGFILE
  1468. X    return;
  1469. X}
  1470. X
  1471. X# First we check if the sender is blacklisted. 
  1472. Xif [ "`BlackList`" != "" ]; then
  1473. X    test $DEBUG && echo "origin is blacklisted!\nDiagnostic: `BlackList`"
  1474. X    echo "Origin is Blacklisted: $ARPA_SENDER" >>$LOGFILE
  1475. X    Headers_Msg >>$OUTFILE
  1476. X    Deliver_Msg >>$OUTFILE
  1477. X    echo "\nWARNING, BLACKLIST PROBLEMS!\n`BlackList`\n" >>$OUTFILE
  1478. X    BlackListed_Msg >>$OUTFILE
  1479. X    YourMail_Msg >>$OUTFILE
  1480. X    NoHuman_Msg >>$OUTFILE
  1481. X    Mail_File
  1482. X#    I'm done with this message; next one, please..
  1483. X    return
  1484. Xfi
  1485. X
  1486. X# Then we check if the sender used "to" field with authorization
  1487. Xif [ "$destination" != "DEFAULT" ]; then
  1488. X    test $DEBUG && echo "external destination for <$destination>\nChecking for privileges...\c"
  1489. X    if test -z "`ToCheck`"; then
  1490. X        test $DEBUG && echo "NO privileges. Request denied!"
  1491. X        echo "External request denied: $ARPA_SENDER" >>$LOGFILE
  1492. X        Headers_Msg >>$OUTFILE
  1493. X        Deliver_Msg >>$OUTFILE
  1494. X        echo "\nWARNING: no privilege for external destinations\n" >>$OUTFILE
  1495. X        NoTo_Msg >>$OUTFILE
  1496. X        YourMail_Msg >>$OUTFILE
  1497. X        NoHuman_Msg >>$OUTFILE
  1498. X        Mail_File
  1499. X#        I'm done with this message; next one, please..
  1500. X        return
  1501. X    fi
  1502. Xtest $DEBUG && echo "OK, origin is authorized!\nDiagnostic: `ToCheck`"
  1503. Xecho "External Request OK: $ARPA_SENDER" >>$LOGFILE
  1504. Xfi
  1505. X
  1506. X# And now we check if the parser reported errors..
  1507. Xif test -s $ERRSTAT; then
  1508. X    test $DEBUG && echo "errors were detected by the parser.\nNotify origin and skip this message."
  1509. X    echo "Parser rejects: $ARPA_SENDER" >>$LOGFILE
  1510. X    Headers_Msg >>$OUTFILE
  1511. X    Deliver_Msg >>$OUTFILE
  1512. X    cat $ERRSTAT >>$OUTFILE
  1513. X    Syntax_Msg >>$OUTFILE
  1514. X    NoHuman_Msg >>$OUTFILE
  1515. X    Mail_File
  1516. X#    I'm done with this message; next one, please..
  1517. X    return
  1518. Xfi
  1519. X
  1520. X# Work for us?
  1521. Xif test -s $CMDLOG; then
  1522. X    set `wc -l $CMDLOG`; cmds=$1
  1523. X    test $DEBUG && echo "working on $cmds valid request(s)"
  1524. X    echo "Found $cmds valid request(s)" >>$LOGFILE
  1525. X# following two lines are very important
  1526. Xstrings="`cat $CMDLOG`"
  1527. Xset -f $strings
  1528. Xaction=""; argument=""; destination=""; via=""; with=""; tok=""
  1529. X#
  1530. X# * INTERPRETER LOOP *
  1531. X# we parse standard 6-fields command lines whose fields are
  1532. X# <action> <argument> <from-lib> <destination> <with> <via>
  1533. X# 
  1534. Xwhile [ "$1" != "" ]
  1535. Xdo
  1536. X
  1537. Xaction=$1; shift; argument=$1; shift; from=$1; shift; destination=$1
  1538. Xshift; with=$1; shift; via=$1
  1539. X
  1540. Xrm -f $OUTFILE 2>/dev/null
  1541. X# the following bracket starts the restricted environment of the interpreter:
  1542. X# since we are using a streamed handling of a "cat", we *need to be sure that
  1543. X# no procedure is executed within the same environment; so status variables
  1544. X# won't change and RNA won't loose control of its job. Basically, the main
  1545. X# effect of such lack is a message like "RNA: cannot shift" . Which takes
  1546. X# RNA to forget about any command line - and any subsequent mail - aside the
  1547. X# very first one of the very first income mail. 
  1548. X(
  1549. Xtest $DEBUG && Reference_Msg
  1550. XHeaders_Msg >$OUTFILE 
  1551. X
  1552. Xcase $action in
  1553. X
  1554. Xsend)    
  1555. X    Deliver_Msg >>$OUTFILE
  1556. X    if [ "$argument" = "DEFAULT" ]; then
  1557. X        test $DEBUG && echo "Missing argument for \"send\""
  1558. X        echo "\nERROR: command \"send\" requires an argument!\n" >>$OUTFILE
  1559. X        Syntax_Msg >>$OUTFILE
  1560. X        NoHuman_Msg >>$OUTFILE
  1561. X        Mail_File
  1562. X#        I'm done with this message; next one, please..
  1563. X        return
  1564. X    fi
  1565. X    Reference_Msg >>$OUTFILE
  1566. X#    Let's see if library and file do really exist
  1567. X    fname=""; fname="`GetFile $argument $from`" 
  1568. X    if [ "$fname" != "" ]; then
  1569. X
  1570. X#    If we are here, file/lib exists , "to" is ok
  1571. X#    (if there's one), so we may try to ship the stuff.
  1572. X#       We need to know HOW, first!
  1573. X
  1574. X# Check the field "via". Sorry for the bad indentation. We all need
  1575. X# 160 columns monitors nowadays ;-)
  1576. X
  1577. Xcase $via in
  1578. X
  1579. Xuusend|UUSEND|Uusend)
  1580. X    With_Type
  1581. X    viasped="NO_MAIL"
  1582. X    Convert_File
  1583. X    Cut_Address
  1584. X    Ship_Msg >> $OUTFILE
  1585. X    test $DEBUG && echo "Now sending file with uusend to :$UUCP_HOST"
  1586. X    echo "File sent: $argument via $via to: $UUCP_SENDER">>$LOGFILE
  1587. X# if you don't want to 'bill' uusend shippings, comment next line
  1588. X    test -n "$PATHSIZE" && Bill $fname
  1589. X    $UUSEND -r -f -m 666 $fname $UUCP_HOST$PUBDIR"/"$argument ;; 
  1590. X
  1591. Xuucp|UUCP|Uucp)
  1592. X    With_Type
  1593. X    viasped="NO_MAIL"
  1594. X    Convert_File
  1595. X    Cut_Address
  1596. X    Ship_Msg >> $OUTFILE
  1597. X    test $DEBUG && echo "Now send file using uucp to :$UUCP_HOST"
  1598. X    echo "File sent: $argument via $via to: $UUCP_SENDER">>$LOGFILE
  1599. X# if you don't want to 'bill' uucp shippings, comment next line
  1600. X    test -n "$PATHSIZE" && Bill $fname
  1601. X    $UUCP -r -C $fname $UUCP_HOST$PUBDIR"/"$argument ;;
  1602. X
  1603. XDEFAULT|default|mail|\
  1604. XMAIL|Mail|email|EMAIL|E-Mail|\
  1605. Xe-mail|E-MAIL)
  1606. X    test $DEBUG && echo "Now send file using e-mail to :$UUCP_SENDER"
  1607. X    With_Type
  1608. X    viasped=""
  1609. X    Convert_File 
  1610. X    echo "File sent: $argument via $via to: $UUCP_SENDER">>$LOGFILE
  1611. X    ;;
  1612. X
  1613. X*)
  1614. X    via="DEFAULT"
  1615. X    With_Type
  1616. X    viasped=""
  1617. X    Convert_File
  1618. X    ViaError_Msg >> $OUTFILE
  1619. X    test $DEBUG && echo "Now send file using e-mail to :$UUCP_SENDER"
  1620. X    echo "File sent: $argument via $via to: $UUCP_SENDER">>$LOGFILE
  1621. X    
  1622. Xesac
  1623. X
  1624. X
  1625. X    else
  1626. X#    Something wrong with object file, Scotland Yards investigates..
  1627. X        if [ "`GetDir $from`" = "" ]; then 
  1628. X            test $DEBUG && echo "Nonexistent library: \"$from\""
  1629. X            echo "NO library found: $from" >>$LOGFILE
  1630. X            NoLibrary_Msg >>$OUTFILE 
  1631. X        elif [ "`GetFile $argument $from`" = "" ]; then
  1632. X            test $DEBUG && echo "Nonexistent file: \"$argument\" inside library \"$from\""
  1633. X            echo "NO file found: $argument" >>$LOGFILE
  1634. X            NoFile_Msg $from $argument >>$OUTFILE
  1635. X        else
  1636. X            CantAccess_Msg >>$OUTFILE
  1637. X            echo "CANT ACCESS $argument from $from" >>$LOGFILE
  1638. X            test $DEBUG && echo "WARNING: cannot open \"`GetFile $argument $from`\""
  1639. X        fi
  1640. X    fi
  1641. X    Mail_File ;; 
  1642. X        
  1643. Xlist)    Deliver_Msg >>$OUTFILE
  1644. X    Reference_Msg >>$OUTFILE
  1645. X    ListLib $argument >>$OUTFILE
  1646. X    echo "\nPLEASE use command \"index\" to get more details\n\
  1647. X           on library: $argument">>$OUTFILE
  1648. X    echo "Command executed: list $argument : $ARPA_SENDER" >>$LOGFILE
  1649. X    Mail_File ;;
  1650. X
  1651. Xindex)    Deliver_Msg >>$OUTFILE
  1652. X    Reference_Msg >>$OUTFILE
  1653. X    GetCat $argument >>$OUTFILE
  1654. X    ListLib $argument >>$OUTFILE
  1655. X    echo "Command executed: index and list $argument : $ARPA_SENDER" >>$LOGFILE
  1656. X    Mail_File ;;
  1657. X
  1658. Xcredits) Deliver_Msg >>$OUTFILE
  1659. X    Reference_Msg >>$OUTFILE
  1660. X    if test -n "$PATHSIZE" ; then
  1661. X        credit="`Check_PathSize $UUCP_SENDER`"
  1662. X        if [ "$credit" = "" ]; then
  1663. X            if [ "$CREDIT" != "0" ]; then 
  1664. X                echo "\nYou are a new user; credits: $CREDIT (bytes)\n" >>$OUTFILE
  1665. X                echo "(This request will be billed as well, normally about 800 bytes)\n" >>$OUTFILE
  1666. X            fi
  1667. X        else
  1668. X                if [ "$credit" = "UNLIMITED" ]; then
  1669. X                echo "\nYour path has no limitations.\n" >>$OUTFILE
  1670. X                else
  1671. X                echo "\nCredits remaining: $credit out of $CREDIT (bytes)\n" >>$OUTFILE
  1672. X                echo "(This request will be billed as well, normally about 800 bytes)\n"
  1673. X                fi
  1674. X        fi
  1675. X    else
  1676. X        echo "\nPathsizing not running here. No limits!\n" >>$OUTFILE
  1677. X    fi
  1678. Xecho "Command executed: credits for $UUCP_SENDER" >> $LOGFILE
  1679. X    Mail_File ;;
  1680. X
  1681. X
  1682. Xfind)    Deliver_Msg >>$OUTFILE
  1683. X    Reference_Msg >>$OUTFILE
  1684. X    if [ "$argument" = "DEFAULT" ]; then
  1685. X        test $DEBUG && echo "Missing argument for \"find\""
  1686. X        echo "\nERROR: command \"find\" needs a valid argument!\n" >>$OUTFILE
  1687. X        NeedHelp_Msg >>$OUTFILE
  1688. X        NoHuman_Msg >>$OUTFILE
  1689. X    else
  1690. X        echo "Command executed: find $argument : $ARPA_SENDER" >>$LOGFILE
  1691. X        FindFile $argument >>$OUTFILE
  1692. X    fi
  1693. X    Mail_File ;;    
  1694. Xhelp)    Deliver_Msg >>$OUTFILE
  1695. X    Reference_Msg >>$OUTFILE
  1696. X    if [ "$argument" != "DEFAULT" ]; then
  1697. X        echo "\n\
  1698. XHELP is not available for \"$argument\": try a simple @@ help" >>$OUTFILE
  1699. X    else
  1700. X        argument="HELP"; from="DEFAULT";
  1701. X        hname=""; hname="`GetFile $argument $from`" 
  1702. X        if [ "$hname" != "" ]; then
  1703. X            cat $hname >>$OUTFILE
  1704. X            echo "Command executed: help : $ARPA_SENDER" >>$LOGFILE
  1705. X        else
  1706. X            echo "WARNING: NO HELP for $ARPA_SENDER" >>$LOGFILE
  1707. X            echo "\n\
  1708. XCannot open help file inside RNA system directory - sorry" >>$OUTFILE
  1709. X        fi
  1710. X    Mail_File 
  1711. X    fi ;;
  1712. X     *)    test $DEBUG && echo "WARNING: interpreter error with token $1"
  1713. X        echo "WARNING: interp error token $1" >>$LOGFILE
  1714. X        shift; shift;;
  1715. X
  1716. Xesac
  1717. X# the following bracket close the restricted environment of the interpreter
  1718. X)
  1719. X# recycle next command line (if any)
  1720. Xshift
  1721. X# end while, recycle
  1722. Xdone
  1723. Xelse
  1724. X#    CMDLOG empty: no commands found inside current message
  1725. X    test $DEBUG && echo "no commands found, notify origin."
  1726. X    echo "Current message is empty : $ARPA_SENDER" >>$LOGFILE
  1727. X    Headers_Msg >>$OUTFILE
  1728. X    Deliver_Msg >>$OUTFILE
  1729. X    echo "" >>$OUTFILE
  1730. X    NoCommands_Msg >>$OUTFILE
  1731. X    Mail_File
  1732. Xfi
  1733. X}
  1734. X# End of interpreter
  1735. X
  1736. X# -----------------------------------
  1737. X#            main program
  1738. X# -----------------------------------
  1739. X
  1740. Xtest -n "$PATHSIZE" && {
  1741. X    test -r $PATHSIZE || {
  1742. X        test $DEBUG && echo "ERROR: cannot open $PATHSIZE"
  1743. X        exit
  1744. X    }
  1745. X}
  1746. X
  1747. X# Are we out of service?
  1748. Xtest -r $RNADIR/hold || {
  1749. X#    No. Check if we just came out of 'holding' state: in this case we
  1750. X#    might have a 'pending' file with old jobs to process.
  1751. X    test -r $RNADIR/pending && {
  1752. X#        That's it: old requests.. We append them to our current
  1753. X#        mailbox. New ones are stored before these, i know. 
  1754. X#        It makes little sense to spend time reordering...
  1755. X        cat $RNADIR/pending >>$MAILBOX
  1756. X# %%FIX%%  
  1757. X# check out that every mail is separated by a null line, in the previous
  1758. X# cat. Normally, it should. Well, if not, add it. 
  1759. X        rm $RNADIR/pending
  1760. X    }
  1761. X}
  1762. X
  1763. Xtest -s $MAILBOX && { 
  1764. XStartup
  1765. XGetMail 
  1766. XCutMail
  1767. Xset `wc -l $POINTERS`
  1768. Xtest $DEBUG && echo "New mail found: $1 message(s)"
  1769. Xecho "\n FOUND $1 MESSAGE(S)" >>$LOGFILE
  1770. Xuntil [ "$message" -gt "$1" ]
  1771. Xdo
  1772. X    test $DEBUG && echo "Now working on message n.$message"
  1773. X    ( ClrTmpFiles
  1774. X    GetMessage $message
  1775. X    parse 
  1776. X    interp )
  1777. X    test $DEBUG && echo "message n.$message is over"
  1778. X    message=`expr $message + 1`
  1779. Xdone
  1780. Xtest $DEBUG && echo "RNA SESSION COMPLETED SUCCESSFULLY"
  1781. X}
  1782. X
  1783. X
  1784. X# End of RNA
  1785. X# %%FIX%%
  1786. X# Congratulations, you got to the end of RNAlib configuration. If you
  1787. X# followed indications now you have a working copy of RNA 2.0.
  1788. X# Before attempting to execute, however, remember you need to create at
  1789. X# least an index file  (libindex) for libraries.
  1790. X# In order to make RNA run faster and better, we need to cut off all
  1791. X# comments from the original configured version. So i strongly recommend
  1792. X# you make your configuration and modifications on a COMPLETE version of
  1793. X# RNA, but RUN ALWAYS an extracted rna called 'XRNA'. How do you get
  1794. X# XRNA out of your RNA? Easy: run 'MAKE_RNA'.
  1795. X# Every time you need to change something inside RNA, edit RNA and then 
  1796. X# re-run MAKE_RNA.  -- Paolo 
  1797. X# 
  1798. X# RNALIB 2.0 Revision A - END OF CONFIGURATION
  1799. SHAR_EOF
  1800. $TOUCH -am 0918180790 RNA &&
  1801. chmod 0644 RNA ||
  1802. echo "restore of RNA failed"
  1803. set `wc -c RNA`;Wc_c=$1
  1804. if test "$Wc_c" != "53931"; then
  1805.     echo original size 53931, current size $Wc_c
  1806. fi
  1807. exit 0
  1808.  
  1809.