home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / sources / d / 1524 < prev    next >
Encoding:
Text File  |  1993-01-07  |  61.4 KB  |  1,475 lines

  1. Newsgroups: comp.sources.d
  2. Path: sparky!uunet!think.com!rpi!usc!ucla-cs!ficus.cs.ucla.edu!johnh
  3. From: johnh@ficus.cs.ucla.edu (John Heidemann)
  4. Subject: Re: v34i092: mserv - Squirrel Mail Server Software, version 3.1, Part01/06
  5. Message-ID: <johnh.726430867@ficus.cs.ucla.edu>
  6. Sender: usenet@cs.ucla.edu (Mr Usenet)
  7. Nntp-Posting-Host: nottingham.cs.ucla.edu
  8. Organization: UCLA, Computer Science Department
  9. References: <csm-v34i092=mserv.214515@sparky.IMD.Sterling.COM>
  10. Date:  7 Jan 93 18:21:07 GMT
  11. Lines: 1462
  12.  
  13. I thought you and Jeff Cook might be interested in this.
  14. It's part of a mail server used for remote file access.
  15. Poritions of it might be useful for Truffles.
  16. The remainder of it can be fetched of of the appropriate
  17. newsgroup (comp.sources.misc).
  18.    -John
  19.  
  20. jv@squirrel.mh.nl (Johan Vromans) writes:
  21.  
  22. >Submitted-by: jv@squirrel.mh.nl (Johan Vromans)
  23. >Posting-number: Volume 34, Issue 92
  24. >Archive-name: mserv/part01
  25. >Environment: Perl
  26. >Supersedes: mserv-3.0: Volume 30, Issue 46-49
  27.  
  28. >    Announcing: Squirrel Mail Server Software, version 3.1
  29. >    ======================================================
  30.  
  31. > For the user:
  32. > -------------
  33. >The Squirrel Mail Server is a mail response program. You can send
  34. >email to it, and it will try to react sensible to your message.
  35.  
  36. >Main purpose of the mail server is to obtain files from a local
  37. >archive or FTP servers. It is also possible to search for files and to
  38. >generate directory listings. A powerful index mechanism obsoletes the
  39. >need to transfer huge "ls-lR" files.
  40.  
  41. >While looking for files, the server knows about commonly used
  42. >extensions to filenames (e.g. ".tar.Z" in "foo.tar.Z") and pseudo-
  43. >standard version numbering (e.g. "gcc-2.1.tar.Z").  It is quite well
  44. >possible that a simple request for "emacs" will actually transmit the
  45. >file "gnu/emacs-18/dist/emacs-18.59.tar.Z".
  46.  
  47. >Delivery of information can take place via email or UUCP or both.
  48. >Files are compressed if possible, encoded if necessary, and split into
  49. >pieces if needed. If a transfer fails, it it always possible to
  50. >request retransmission of the failed parts only.
  51.  
  52. > For the implementor:
  53. > --------------------
  54. >All written in perl, hence portable and easily maintainable.  Code is
  55. >readable; useful, plentiful comments. Very extentable and easily
  56. >modified. Easy to install. Over 2000 lines of documentation.
  57.  
  58. >Archives can be split over a number of directories or file systems.
  59.  
  60. >Requests are queued and processed by a separate daemon process (e.g.
  61. >from cron) to cut down on the system load. Moreover, the implementor
  62. >can control when the queue is being run.
  63.  
  64. >All transfers are logged. Maintenance procedures include a reporting
  65. >tool.
  66.  
  67. >Files retrieved via FTP are kept on local store for some time, so
  68. >subsequent requests can be honoured from the cache.
  69.  
  70. > Requirements:
  71. > -------------
  72. >Perl 4.0 patchlevel 35 or later.
  73. >NOTE that perl 4.0 pl35 contains a bug that can be fixed by an
  74. >(unofficial) patch obtainable from the NLUUG mail server -- see below.
  75.  
  76. >GNU find 3.6 or later (only if you want to exploit the index
  77. >features).
  78.  
  79. >A decent mail system that can deliver mail to a process (sendmail,
  80. >smail3, or smail2.5 w/ mods).
  81.  
  82. >Common tools like compress, zoo, zip, uuencode etc.
  83.  
  84. > How to get it:
  85. > --------------
  86. >Send a mail message to <mail-server@nluug.nl> with contents
  87.  
  88. >    begin
  89. >    send mserv-3.1.tar.Z
  90. >    send XPatch-4.035.tar.Z
  91. >    end
  92.  
  93. >The latter file contains some unofficial patches to perl 4.0
  94. >patchlevel 35.
  95.  
  96. >Also available are nicely formatted PostScript versions of the 
  97. >User Guide and Installation Guide:
  98.  
  99. >    send usrguide.ps.Z
  100. >    send mservmgr.ps.Z
  101.  
  102. >The Squirrel Mail Server Software is 
  103.  
  104. >    Copyright 1988,1992,1993 Johan Vromans.
  105.  
  106. >It is distributed under the terms of the GNU Public Licence.
  107.  
  108. >For more information: Johan Vromans <jv@mh.nl> .
  109. >----------------------------------------------------------
  110. >#! /bin/sh
  111. ># This is a shell archive.  Remove anything before this line, then feed it
  112. ># into a shell via "sh file" or similar.  To overwrite existing files,
  113. ># type "sh file -c".
  114. ># Contents:  mserv-3.1 mserv-3.1/INSTALL mserv-3.1/dateconv.pl
  115. ># Wrapped by kent@sparky on Wed Jan  6 21:39:45 1993
  116. >PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  117. >echo If this archive is complete, you will see the following message:
  118. >echo '          "shar: End of archive 1 (of 6)."'
  119. >if test ! -d 'mserv-3.1' ; then
  120. >    echo shar: Creating directory \"'mserv-3.1'\"
  121. >    mkdir 'mserv-3.1'
  122. >fi
  123. >if test -f 'mserv-3.1/INSTALL' -a "${1}" != "-c" ; then 
  124. >  echo shar: Will not clobber existing file \"'mserv-3.1/INSTALL'\"
  125. >else
  126. >  echo shar: Extracting \"'mserv-3.1/INSTALL'\" \(52619 characters\)
  127. >  sed "s/^X//" >'mserv-3.1/INSTALL' <<'END_OF_FILE'
  128. >XAuthor:     Johan Vromans 
  129. >XCmpny:      SQS 
  130. >XCompany:    Squirrel Software 
  131. >XDept.:      Public Domain 
  132. >XProject:    Squirrel Mail Server 
  133. >XTitle:      Squirrel Mail Server
  134. >X            Installation and Maintenance 
  135. >XVersion:    V3.01 
  136. >X----------------------------------------
  137. >X
  138. >X1.    INTRODUCTION 
  139. >X
  140. >X1.1   The Mail Server 
  141. >X
  142. >X      The mail server is a mail response program. This means that you 
  143. >X      can send it an email message, and the program will read this 
  144. >X      message, extracts commands from it, and execute these commands if 
  145. >X      no errors were encountered. 
  146. >X
  147. >X      The main purpose of the mail server is to handle requests for 
  148. >X      files in archives. By sending a request for a file, the mail 
  149. >X      server will look it up and send the requested file to the 
  150. >X      originator of the request, either via email or via UUCP. 
  151. >X
  152. >X      When files are transferred via email, binary files (e.g. 
  153. >X      compressed archives) are encoded using one of several popular 
  154. >X      encoding schemes. Big files are split into pieces to avoid mailer 
  155. >X      limits and transmission failures due to communication problems. 
  156. >X
  157. >X      The algoritms of the mail server are designed to satisfy user 
  158. >X      requests as much as possible, without taking the risk that 
  159. >X      unwanted information is sent. 
  160. >X
  161. >X1.2   Mail Server Basics 
  162. >X
  163. >X      The Squirrel Mail Server Software consists of a set of perl 
  164. >X      programs, data files and a small wrapper program. The installation 
  165. >X      procedure prepares these files, and stores them at a specific 
  166. >X      location on disk, hereafter named LIBDIR. LIBDIR and the files it 
  167. >X      contains should be owned by the so called 'mail server owner'. 
  168. >X
  169. >X      The mail server itself is driven via an email alias entry in the 
  170. >X      file '/usr/lib/aliases' (or whatever your system uses). 
  171. >X
  172. >X      Default values are 'mserv' for the mail server owner, 
  173. >X      'mail-server' for the mail alias, and '/usr/local/lib/mserv' for 
  174. >X      LIBDIR. Al these (and more) can be configured for a particular 
  175. >X      installation. 
  176. >X
  177. >X2.    PRINCIPLES OF OPERATION 
  178. >X
  179. >X      The main functions of the mail server are executed by the programs 
  180. >X      'process' and 'dorequest'. 
  181. >X
  182. >X      A third program 'listener' is usually used as a wrapper around 
  183. >X      'process'. This little C-program disguises itself as the mail 
  184. >X      server owner and executes 'process'. 
  185. >X
  186. >X      The program 'process' reads an incoming email message, scans the 
  187. >X      mail headers and examines the message body for mail server 
  188. >X      commands. Valid server commands are stored internally until the 
  189. >X      whole message has been read. If any errors were found, a short 
  190. >X      help message is sent back to the sender of the message, and the 
  191. >X      program quits. 
  192. >X
  193. >X      If desired, messages originating from a pre-defined list of users 
  194. >X      may be rejected without notice. The standard configuration defines 
  195. >X      @black_list to a list of system accounts, e.g. 'root', 'news', 
  196. >X      'daemon' etc. 
  197. >X
  198. >X      If all commands appear valid, 'process' enters the second phase. 
  199. >X      The commands are executed one by one. If files are requested 
  200. >X      (which is normally the case) the files are looked up in the mail 
  201. >X      server archives, using one or more search techniques discussed 
  202. >X      below. If the file has been located, it is queued for delivery in 
  203. >X      the mail server queue file. 
  204. >X
  205. >X      If files are requested from remote FTP servers, a connection to 
  206. >X      the server is made and the files are transferred to local storage. 
  207. >X      The local copy of the file is then entered in the mail server 
  208. >X      queue for delivery. 
  209. >X
  210. >X      Finally, the program generates a report and sends it to the sender 
  211. >X      of the message. This report contains (a.o.) details about the FTP 
  212. >X      activities, and a list of files that are queued for delivery. 
  213. >X
  214. >X      At this point 'process' is complete and exits. 
  215. >X
  216. >X      Some other time, program 'dorequest' will be run, either 
  217. >X      automatically from 'process' or via cron. This program handles the 
  218. >X      actual delivery of files. It is also responsible for packing 
  219. >X      directories and removing temporary files. 
  220. >X
  221. >X      For delivery via electronic mail, the requested file is (usually) 
  222. >X      encoded to protect binary information from text-based mail 
  223. >X      programs. The encoded file is chopped into parts (chunks) of a 
  224. >X      specific maximum size, to not exceed mailer limits. The parts are 
  225. >X      then passed to the mail program for delivery. If only some parts 
  226. >X      need to be delivered, only these parts are passed to the mail 
  227. >X      program. 
  228. >X
  229. >X      For delivery via UUCP there is no need to encode, so the actual 
  230. >X      input file is passed, in pieces if necessary, to the delivery 
  231. >X      program 'uucp'. 
  232. >X
  233. >X      An entry is made in the mail server logfile for each (partial) 
  234. >X      delivery. 
  235. >X
  236. >X2.1   Format of the queue file 
  237. >X
  238. >X      Each queue entry takes one record from the queue file, with tab 
  239. >X      separated items as follows: 
  240. >X
  241. >X         type           'M' or 'm' for email delivery,
  242. >X                        'U' or 'u' for UUCP transfer,
  243. >X                        'MP' for packed email,
  244. >X                        'UP' for packed UUCP.
  245. >X                        If the 'm' or 'u' is used instead of 'M' or
  246. >X                        'U', the file is removed after being handled.
  247. >X         recipient      the reply address used
  248. >X         destination    email address (for email), or host!path for UUCP
  249. >X                        transfers.
  250. >X         notify         UUCP notification user
  251. >X         request        the request
  252. >X         file           the real name of the real file
  253. >X         encoding       Encoding:
  254. >X                        'B' = btoa, 'U' = uuencode, 'X' = xxencode,
  255. >X                        'D' = Dumas' uue
  256. >X                        If a 'Z' is appended, the file will be compressed
  257. >X                        before being transferred.
  258. >X         limit          max size (in Kb) per chunk
  259. >X         parts          comma-separated parts list.
  260. >X
  261. >X2.2   Format of the logfile 
  262. >X
  263. >X      If you select logging, all transfers that are sent are logged in 
  264. >X      the logfile. Each record has a number of (space separated) fields 
  265. >X      as follows: 
  266. >X
  267. >X         date           e.g. 920501
  268. >X         time           e.g. 15:22
  269. >X         type           'M' for email, 'U' for UUCP transfer
  270. >X         destination    email address, or host!notify for UUCP transfers
  271. >X         request        the name of the requested file
  272. >X         Xnn/mm         X = encoding;
  273. >X                        nn/mm = part nn of mm parts
  274. >X         size           the size of the transfer
  275. >X
  276. >X      Errors are logged with type 'F'. The remainder of the record 
  277. >X      contains the text of the error message. 
  278. >X
  279. >X      If an error is detected due to a user request, the queue entry for 
  280. >X      this request is entered in the logfile with type 'Q'. If the 
  281. >X      failure is temporary, the queue entry can be extracted from the 
  282. >X      logfile and added to the queue (or better: queue~) file. 
  283. >X
  284. >X      The support programs programs 'report.pl' and 'do_report.pl' can 
  285. >X      be used to generate reports from the logfile. 
  286. >X
  287. >X3.    IMPLEMENTATION DETAILS 
  288. >X
  289. >X      Program 'process' uses the package 'rfc822' to read the incoming 
  290. >X      mail message. This package supports reading header and body of the 
  291. >X      message, and analyzing RFC822 compliant message headers. 
  292. >X
  293. >X      One of the functions of the package is to extract the send 
  294. >X      information from the 'From', 'Sender' and 'Reply-To' headers. 
  295. >X
  296. >X      The commands are parsed by subroutine 'command_loop'. The command 
  297. >X      handling is table driven, %cmd_tbl contains, for each of the 
  298. >X      command verbs, the name of the subroutine to be called to parse 
  299. >X      the command. 
  300. >X
  301. >X      Upon completion subroutine 'index_loop' (required from file 
  302. >X      pr_doindex.pl) is called to handle index requests stored 
  303. >X      internally in @indexq. 
  304. >X
  305. >X      Then subroutine 'search_loop' is called to handle search requests 
  306. >X      stored in @searchq. 
  307. >X
  308. >X      If needed, subroutine 'do_work' (required from file pr_dowork.pl) 
  309. >X      is called to handle the commands stored internally in @workq. This 
  310. >X      will probably result in transfer requests being stored in @queueq. 
  311. >X
  312. >X      Processing @workq is table driven, just like the command loop. 
  313. >X      Therefore is it very easy to add your own commands (and execution 
  314. >X      code) to the mail server program without having to modify the 
  315. >X      source code. See chapter "Advanced Techniques" for more 
  316. >X      information. 
  317. >X
  318. >X      If @queueq contains transfer requests, these requests are reported 
  319. >X      and stored in the queue file for processing by program 
  320. >X      'dorequest'. 
  321. >X
  322. >X      Finally, a help message is generated on demand, or if syntactic 
  323. >X      errors were detected by 'command_loop'. 
  324. >X
  325. >X3.1   Archive file lookup 
  326. >X
  327. >X      One of the advantages of the Squirrel Mail Server is the 
  328. >X      possibility to spread the archives over a number of file trees. 
  329. >X      Another advantage is the ability to search for files in the 
  330. >X      archives, using file- and directory searches and index lookup. 
  331. >X      While searching, a number of known extensions are appended to the 
  332. >X      filename so that a request for 'foo' might result in finding 
  333. >X      'foo.Z' or 'foo.tar'. 
  334. >X
  335. >X      The general principle of searching is: 
  336. >X
  337. >X      -- Use file lookup;
  338. >X      -- if not found; use directory search;
  339. >X      -- if still not found: search the index;
  340. >X      -- unsuccessfull, or multiple possibilities were found,
  341. >X         try automatic packing;
  342. >X      -- if still unsuccessfull, try automatic compression.
  343. >X
  344. >X      When a SEARCH command is issued, all alternatives are tried and a 
  345. >X      list of possibilities is returned. 
  346. >X
  347. >X3.1.1 File search strategy 
  348. >X
  349. >X      This strategy is rather straightforward: for each of the archive 
  350. >X      directories, try to locate the requested file by appending the 
  351. >X      known extensions. E.g. when looking for 'file': 
  352. >X
  353. >X            dir1/file
  354. >X            dir1/file.tar
  355. >X            dir1/file.tar.Z
  356. >X            ...
  357. >X            dir2/file
  358. >X            dir2/file.tar
  359. >X            ... etc ...
  360. >X
  361. >X      If an exact match is found, the search within the directory is 
  362. >X      terminated. This way it is possible to locate 'foo' even if 
  363. >X      'foo.tar' also exists. 
  364. >X
  365. >X3.1.2 Directory search strategy 
  366. >X
  367. >X      The directory search extends the file search. The code is located 
  368. >X      in file 'pr_dsearch.pl'. 
  369. >X
  370. >X      It reads the directories that are specified in @libdirs, and 
  371. >X      searches them for entries that correspond to certain patterns. In 
  372. >X      general, it looks for filenames that start with the search 
  373. >X      argument, optionally followed by something that can be interpreted 
  374. >X      as a version number. If such a filename is found, and it 
  375. >X      corresponds to a directory, the search recurses to this directory. 
  376. >X      If not, the known extensions are tried. 
  377. >X
  378. >X      E.g. when looking for 'file': 
  379. >X
  380. >X            dir1/file-2.3.tar.Z              <-- found
  381. >X            dir1/file/                       <-- recurse
  382. >X            dir1/file/file-2.3.tar.Z         <-- found
  383. >X            dir1/file-2.3/                   <-- recurse
  384. >X            dir1/file-2.3/file.tar.Z         <-- found
  385. >X            dir1/file-2.3/file-2.3.tar.Z     <-- found
  386. >X            ...
  387. >X
  388. >X      This process is repeated for every directory in @libdirs. 
  389. >X
  390. >X3.1.3 Index search strategy 
  391. >X
  392. >X      The final (and most powerful) search strategy uses a list of 
  393. >X      filenames, and searches for every occurrence of the search 
  394. >X      argument. The code is located in file 'pr_isearch.pl'. 
  395. >X
  396. >X      The index strategy is based on the GNU 'locate' program. This 
  397. >X      program provides an extreme fast searching method in a compressed 
  398. >X      list of files. 
  399. >X
  400. >X      When searching the index, the search argument is turned into a 
  401. >X      regular expression pattern and passed to the 'locate' program. The 
  402. >X      output of this program is further analyzed to find filenames using 
  403. >X      the same method as described above (version numbers and known 
  404. >X      extensions). 
  405. >X
  406. >X      For efficiency, the 'locate' database contains the file date and 
  407. >X      size, so no other lookups are needed. 
  408. >X
  409. >X      It is possible to have an index file per archive directory 
  410. >X      (default situation), or one single index file that contains 
  411. >X      information for all archive directories. 
  412. >X
  413. >X      The index information is maintained by the program 'makeindex'. 
  414. >X      This program uses GNU 'find' to traverse the archive directories, 
  415. >X      and GNU 'locate' tools to create the index files. 
  416. >X
  417. >X3.1.4 Automatic Packing 
  418. >X
  419. >X      This section only applies if $auto_packing and $packing_limit have 
  420. >X      been set in the configuration file. 
  421. >X
  422. >X      If the user requests for 'file.XXX', where XXX is a known packing 
  423. >X      extension ('zip', 'zoo', 'tar' or 'tar.Z'), and this file does not 
  424. >X      exist, automatic packing is tried. 
  425. >X
  426. >X      The packing extension is removed from the filename. If the 
  427. >X      resultant name points to a directory it is handled as if the 
  428. >X      request were preceeded with a PACK command. See also the section 
  429. >X      on Packing, below. 
  430. >X
  431. >X      No search strategies will be used when locating this directory. 
  432. >X
  433. >X3.1.5 Automatic Compression 
  434. >X
  435. >X      This section only applies if $auto_compress and $compress have 
  436. >X      been set in the configuration file. 
  437. >X
  438. >X      If the user requests for a file 'foo.Z', which does not exist, but 
  439. >X      a file 'foo' exists in the archives, this file is queued for 
  440. >X      delivery. Before transfer, it will be compressed. 
  441. >X
  442. >X      The strategies file search, directory search and index search will 
  443. >X      be used when locating this file. Normally, no known extensions are 
  444. >X      tried. By setting $auto_compress to a value greater than 1 in the 
  445. >X      config file, known extensions will be tried, so that a request for 
  446. >X      'file.Z' may result in 'file.shar.Z' (or 'file.zoo.Z'). 
  447. >X
  448. >X3.2   FTP file lookup 
  449. >X
  450. >X      The Squirrel Mail Server uses a cached FTP lookup mechanism. The 
  451. >X      code is located in file 'pr_ftp.pl'. 
  452. >X
  453. >X      When a request for a file to be retrieved via FTP is handled, the 
  454. >X      mail server performs the following steps. 
  455. >X
  456. >X      1. A connection is made to the FTP host. 
  457. >X
  458. >X      2. A directory request (LIST command) is used to retrieve 
  459. >X         information about the file that is being requested. 
  460. >X
  461. >X      3. The file is looked up in the FTP cache. If the file exists in 
  462. >X         the cache, the file modification date and size are compared to 
  463. >X         the FTP information from the FTP host. 
  464. >X
  465. >X      4. If the file is not in the cache, or if the info does not match, 
  466. >X         the file is retrieved from the FTP host and placed in the 
  467. >X         cache. 
  468. >X
  469. >X      5. The file in the cache is queued for delivery. 
  470. >X
  471. >X      This caching strategy is based on the assumption that, when a 
  472. >X      piece of interesting software is made available via anonymous FTP 
  473. >X      and announced on the net, several requests for this file will be 
  474. >X      made within a short period of time. 
  475. >X
  476. >X      Special precautions are taken to prevent problems when the cache 
  477. >X      does not exists, or is write-protected, etc. In this case, the 
  478. >X      file is retrieved to temporary storage and transferred from there. 
  479. >X
  480. >X      The filenames for the cache are generated by reversing the 
  481. >X      dot-separated parts of the FTP host name, and prepending these (as 
  482. >X      directories) to the file name, e.g. 
  483. >X
  484. >X            prep.ai.mit.edu:/pub/gnu/emacs-18.59.tar.Z
  485. >X
  486. >X      is stored in the cache as 
  487. >X
  488. >X            edu/mit/ai/prep/gnu/emacs-18.59.tar.Z
  489. >X
  490. >X      A leading directory "pub" is removed from the resultant filename. 
  491. >X      The host info is transformed to all lowercase; the filename is 
  492. >X      not. 
  493. >X
  494. >X      NOTE:  VMS style filenames are recognized and transformed. The
  495. >X             resultant filename is lowcased.
  496. >X             VMS directory info is not handled yet.
  497. >X
  498. >X3.3   Directory listings 
  499. >X
  500. >X      Directory listings are obtained from the server using a local 
  501. >X      "ls -l" command or an FTP "LIST" command, the return info is 
  502. >X      stored in a temporary file. If the size of this file does not 
  503. >X      exceed a specific limit ($fb_limit) it is included in the output. 
  504. >X      Otherwise it is queued for delivery. 
  505. >X
  506. >X3.4   Archie commands 
  507. >X
  508. >X      Archie commands are handled by executing the 'archie' program. The 
  509. >X      output is stored in a temporary file. If the size of this file 
  510. >X      does not exceed a specific limit ($fb_limit) it is included in the 
  511. >X      output. Otherwise it is queued for delivery. 
  512. >X
  513. >X3.5   Packing 
  514. >X
  515. >X      With packing, it is possible to gather the contents of a directory 
  516. >X      into a single file, which is then queued for transfer. Before 
  517. >X      doing so, the size of the resultant file is calculated. If the 
  518. >X      size exceeds a specific limit ($packing_limit) the request is 
  519. >X      rejected, to prevent accidental (or not accidental) retrieval of 
  520. >X      too much information. 
  521. >X
  522. >X      The name of the directory is stored in the queue file, the actual 
  523. >X      packing and delivery is handled by the 'dorequest' program. 
  524. >X
  525. >X3.6   The delivery process 
  526. >X
  527. >X      Upon completion of 'process' all files to be transferred are 
  528. >X      stored somewhere on disk, and their names and destinations are in 
  529. >X      the queue file. 
  530. >X
  531. >X      The delivery is handled by program 'dorequest'. It can be run 
  532. >X      automatically from 'process', from 'cron' or manually. 
  533. >X
  534. >X      Upon invokation, it ensures that there is only one instance of the 
  535. >X      program running. Then it locks the mail server queue, reads it 
  536. >X      into internal storage, writes it out to a special backup version 
  537. >X      on disk, empties the queue on disk and releases it. The queue file 
  538. >X      is not simply removed, since other instances of 'process' may 
  539. >X      already be waiting to store new entries in the queue file. 
  540. >X      (Actually, 'dorequest' picks up an existing backup on disk first, 
  541. >X      since that file results from a previous run of 'dorequest' that 
  542. >X      was not properly finished, most likely due to a system crash.) The 
  543. >X      backup file is hereafter referred to with 'queue~', since its name 
  544. >X      is dereived from the name of the queue file by appending a tilde. 
  545. >X
  546. >X      Next, the program starts to handle the entries that were in the 
  547. >X      queue. First the internal copy of the queue is written to the 
  548. >X      queue~ file. Then an entry is taken from the internal queue, to be 
  549. >X      handled. This way, if the system crashes during a 'dorequest' run, 
  550. >X      no requests will get lost. 
  551. >X
  552. >X      If the request needs packing, the contents of the directory are 
  553. >X      stored into a single file, which is then queued for transfer. 
  554. >X
  555. >X      The following packing methods are supported by the mail server, 
  556. >X      although they need not be present in each implementation. 
  557. >X
  558. >X      *  (Compressed) tar 
  559. >X
  560. >X         The contents of the directory are gathered into a tar-file, 
  561. >X         which is then compressed. If the public domain program 'pdtar' 
  562. >X         is available, it is ised to handle the packing and compressing. 
  563. >X         Otherwise the output of 'tar' is piped to 'compress'. 
  564. >X
  565. >X      *  Zoo 
  566. >X
  567. >X         The popular 'zoo' program is used, in combination with 'find', 
  568. >X         to gather the information. 
  569. >X
  570. >X      *  Zip 
  571. >X
  572. >X         The INFO-ZIP standard 'zip' program is used to handle the 
  573. >X         request. 
  574. >X
  575. >X      If the requested file must be compressed, this is handled now. The 
  576. >X      file is compressed into a temporary file which is further 
  577. >X      processed. If the file to be transferred was a temporary file, it 
  578. >X      is removed. The (freshly created) temporary file is marked for 
  579. >X      deletion so it will be removed upon completion of this request. 
  580. >X
  581. >X      For delivery via electronic mail, the requested file is (usually) 
  582. >X      encoded to protect binary information from text-based mail 
  583. >X      programs. The encoded file is chopped into parts (chunks) of a 
  584. >X      specific maximum size, to not exceed mailer limits. The parts are 
  585. >X      then passed to the mail program for delivery. If only some parts 
  586. >X      need to be delivered, only these parts are passed to the mail 
  587. >X      program. To reduce system load, the 'dorequest' program sleeps a 
  588. >X      bit between parts so the mail delivery can take place. 
  589. >X
  590. >X      For delivery via UUCP there is no need to encode, so the actual 
  591. >X      input file is passed, in pieces if necessary, to the delivery 
  592. >X      program 'uucp'. 
  593. >X
  594. >X      An entry is made in the mail server logfile for each (partial) 
  595. >X      delivery. 
  596. >X
  597. >X      Finally, if the file to be transferred was a temporary file, it is 
  598. >X      removed and processing continues with the next entry in the queue. 
  599. >X
  600. >X      Upon completion, the backup of the queue file (queue~) on disk 
  601. >X      will be removed. 
  602. >X
  603. >X4.    SUPPORT PROGRAMS 
  604. >X
  605. >X4.1   Generating the index files 
  606. >X
  607. >X      The program 'makeindex', as its name suggests, maintains the index 
  608. >X      information. It is based on the 'updatedb' program that comes with 
  609. >X      GNU find. 
  610. >X
  611. >X      The program should be run from cron, as often as needed to keep 
  612. >X      the index file synchronized with the actual contents of the 
  613. >X      archives. Usually once per day (night) is sufficient. 
  614. >X
  615. >X      Sometimes it is not appropriate to include all information in the 
  616. >X      index file, e.g. a specific sub-tree might contain your local news 
  617. >X      spool which is not to be retrieved via the mail server. You can 
  618. >X      set @libprunes in the configuration file to a regular expression 
  619. >X      pattern to exclude certain directories from being traversed. Note 
  620. >X      that this pattern is implicitly anchored, i.e. it behaves as if it 
  621. >X      were placed between '^' and '$'. @libprunes, if used, should 
  622. >X      contain a pattern for each of the directories in @libdirs, in the 
  623. >X      same order. 
  624. >X
  625. >X4.2   Analyzing the log file 
  626. >X
  627. >X      The support programs programs 'report' and 'do_report' can be used 
  628. >X      to generate reports from the logfile. 
  629. >X
  630. >X      'do_report' is a wrapper around 'report', and will usually be the 
  631. >X      only program used. 
  632. >X
  633. >X      When run, 'do_report' gathers logfile information about transfers 
  634. >X      and errors. Both reports are mailed to the mail server owner by 
  635. >X      default. You can specify other recipients on the command line. 
  636. >X
  637. >X      You can specify a cutoff date and time for error reporting by 
  638. >X      supplying the name of a file that is timestamped after the 
  639. >X      previous error report. The 'do_report' program normally updates 
  640. >X      the timestamp of this file, so errors are reported only once. 
  641. >X
  642. >X      A typical usage report looks like: 
  643. >X
  644. >X            Mail Server Report for July 1992 -- by Package                           Page 1
  645. >X            
  646. >X                                                                     1111111111222222222233
  647. >X            Package                              Type Total 1234567890123456789012345678901
  648. >X            -------------------------------------------------------------------------------
  649. >X            /usr/local/lib/mserv/pub/README         M     1                   S
  650. >X            /usr/local/lib/mserv/pub/mserv.tar.Z    M     2                   S
  651. >X            TOTAL                                         4                   S
  652. >X
  653. >X      'Type' will be 'M' for mail transfers, and 'U' for UUCP transfers. 
  654. >X      'Total' denoted the number of times a file has been requested. The 
  655. >X      rest of the information shows on what days requests have been 
  656. >X      issued. In the above example, all requests were issued on July 19 
  657. >X      (a Sunday). 
  658. >X
  659. >X      Likewise, a list will be generated containing the users that have 
  660. >X      requested files. 
  661. >X
  662. >X      Program 'do_report' can also be used to cleanup the logfile. If 
  663. >X      this function is selected, the logfile is renamed to a '.o' 
  664. >X      extension (e.g. 'logfile.o'), and appended to a file with a '.cum' 
  665. >X      extension (e.g. 'logfile.cum'). It is possible to compress the 
  666. >X      accumulating logfile, in this case the program will uncompress is 
  667. >X      before appending the new information, and compress it afterwards. 
  668. >X
  669. >X      Command line options for 'do_report' are: 
  670. >X
  671. >X                -config XX   use alternate config file
  672. >X                -usage       generate usage report
  673. >X                -ftp         show files in FTP cache
  674. >X                -full        generate report for usage, errors and ftp
  675. >X                -ftpclean    cleanup old files in FTP cache (implies -ftp)
  676. >X                -ftpkeep NN  number of days a file is to be kept in the FTP cache
  677. >X                -since FILE  only error messages newer than FILE
  678. >X                             (FILE date will be updated upon successful completion)
  679. >X                -noupdate    do not update FILE date
  680. >X                -collect     collect and cleanup logfile data
  681. >X                -help        this message
  682. >X                -trace       show commands
  683. >X                -ident       print identification
  684. >X            
  685. >X            Default action is to generate a usage report, and to mail it to the
  686. >X            recipients.
  687. >X
  688. >X4.3   The FTP cache 
  689. >X
  690. >X      Program 'do_report' can also be used to report the contents of the 
  691. >X      FTP cache, and to exipre it. 
  692. >X
  693. >X      A typical report, generated with "do_report -ftp", will look like: 
  694. >X
  695. >X            Files in FTP cache /usr/local/lib/mserv/pub
  696. >X            
  697. >X              Timestamp     Age* Size  Filename (* means: file has been removed)
  698. >X            --------------  ---  ----  ------------------------------------
  699. >X            92/12/05 02:24   5   142K  com/foo/ftp/crack-4.1.tar.Z
  700. >X            92/12/01 12:34   9*    2K  com/foo/ftp/pasta/INDEX
  701. >X
  702. >X      'Timestamp' indicates the last modification time of the file as 
  703. >X      dereived from the FTP server. 'Age' is the last access date of the 
  704. >X      file in the cache, in days. The cache expiry time is set in the 
  705. >X      configuration file, but can be overridden with a command line 
  706. >X      option. By using the last access date for expiry, the file will be 
  707. >X      considered 'new' each time it is accessed. An '*' after the file 
  708. >X      age means that this file has exceeded the expiry time and has been 
  709. >X      removed from the cache. 
  710. >X
  711. >X5.    INSTALLING THE SQUIRREL MAIL SERVER SOFTWARE 
  712. >X
  713. >X5.1   Preparation 
  714. >X
  715. >X      As distributed, perl is expected to reside in /usr/local/bin. You 
  716. >X      can change this in the Makefile if your perl resides somewhere 
  717. >X      else. 
  718. >X
  719. >X      The mail server needs a user id to own the programs, and a place 
  720. >X      where the programs and files can be stored. Pre-configured values 
  721. >X      are "mserv" and "/usr/local/lib/mserv" respectively. We'll call 
  722. >X      the library LIBDIR in this document. LIBDIR could be the HOME 
  723. >X      directory of the mail server owner, but it need not. If you prefer 
  724. >X      a different value for LIBDIR, change the appropriate line in the 
  725. >X      Makefile. The name of the mail server owner can be changed in step 
  726. >X      2, as described below. 
  727. >X
  728. >X      Since all messages sent by the mail server are sent under the 
  729. >X      server owner uid, its full name (the GCOS or comment field in 
  730. >X      /etc/passwd) should be descriptive. 
  731. >X
  732. >X      The mail server owner does not need any privileges, except for 
  733. >X      read access to the archives, and read/write access to LIBDIR. 
  734. >X
  735. >X      Do not use the root account for server owner! 
  736. >X
  737. >X5.2   Configure and build 
  738. >X
  739. >X      Tailor 'ms_config.pl' to reflect your specific needs. It has 
  740. >X      extensive descriptions for configuration variables and values. Do 
  741. >X      not forget to tailor the Makefile also, if needed. 
  742. >X
  743. >X      It may be a good habit to generate differences using the 'diff' 
  744. >X      program so you can apply your modifications to a new version of 
  745. >X      the mail server software easily. 
  746. >X
  747. >X      Issue "make" to prepare the programs. 
  748. >X
  749. >X      If you select the index file feature, you need GNU find / locate. 
  750. >X      As of GNU find version 3.6, you can use the locate program 'as 
  751. >X      is'. For version 3.5, change GNUFIND in the Makefile to designate 
  752. >X      where your GNU find sourcetree is, and issue "make ixlookup". This 
  753. >X      will build a customized version of GNU locate, called 'ixlookup'. 
  754. >X
  755. >X      Issue "make listener" to generate and compile the listener 
  756. >X      program. This command uses ms_config.pl (from the current 
  757. >X      directory) to determine how to build the listener program. 
  758. >X
  759. >X5.3   Verify the configuration 
  760. >X
  761. >X      You can now verify the configuration with the 'chkconfig' program. 
  762. >X
  763. >X      You may need to run the perl tool 'h2ph' to supply system include 
  764. >X      files needed for locking and socket IO. Pay attention to the lines 
  765. >X      that got a "Not found" remark. Since the software has not been 
  766. >X      installed yet, some of these remarks must be considered normal. 
  767. >X
  768. >X            % perl chkconfig.pl -current
  769. >X            Squirrel Mail Server Software V3.01 [chkconfig 1.30]
  770. >X            MSERVLIB = (not set, but that's OK)
  771. >X            Program library: /usr/local/lib/mserv/src [OK]
  772. >X            
  773. >X            Server owner: mserv, uid = 50, gid = 8, "Squirrel Mail Server"
  774. >X            Bcc user: mserv, uid = 50, gid = 8, "Squirrel Mail Server"
  775. >X            
  776. >X            The 'listener' program will use the setruid system call
  777. >X              It will change identity to compiled-in uid 50
  778. >X              (setenv will be used to set USER, LOGNAME and HOME)
  779. >X            The 'listener' program is not installed correctly!
  780. >X              It should be installed setuid mserv
  781. >X            
  782. >X            Replies will be sent using "/usr/lib/sendmail" [OK]
  783. >X            Preset mail headers:
  784. >X              From: PRONTO Mail Server <bit-bucket@mh.nl>
  785. >X              X-Server: Squirrel Mail Server Software V3.01 [chkconfig 1.30]
  786. >X              X-Info: Send mail to <postmaster@mh.nl>
  787. >X            
  788. >X            Mail messages from the following users will be rejected:
  789. >X              root uucp mailer MAILER-DAEMON news daemon demon deliver sendmail
  790. >X            
  791. >X            Transfer strategies:
  792. >X              email: "/usr/lib/sendmail -odq" [OK]
  793. >X                     wait 30 seconds between chunks
  794. >X                     limits: 64K (default), 10K (min), 1024K (max)
  795. >X              uucp : "/usr/bin/uucp -ga" [OK]
  796. >X                     check host names using "/usr/bin/uuname" [OK]
  797. >X                     limits: 256K (default), 10K (min), 2048K (max)
  798. >X                     uucp transfer is preferred, if possible
  799. >X            
  800. >X            Search strategies: File Directory Index
  801. >X            
  802. >X            Archives:
  803. >X              /usr/local/src [OK]
  804. >X              /beethoven/arch [OK]
  805. >X              /albinoni/arch [OK]
  806. >X              /usr/local/lib/mserv/src/pub [*** Not found ***]
  807. >X            
  808. >X            Indexfiles:
  809. >X              /usr/local/src/ix.codes [Not found, but that's OK]
  810. >X              /beethoven/arch/ix.codes [Not found, but that's OK]
  811. >X              /albinoni/arch/ix.codes [Not found, but that's OK]
  812. >X              /usr/local/lib/mserv/src/pub/ix.codes [Not found, but that's OK]
  813. >X            Limit per index request: 200 lines.
  814. >X            
  815. >X            Index tools:
  816. >X              gfind      /usr/local/bin/gfind [OK]
  817. >X              ixlookup   /usr/local/bin/locate [OK]
  818. >X              locatelib  /usr/local/lib/locate [OK]
  819. >X            
  820. >X            Server files:
  821. >X              queue      /usr/local/lib/mserv/src/queue [OK]
  822. >X              logfile    /usr/local/lib/mserv/src/logfile [Not found, but that's OK]
  823. >X              lockfile   /usr/local/lib/mserv/src/lockfile [OK]
  824. >X              notes      /usr/local/lib/mserv/src/mserv.notes [OK]
  825. >X              hints      /usr/local/lib/mserv/src/mserv.hints [OK]
  826. >X            
  827. >X            Locking with fcntl(2).
  828. >X            Use the 'testlock' program to verify the locking! (See INSTALL)
  829. >X            
  830. >X            Default encoding is B (btoa)
  831. >X            Encoders:
  832. >X              btoa       /usr/local/bin/btoa [OK]
  833. >X              uuencode   /usr/bin/uuencode [OK]
  834. >X              uue        /usr/local/bin/uue [OK]
  835. >X              xxencode   /usr/local/bin/xxencode [Not found, but that's OK]
  836. >X            
  837. >X            Tools:
  838. >X              dir: "/bin/ls -lL" [OK]
  839. >X              archie: "/usr/local/bin/archie" [OK]
  840. >X              extensions: /usr/local/lib/mserv/src/userdefs.pl [OK]
  841. >X              feedback limit = 8K
  842. >X            
  843. >X            Support for FTP is included.
  844. >X              Limited to uucp only.
  845. >X              Cache dir = /usr/local/lib/mserv/src/ftp [*** Not found ***]
  846. >X              Files are kept for 8 days in the cache.
  847. >X            
  848. >X            Support for packing is included.
  849. >X              Packing limit = 4100 blocks.
  850. >X              Dusk usage obtained using "/bin/du" [OK]
  851. >X              File list obtained using "/usr/local/bin/gfind" [OK]
  852. >X              Methods: tar [OK] zip [OK] zoo [OK]
  853. >X              Compress/Tar using "/usr/local/bin/pdtar" [OK]
  854. >X              Automatic packing of directories is allowed.
  855. >X            
  856. >X            Working storage: /usr/tmp [OK]
  857. >X            
  858. >X            The queue will automatically be run upon completion of process.
  859. >X            The mail server will be niced with 10.
  860. >X
  861. >X5.4   Installation 
  862. >X
  863. >X      Now "su mserv" and execute "make install". 
  864. >X
  865. >X      This will install all programs and files in LIBDIR. It will not 
  866. >X      install programs ixlookup and listener, since they need special 
  867. >X      treatment. 
  868. >X
  869. >X      If you select the index file feature, issue "make 
  870. >X      install-ixlookup" if you need the customized version of GNU locate 
  871. >X      3.5. Note that whoever creates the index files, must have write 
  872. >X      access to the location the index files are stored. 
  873. >X
  874. >X      If you configured the listener to use the setruid/setrgid system 
  875. >X      calls, you need to "su mserv" before executing "make 
  876. >X      install-listener". 
  877. >X
  878. >X      If you do not have setruid/setrgid, the program must be installed 
  879. >X      setuid root. In this case, you have to "su root" before doing 
  880. >X      "make install-listener". Look at the source of the listener.c 
  881. >X      program to verify it will not harm your system security. 
  882. >X
  883. >X      Cd to the LIBDIR directory, and run 'chkconfig' again. Make sure 
  884. >X      that all settings have the expected values. 
  885. >X
  886. >X5.5   Testing interactively 
  887. >X
  888. >X      Run LIBDIR/listener als follows: 
  889. >X
  890. >X            % ~mserv/listener -noqueue
  891. >X
  892. >X      Is should display a friendly banner: 
  893. >X
  894. >X            Mail Server (Squirrel Mail Server Software V3.01) ready.
  895. >X            Local time is Thu Dec 24 20:33:06 1992.
  896. >X            Enter HELP for a list of commands.
  897. >X            
  898. >X            Command>
  899. >X
  900. >X      Type "mail foo", followed by a RETURN: 
  901. >X
  902. >X            Command> mail foo
  903. >X            Command: mail foo
  904. >X            => Transfer via email to "foo"
  905. >X
  906. >X      Try "send HELP", followed by a RETURN: 
  907. >X
  908. >X            Command> send HELP
  909. >X            Command: send HELP
  910. >X            => Send: HELP
  911. >X            Request results:
  912. >X            
  913. >X              Request                   Size  Enc  Limit  Status
  914. >X              -----------------------  -----  ---  -----  ------
  915. >X              HELP                       19K   A     64K  Tested OK
  916. >X            
  917. >X            Encoding A means: not encoded (plain file).
  918. >X            
  919. >X            The requests with status "Queued" will be sent as soon as
  920. >X            the load of the server system permits, usually within 24 hours.
  921. >X
  922. >X      At this point, the basic functions of the mail server are working. 
  923. >X      You can issue SEND and SEARCH commands for files in your archives, 
  924. >X      and verify that the server can find them. 
  925. >X
  926. >X      Terminate this little session with the END command. 
  927. >X
  928. >X5.6   Adding aliases 
  929. >X
  930. >X      Create a suitable alias in /usr/lib/aliases (or wherever your 
  931. >X      aliases are kept): 
  932. >X
  933. >X            mail-server : "|LIBDIR/listener"
  934. >X
  935. >X      To get rid of bounced mail, the mail server fakes 'bit-bucket' as 
  936. >X      its return address. To avoid bounced mails filling your 
  937. >X      filesystems, add another alias: 
  938. >X
  939. >X            bit-bucket: /dev/null
  940. >X
  941. >X5.7   Verification of the installation 
  942. >X
  943. >X      All the following steps should be executed under the mail server 
  944. >X      owner! 
  945. >X
  946. >X      *  Verify your locking strategy. Execute 
  947. >X
  948. >X            % perl -s testlock.pl -test1 &
  949. >X
  950. >X         It should say "Got the lock -- waiting ...". Now execute 
  951. >X
  952. >X            % perl -s testlock.pl -test2 &
  953. >X
  954. >X         It should say "Good. Could not lock -- waiting ...". Now kill 
  955. >X         the first process. The second process should print "ret = 1" 
  956. >X         and exit. 
  957. >X
  958. >X      *  Verify the working of the 'dorequest' program: 
  959. >X
  960. >X            % LIBDIR/dorequest <youraddress> <arealfile>
  961. >X
  962. >X         You should receive mail(s) containing the indicated file. NOTE: 
  963. >X         If your site is running sendmail, the mail(s) are queued for 
  964. >X         delivery. They can take some time before they arrive, depending 
  965. >X         on how often the sendmail queue is run. You may want to inspect 
  966. >X         the sendmail queue to see if your mail(s) are in it. 
  967. >X
  968. >X         If no mail(s) arrive, try 
  969. >X
  970. >X            % LIBDIR/dorequest -debug <youraddress> <arealfile>
  971. >X
  972. >X         and see what happens. 
  973. >X
  974. >X      *  Create a text file containing the following lines: 
  975. >X
  976. >X            From bla
  977. >X            From: <youraddress>
  978. >X            
  979. >X            test
  980. >X            send HELP
  981. >X            end
  982. >X
  983. >X         Now execute the 'process' script by hand: 
  984. >X
  985. >X            % LIBDIR/process < text-file
  986. >X
  987. >X         (The program should terminate after processing the 'end' 
  988. >X         command). Now you should receive a mail (from yourself!) 
  989. >X         telling you that your request has been processed. 
  990. >X
  991. >X         NOTE: If your site is running sendmail, and sendmail is 
  992. >X         configured to use 'queued' delivery, the mail(s) are not 
  993. >X         delivered immediately. You may want to inspect the sendmail 
  994. >X         queue to see if your mail is in it, or run the queue by hand. 
  995. >X
  996. >X         In case of trouble: run LIBDIR/process with "-debug" to find 
  997. >X         out what happens. 
  998. >X
  999. >X      *  Execute the 'process' script again with the same input, but 
  1000. >X         remove the line "test" from the text file. 
  1001. >X
  1002. >X         Again you should receive a mail (from yourself!) telling that 
  1003. >X         your request has been processed. It should also tell you that 
  1004. >X         your request has been queued. 
  1005. >X
  1006. >X         If you configured $auto_runrequest, program 'dorequest' will be 
  1007. >X         run to handle your request. You should receive a mail with the 
  1008. >X         requested file. 
  1009. >X
  1010. >X         In case of trouble: run LIBDIR/process with "-debug" to find 
  1011. >X         out what happens. This will prevent 'dorequest' from being 
  1012. >X         invoked, so you can study the contents of LIBDIR/queue. 
  1013. >X
  1014. >X      *  Execute the 'listener' program with the same input. 
  1015. >X
  1016. >X         Again you should receive a mail message, but this time it 
  1017. >X         should be from the mail server owner. 
  1018. >X
  1019. >X         If you configured $auto_runrequest, program 'dorequest' will be 
  1020. >X         run to handle your request. You should receive a mail with the 
  1021. >X         requested file. 
  1022. >X
  1023. >X      *  As another user, run the 'listener' program with the same 
  1024. >X         input. 
  1025. >X
  1026. >X         Again you should receive a mail, still originating from the 
  1027. >X         mail server owner. 
  1028. >X
  1029. >X      *  Still going strong? Now, as another user, send a mail message 
  1030. >X         to your mail server: 
  1031. >X
  1032. >X            % mail mail-server
  1033. >X            send foo bar INDEX
  1034. >X            end
  1035. >X            ^D
  1036. >X
  1037. >X         (Mail programs usually do not terminate after reading the 'end' 
  1038. >X         line. Issue Control-D or whatever you local EndOfFile setting 
  1039. >X         is). 
  1040. >X
  1041. >X         You will receive a return mail, indicating which archive 
  1042. >X         entries were found, and how they would be transmitted. 
  1043. >X
  1044. >X      *  If you did not configure $auto_runrequest, change back to the 
  1045. >X         mail server user, and inspect LIBDIR/queue to see that your 
  1046. >X         request is in it. 
  1047. >X
  1048. >X         Run LIBDIR/dorequest without arguments; the selected file 
  1049. >X         should be sent to you by email or UUCP. 
  1050. >X
  1051. >X      If you receive the requests, your mail server is fully 
  1052. >X      operational! 
  1053. >X
  1054. >X      Likewise, you can test the correct functioning of delivery via 
  1055. >X      UUCP. 
  1056. >X
  1057. >X5.8   The logfile 
  1058. >X
  1059. >X      If you don't want to keep of log of transactions, remove the file 
  1060. >X      LIBDIR/logfile that was created by the Makefile. 
  1061. >X
  1062. >X      NOTE: This is strongly discouraged, since it will also disable the 
  1063. >X      delivery of error messages. 
  1064. >X
  1065. >X5.9   Helpfiles and other goodies 
  1066. >X
  1067. >X      As a service: place the files 'HELP' and 'unpack.pl' in one of 
  1068. >X      your archives. The Makefile prepares PUBDIR (defaults to 
  1069. >X      LIBDIR/pub) for this purpose. 
  1070. >X
  1071. >X      Also, supply shar-files with the btoa/atob handling programs, 
  1072. >X      uudecode/uuencode, and compress/uncompress. 
  1073. >X
  1074. >X      The contents of file LIBDIR/mserv.notes is prepended to every 
  1075. >X      reply the mail server sends. This file can be used to supply a 
  1076. >X      daily message about the server, new entries, etc. 
  1077. >X
  1078. >X      The contents of file LIBDIR/mserv.hints is appended to every reply 
  1079. >X      the mail server sends. 
  1080. >X
  1081. >X      Make sure your archives have a decent copy of Dumas uud/uue and 
  1082. >X      xxencode/xxdecode if you intent to support these. Likewise, zoo, 
  1083. >X      zip, etc. 
  1084. >X
  1085. >X      Also, provide a file 'INDEX' that more or less describes what is 
  1086. >X      in your archives. People are going to ask for it. 
  1087. >X
  1088. >X      Since people usually don't read the documentation, link 'help' to 
  1089. >X      'HELP', 'index' to 'INDEX', 'atob.shar' to 'btoa.shar', etc. 
  1090. >X
  1091. >X5.10  Daemon processes 
  1092. >X
  1093. >X      Install crontab entries for the mail server processes. A sample 
  1094. >X      crontab is included in the distribution as CRONTAB.sample. 
  1095. >X
  1096. >X            30 0,2,4,6,18,20,22 * * * LIBDIR/do_runq
  1097. >X            0 3 * * * LIBDIR/makeindex
  1098. >X            0 7 * * * LIBDIR/do_report -errors -since .errrun
  1099. >X            10 7 * * 7 LIBDIR/do_report -full -collect -ftp -ftpclean
  1100. >X
  1101. >X      The above example runs the mail server queue every two hours, 
  1102. >X      except during working hours. Once a day any mail server errors are 
  1103. >X      reported, once a week the logfile data is accumulated and a usage 
  1104. >X      report is generated. The FTP cache is reported and cleaned. 
  1105. >X
  1106. >X      CHECK AND MODIFY THESE SCRIPTS SINCE THEY WILL PROBABLY NOT DO 
  1107. >X      WHAT YOU WANT! 
  1108. >X
  1109. >X      Every night a three o'clock new index files are generated. You may 
  1110. >X      leave this line out if you do not use index files. 
  1111. >X
  1112. >X      If you configured $auto_runrequest in 'ms_common.pl', there is no 
  1113. >X      need to run the queue that often; once or twice a day will be 
  1114. >X      sufficient. 
  1115. >X
  1116. >X5.11  Let Me Know 
  1117. >X
  1118. >X      If you have implemented the mail server on your system, please let 
  1119. >X      me <jv@mh.nl> know so I can collect information about the 
  1120. >X      implementations. Also let me (and the net!) know what kind of 
  1121. >X      archives you are offering. 
  1122. >X
  1123. >X      And protect your and mine freedom to write programs: join the 
  1124. >X      League for Programming Freedom. 
  1125. >X
  1126. >X            League for Programming Freedom
  1127. >X            1 Kendall Square #143
  1128. >X            P.O.Box 9171
  1129. >X            Cambridge, Massachusetts 02139
  1130. >X            E-mail: league@prep.ai.mit.edu
  1131. >X
  1132. >X6.    ADVANCED TECHNIQUES 
  1133. >X
  1134. >X6.1   Extending the Mail Server command set 
  1135. >X
  1136. >X      Both the command parsing and execution are implemented using 
  1137. >X      dispatch tables to subroutines. As a result, it is very easy to 
  1138. >X      extend the Mail Server command set. 
  1139. >X
  1140. >X      In the configuration file, $cmd_extend can be defined to the name 
  1141. >X      of a (perl) file to load extensions. 
  1142. >X
  1143. >X      Mail Server extensions can be implemented as follows: 
  1144. >X
  1145. >X      1. Write a subroutine to parse the command. See 'pr_parse.pl' for 
  1146. >X         lots of examples. Any work should be pushed on the @workq. 
  1147. >X
  1148. >X      2. Add a command verb to $cmd_tbl, pointing to this routine. The 
  1149. >X         command verb must be in ALL UPPERCASE. 
  1150. >X
  1151. >X      3. Write a subroutine to execute the command. See 'pr_dowork.pl' 
  1152. >X         for lots of examples. 
  1153. >X
  1154. >X      4. Add a command verb to $exe_tbl, pointing to this routine. Since 
  1155. >X         the Mail Server uses uppercase letters for this purpose, please 
  1156. >X         use a lowercase letter or verb. 
  1157. >X
  1158. >X      5. Provide a short help message for the HELP command. 
  1159. >X
  1160. >X      As an example, the following code adds the 'REPORT' command to the 
  1161. >X      Mail Server. 
  1162. >X
  1163. >X            sub cmd_report {                         # step 1.
  1164. >X                # Check syntax.
  1165. >X                # $cmd is the command verb, upcased.
  1166. >X                # @cmd has the remainder of the command.
  1167. >X                return &errmsg ("Usage: $cmd") unless @cmd == 0;
  1168. >X            
  1169. >X                # Push exe command on work queue.
  1170. >X                push (@workq, &zp ('r'));
  1171. >X            
  1172. >X                # Feedback.
  1173. >X                print STDOUT ("=> Okay\n");
  1174. >X                1;
  1175. >X            }
  1176. >X            
  1177. >X            $cmd_tbl{'REPORT'} = 'cmd_report';       # step 2.
  1178. >X            
  1179. >X            sub exe_report {                         # step 4.
  1180. >X                &do_unix ("$libdir/report -usage");
  1181. >X                1;
  1182. >X            }
  1183. >X            
  1184. >X            $exe_tbl{'r'} = 'exe_report';            # step 4.
  1185. >X            
  1186. >X            &add_help ('REPORT',                     # step 5.
  1187. >X                'Generate a mail server usage report.');
  1188. >X
  1189. >X      The source distribution contains a number of extension examples, 
  1190. >X      look for the files ud_sample*.pl. 
  1191. >X
  1192. >X      NOTE:  Extending the Mail Server command set is not supported
  1193. >X             and is not garanteed to work in future releases.
  1194. >X             However, when implemented as described above, the impact
  1195. >X             of a new release will probably be small.
  1196. >X
  1197. >X6.2   Setting up multiple servers 
  1198. >X
  1199. >X      You can set up multiple servers sharing the same software. All 
  1200. >X      mail server programs support the command line option "-config" to 
  1201. >X      specify an alternate configuration file for the program. This file 
  1202. >X      can be used to select different archive directories. Depending on 
  1203. >X      your needs, you can share the logfile, lockfile and queuefile. 
  1204. >X      However, If you wish to share the queuefile, you *NEED* to share 
  1205. >X      the lockfile also. 
  1206. >X
  1207. >X      You can have multiple mail aliases, e.g.: 
  1208. >X
  1209. >X            mail-server : "|LIBDIR/listener"
  1210. >X            debug-server: "|LIBDIR/listener -trace"
  1211. >X            info-server : "|LIBDIR/listener -config LIBDIR/info_config.pl"
  1212. >X
  1213. >X      All I/O to queue and logfile is done while locking the file, so it 
  1214. >X      is not possible to get file corruption. The lockfile is used to 
  1215. >X      prevent multiple invokations of the delivery program, 'dorequest'. 
  1216. >X      But if you configure a common queue, you need to configure a 
  1217. >X      common lockfile too. 
  1218. >X
  1219. >X      The delivery program will deliver requests that are entered in the 
  1220. >X      queue. Who is going to receive what is totally determined by the 
  1221. >X      'process' program. So it is perfectly safe to have a single queue 
  1222. >X      for several flavours of the mail server. Once the information is 
  1223. >X      in the queue, it doesn't matter what program is going to deliver 
  1224. >X      it. 
  1225. >X
  1226. >X      NOTE: You need to build the listener program version 3.1 or later. 
  1227. >X
  1228. >X6.3   Setting up de Mail Server for Interactive Use 
  1229. >X
  1230. >X      If the program 'process' (or 'listener') is invoked with its input 
  1231. >X      to a terminal, it enters interactive mode. Commands can be typed 
  1232. >X      in and are executed immediately. Errors are not considered fatal. 
  1233. >X      Alternatively, interactive mode can be forced with the 
  1234. >X      "-interactive" command line option, and prohibited with "-noi". 
  1235. >X
  1236. >X      In interactive mode, the program displays a sign-on message, 
  1237. >X      followed by the contents of the $notesfile. However, if a file 
  1238. >X      exists with the name of the $notesfile followed by 'i', this file 
  1239. >X      is used instead. This way you can have different messages for 
  1240. >X      interactive and non-interactive use. 
  1241. >X
  1242. >X      In interactive mode, the $hintsfile, normally included at the end 
  1243. >X      of the feedback message, will be appended to the output of the 
  1244. >X      HELP command. If a file exists with the name of the $hintsfile 
  1245. >X      followed by 'i', this file is used instead. 
  1246. >X
  1247. >X6.3.1 Via login 
  1248. >X
  1249. >X      Add a login name to your system to be used for this purpose. 
  1250. >X      Supply a dummy HOME directory (e.g. /tmp), and specify 
  1251. >X      LIBDIR/listener for login shell. 
  1252. >X
  1253. >X6.3.2 Via inetd 
  1254. >X
  1255. >X      Choose a port to be used for this service, e.g. 2000. Add this 
  1256. >X      port to /etc/services: 
  1257. >X
  1258. >X            mserv   2000/tcp
  1259. >X
  1260. >X      Add the following line to the inet configuration file (usually 
  1261. >X      /etc/inetd.conf): 
  1262. >X
  1263. >X            mserv    stream tcp nowait LIBDIR/listener listener -i0
  1264. >X
  1265. >X      Depending on your system, you may have to insert a user-id after 
  1266. >X      'nowait'. Use whatever is appropriate. The listener program will 
  1267. >X      set UID anyway. 
  1268. >X
  1269. >X      The command line option "-i0" forces interactive mode, and 
  1270. >X      attaches standard output and error to standard input (file 
  1271. >X      descriptor 0). 
  1272. >X
  1273. >X7.    DESIGN AND MAINTENANCE OF THE ARCHIVES 
  1274. >X
  1275. >X      The mail server software can handle multiple archive directories. 
  1276. >X      Every directory specified in @libdirs is treated equal. 
  1277. >X
  1278. >X      Please consider the following points: 
  1279. >X
  1280. >X      *  Hidden files (filenames starting with '.') and files that are 
  1281. >X         not readable to 'mserv' cannot be retrieved. They might show in 
  1282. >X         the index, however. 
  1283. >X
  1284. >X      *  If a file occurs multiple (e.g. 'INDEX') in more than one 
  1285. >X         archive directory, the first occurrence is retrieved. 
  1286. >X
  1287. >X      *  If a directory occurs multiple it can not be retrieved. 
  1288. >X
  1289. >X      *  For best results: name archives similar to 'foo-XXX.tar.Z', 
  1290. >X         where XXX is a version number, e.g. emacs-18.58.tar.Z or 
  1291. >X         xdvi-12.zoo. This will aid people in finding the right version 
  1292. >X         for a specific archive entry. 
  1293. >X
  1294. >X8.    THE MAIL SERVER DISTRIBUTION 
  1295. >X
  1296. >X      This section lists the files in the mail server distribution, with 
  1297. >X      a short explanation. Note that lots of functions are contained in 
  1298. >X      separate files. These files are only loaded if needed, cutting 
  1299. >X      down on the system resources. 
  1300. >X
  1301. >X      README           A short introduction.
  1302. >X      ChangeLog        A log of changes. Relevant for developers only.
  1303. >X      INSTALL          The ASCII version of this document.
  1304. >X      ms_config.pl     Configuration file.
  1305. >X      ms_common.pl     Common information for the mail server constituents.
  1306. >X      process.pl       Perl script to parse mail messages, and to
  1307. >X                       enqueue the requests.
  1308. >X      pr_*.pl          Demand loadable modules for process.pl
  1309. >X      pr_doindex.pl    Index lookup (for INDEX command).
  1310. >X      pr_dowork.pl     Looking up files.
  1311. >X      pr_dsearch.pl    Directory searching (for SEND commands).
  1312. >X      pr_ftp.pl        FTP operations.
  1313. >X      pr_help.pl       HELP message.
  1314. >X      pr_isearch.pl    Index searching (for SEND commands).
  1315. >X      pr_parse.pl      Command parsing
  1316. >X      rfc822.pl        A package to process rfc822 based messages.
  1317. >X      ftp.pl           Modified version of Alan R. Martello's package
  1318. >X                       to deal with FTP.
  1319. >X      chat2.pl         Modified version of Randal Schwartz' chat2.
  1320. >X      dateconv.pl      Date conversions.
  1321. >X      dorequest.pl     Perl script to encode and split the files, and sent
  1322. >X                       them to the requester.
  1323. >X      dr_*.pl          Demand loadable modules for dorequest.pl
  1324. >X      dr_mail.pl       Sending files via email.
  1325. >X      dr_uucp.pl       Sending files via UUCP.
  1326. >X      dr_pack.pl       Packing directories before sending.
  1327. >X      ms_lock.pl       Portable file locking package
  1328. >X      unpack.pl        Perl script to unpack a concatenated series of parts.
  1329. >X      HELP             The ASCII version of the user guide.
  1330. >X      mlistener.pl     Generator for a simple wrapper around "process.pl"
  1331. >X                       to enable setuid processing.
  1332. >X      makeindex.pl     A simple script to aid in maintaining an index
  1333. >X                       of archive entries.
  1334. >X      chkconfig.pl     A tool to feed back on the configuration file.
  1335. >X      testlock.pl      A tool to test the locking package.
  1336. >X      report.pl        A tool to generate usage and error reports.
  1337. >X      do_report.pl     A script to use report.pl
  1338. >X      do_runq.sh       A shell script to run the mail server queue from cron.
  1339. >X      CRONTAB.sample   A sample cron tab for the mail server.
  1340. >X      mserv.notes      
  1341. >X      mserv.hints      
  1342. >X      mserv.hintsi     Sample files.
  1343. >X      ud_*.pl          Sample Mail Server extensions.
  1344. >X      ud_sample1.pl    'REPORT' command.
  1345. >X      ud_sample2.pl    'SEND CONFIG' command.
  1346. >X      ixlookup.patch   Patch to GNU find 3.5 'locate.c' to create
  1347. >X                       the index lookup program.
  1348. >X      Makefile         To install the package.
  1349. >X      patchlevel.h     Patch version check.
  1350. >X      MANIFEST         List of files.
  1351. >X
  1352. >X      Not included but also available are nicely formatted PostScript 
  1353. >X      versions of the User Guide and Installation Guide. To obtain them, 
  1354. >X      send a mail message to <mail-server@nluug.nl> with contents: 
  1355. >X
  1356. >X            begin
  1357. >X            send usrguide.ps.Z
  1358. >X            send mservmgr.ps.Z
  1359. >X            end
  1360. >END_OF_FILE
  1361. >  if test 52619 -ne `wc -c <'mserv-3.1/INSTALL'`; then
  1362. >    echo shar: \"'mserv-3.1/INSTALL'\" unpacked with wrong size!
  1363. >  fi
  1364. >  # end of 'mserv-3.1/INSTALL'
  1365. >fi
  1366. >if test -f 'mserv-3.1/dateconv.pl' -a "${1}" != "-c" ; then 
  1367. >  echo shar: Will not clobber existing file \"'mserv-3.1/dateconv.pl'\"
  1368. >else
  1369. >  echo shar: Extracting \"'mserv-3.1/dateconv.pl'\" \(1794 characters\)
  1370. >  sed "s/^X//" >'mserv-3.1/dateconv.pl' <<'END_OF_FILE'
  1371. >X# dateconv.pl -- date/time conmversions.
  1372. >X# SCCS Status     : @(#)@ dateconv.pl    1.2
  1373. >X# Last Modified By: Johan Vromans
  1374. >X# Last Modified On: Sat Dec  5 01:32:31 1992
  1375. >X# Update Count    : 1
  1376. >X# Status          : OK
  1377. >X
  1378. >X# Convert a date into a time.
  1379. >X
  1380. >Xsub lstime_to_standard
  1381. >X{
  1382. >X    local( $ls ) = @_;
  1383. >X
  1384. >X    return &time_to_standard( &lstime_to_time( $ls ) );
  1385. >X}
  1386. >X
  1387. >Xpackage dateconv;
  1388. >X
  1389. >Xrequire 'timelocal.pl';
  1390. >X
  1391. >X@months = ( "zero", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" );
  1392. >X
  1393. >X$month_num{ "Jan" } = 0;
  1394. >X$month_num{ "Feb" } = 1;
  1395. >X$month_num{ "Mar" } = 2;
  1396. >X$month_num{ "Apr" } = 3;
  1397. >X$month_num{ "May" } = 4;
  1398. >X$month_num{ "Jun" } = 5;
  1399. >X$month_num{ "Jul" } = 6;
  1400. >X$month_num{ "Aug" } = 7;
  1401. >X$month_num{ "Sep" } = 8;
  1402. >X$month_num{ "Oct" } = 9;
  1403. >X$month_num{ "Nov" } = 10;
  1404. >X$month_num{ "Dec" } = 11;
  1405. >X
  1406. >X( $mn, $yr ) = (localtime)[ 4, 5 ];
  1407. >X
  1408. >X# Convert an 'ls' type date string into a time
  1409. >Xsub main'lstime_to_time
  1410. >X{
  1411. >X    package dateconv;
  1412. >X
  1413. >X    local( $date ) = @_;
  1414. >X
  1415. >X    local( $mon, $day, $hours, $mins, $month, $year );
  1416. >X
  1417. >X    if( $date =~ /^(\w\w\w)\s+(\d+)\s+((\d\d\d\d)|((\d+):(\d+)))$/ ){
  1418. >X        ($mon, $day, $year, $hours, $mins) = ($1, $2, $4, $6, $7);
  1419. >X#print "(mon $mon, day $day, year $year, hours $hours, mins $mins)\n";
  1420. >X    }
  1421. >X    else {
  1422. >X        printf STDERR "invalid date $date\n";
  1423. >X        return time;
  1424. >X    }
  1425. >X    
  1426. >X    $month = $month_num{ $mon };
  1427. >X
  1428. >X    if( $year !~ /\d\d\d\d/ ){
  1429. >X        $year = $yr;
  1430. >X        $year-- if( $month > $mn );
  1431. >X    }
  1432. >X    if( $year > 1900 ){
  1433. >X        $year -= 1900;
  1434. >X    }
  1435. >X     
  1436. >X#print " &timegm( 0, $mins, $hours, $day, $month, $year );\n";
  1437. >X    return &timegm( 0, $mins, $hours, $day, $month, $year );
  1438. >X}
  1439. >X
  1440. >Xsub main'time_to_standard
  1441. >X{
  1442. >X    package dateconv;
  1443. >X
  1444. >X    local( $time ) = @_;
  1445. >X
  1446. >X    local( $sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst ) =
  1447. >X         gmtime( $time );
  1448. >X    return sprintf( "%2d $months[ $mon + 1 ] %2d %02d:%02d", $mday, $year, $hour, $min );
  1449. >X}
  1450. >X
  1451. >X1;
  1452. >END_OF_FILE
  1453. >  if test 1794 -ne `wc -c <'mserv-3.1/dateconv.pl'`; then
  1454. >    echo shar: \"'mserv-3.1/dateconv.pl'\" unpacked with wrong size!
  1455. >  fi
  1456. >  # end of 'mserv-3.1/dateconv.pl'
  1457. >fi
  1458. >echo shar: End of archive 1 \(of 6\).
  1459. >cp /dev/null ark1isdone
  1460. >MISSING=""
  1461. >for I in 1 2 3 4 5 6 ; do
  1462. >    if test ! -f ark${I}isdone ; then
  1463. >    MISSING="${MISSING} ${I}"
  1464. >    fi
  1465. >done
  1466. >if test "${MISSING}" = "" ; then
  1467. >    echo You have unpacked all 6 archives.
  1468. >    rm -f ark[1-9]isdone
  1469. >else
  1470. >    echo You still must unpack the following archives:
  1471. >    echo "        " ${MISSING}
  1472. >fi
  1473. >exit 0
  1474. >exit 0 # Just in case...
  1475.