home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume34 / mserv / part01 < prev    next >
Encoding:
Text File  |  1993-01-05  |  59.5 KB  |  1,462 lines

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