home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / ease3.5 / part05 < prev    next >
Encoding:
Internet Message Format  |  1991-12-09  |  34.2 KB

  1. Subject:  v25i021:  Ease 3.5 - high-level sendmail.cf language, Part05/06
  2. Newsgroups: comp.sources.unix
  3. Approved: vixie@pa.dec.com
  4.  
  5. Submitted-by: Bruce G. Barnett <barnett@crdgw1.ge.com>
  6. Posting-number: Volume 25, Issue 21
  7. Archive-name: ease3.5/part05
  8.  
  9. #! /bin/sh
  10. # This is a shell archive.  Remove anything before this line, then unpack
  11. # it by saving it into a file and typing "sh file".  To overwrite existing
  12. # files, type "sh file -c".  You can also feed this as standard input via
  13. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  14. # will see the following message at the end:
  15. #        "End of archive 5 (of 6)."
  16. # Contents:  doc/ease.paper
  17. # Wrapped by vixie@cognition.pa.dec.com on Tue Dec 10 08:45:58 1991
  18. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  19. if test -f 'doc/ease.paper' -a "${1}" != "-c" ; then 
  20.   echo shar: Will not clobber existing file \"'doc/ease.paper'\"
  21. else
  22. echo shar: Extracting \"'doc/ease.paper'\" \(32946 characters\)
  23. sed "s/^X//" >'doc/ease.paper' <<'END_OF_FILE'
  24. X...
  25. X... $Header: /tmp_mnt/home/kreskin/u0/barnett/Src/Ease/ease/doc/RCS/ease.paper,v 3.3 1991/09/09 16:36:05 barnett Exp $
  26. X... 
  27. X... $Log: ease.paper,v $
  28. X... Revision 3.3  1991/09/09  16:36:05  barnett
  29. X... minor bug fixes
  30. X...
  31. X... Revision 2.0  1990/01/30  12:50:44  jeff
  32. X... Baseline version, corresponding to netwide release 2.0.
  33. X...
  34. X... Revision 1.6  88/06/15  10:12:36  root
  35. X... Some editorial cleanup, added Acknowledgements section.
  36. X... 
  37. X... Revision 1.5  88/01/21  17:19:35  root
  38. X... Several editorial changes. ADR.
  39. X... 
  40. X... Revision 1.4  87/12/23  11:30:47  root
  41. X... Updated list of authors. Documented extended canon() capability.
  42. X... Integrated fluke changes in a little better. ADR.
  43. X... 
  44. X... Revision 1.3  87/11/04  11:33:45  root
  45. X... Documented new keyword "while" which is equivalent to "if". ADR.
  46. X... 
  47. X... Revision 1.2  87/08/13  17:08:05  root
  48. X... Changes from Jeff Stearns, fluke!jeff, for Sun. ADR.
  49. X... 
  50. X... Revision 1.1  87/08/13  17:05:00  root
  51. X... Initial revision
  52. X... 
  53. X...
  54. X.LP
  55. X.TL
  56. XEase: A Configuration Language
  57. for Sendmail
  58. X.AU
  59. James S. Schoner
  60. X.AI
  61. Purdue University Computing Center
  62. West Lafayette, Indiana  47907
  63. X.AU
  64. Jeff P. Stearns
  65. X.AI
  66. John Fluke Manufacturing Company
  67. XEverett, Washington  98206
  68. X.AU
  69. Arnold D. Robbins
  70. X.AI
  71. XEmory University Computing Center
  72. Atlanta, Georgia  30322
  73. X.AU
  74. Bruce G. Barnett
  75. X.AI
  76. General Electric Corporate Research and Development
  77. Schenectady, NY 12301
  78. X.sp 2
  79. X.I
  80. X.ce
  81. ABSTRACT
  82. X.R
  83. X.PP
  84. The rapid expansion of computer networks and ensuing variation among mailing
  85. address formats have made address interpretation an increasingly
  86. complex task.  In the UNIX* 4.2BSD operating system, a program named 
  87. X\fIsendmail\fR was introduced which provided a
  88. general internetwork mail routing facility.  This facility has significantly
  89. diminished the complexity of handling address interpretation.
  90. X.PP
  91. X\fISendmail\fR's address interpretation is based on a rewriting
  92. system composed of
  93. a number of rewriting rules (or productions) arranged as part of a 
  94. configuration file.  Unfortunately, the syntactical format of a
  95. configuration file for \fIsendmail\fR is both terse and rigid, making it
  96. rather difficult to modify.  The standard format certainly serves its 
  97. purpose, but, as 
  98. the need to change these configurations increases in frequency, a more 
  99. readable format (i.e., one that is similar to the format 
  100. of modern programming languages) is required to permit reasonably 
  101. quick modifications to the configuration.  As a solution to this problem, 
  102. X\fBEase\fR 
  103. provides a level of abstraction which eliminates most of the current
  104. syntactic hindrances
  105. faced by programmers who must reconfigure \fIsendmail\fR's 
  106. address parsing scheme.  
  107. X.PP
  108. As a high-level specification format, \fBEase\fR is proving to be an 
  109. excellent alternative to \fIsendmail\fR's cryptic 
  110. configuration file syntax.  The syntactic structures of \fBEase\fR 
  111. are patterned after modern language constructs, making the language
  112. easy to learn and easy to remember.  The format of the address rewriting
  113. rule is perhaps the most significant syntactical improvement.  It was 
  114. undoubtedly
  115. the most needed improvement.  Nevertheless, every element of a configuration 
  116. file is structurally enhanced through the use of \fBEase\fR. 
  117. X.FS
  118. X*  UNIX is a registered trademark of AT&T.
  119. X.FE
  120. X.sp 2
  121. X.NH
  122. Introduction
  123. X.PP
  124. The \fBEase\fR language is a high-level specification format for \fIsendmail\fR's
  125. configuration file.  The motivation for its development
  126. was to fulfill a goal of providing a readable and easily modifiable 
  127. X\fIsendmail\fR configuration file format.  \fBEase\fR fulfills this goal by
  128. shielding the programmer from the cryptic configuration specification required
  129. by \fIsendmail\fR and providing a high-level language with which the programmer
  130. may specify all modifications to a configuration file.  The development 
  131. of Ease coincided with
  132. the development of an \fBEase\fR translator, \fIet\fR,
  133. which translates a configuration file written 
  134. in \fBEase\fR to an
  135. equivalent file of the standard format accepted by \fIsendmail\fR.
  136. X.NH
  137. XEase in Profile
  138. X.PP
  139. As will be seen in the next section, the syntax of \fBEase\fR is quite
  140. readable and easy to learn.  
  141. In order to acquire a relevant perspective
  142. on this issue,
  143. the reader is advised to examine a raw configuration file for \fIsendmail\fR (the 
  144. output
  145. of the \fBEase\fR translator, \fIet\fR, will do nicely).  The raw syntax, while
  146. quite fitting for quick translation, can prove to be a programmer's nightmare.  
  147. X.PP
  148. It is recommended that you learn \fBEase\fP by converting your current
  149. configuration file into \fBEase\fP format by using the program
  150. X\fIcfc\fP written by Arnold Robbins and modified by Bruce G. Barnett.
  151. X.PP
  152. Undoubtedly, one of the more prominent features of \fBEase\fR is the ability 
  153. to attach
  154. names to address fields.  When address field names are well-chosen, a distinct,
  155. self-documenting quality becomes a visible part of the address rewriting 
  156. rules.  Ostensibly, address field names provide a new level of semantic 
  157. abstraction.  A brief comparison of the formats can be accomplished by examining
  158. the following equivalent representations of an address pattern:
  159. X.DS
  160. X    user_path@host_name            (\fBEase\fR format)
  161. X    $+@$-                    (raw format)
  162. X.DE
  163. In the above, \*Quser_path\*U represents a field of one or more address
  164. tokens, and \*Qhost_name\*U represents one address token exactly.  These
  165. token fields are represented by \*Q$+\*U and \*Q$-\*U in the raw format.  Clearly, 
  166. the \fBEase\fR format is preferable, not only for increased readability, but 
  167. structural comprehension as well.
  168. X.PP
  169. Other features of \fBEase\fR include ruleset naming, long identifiers for 
  170. macros and classes, flow-of-control structures, and free formatting.  In
  171. addition, it supports C language preprocessor (cpp) commands, which can be used for file inclusion
  172. and conditionally defined code constructs.  The next section describes
  173. the \fBEase\fR language in complete detail.
  174. X.NH
  175. XEase Syntax*
  176. X.FS
  177. X*  \fINo attempt is made to describe the complete semantic meaning 
  178. associated with all of the constructs of a sendmail configuration file.  Items 
  179. not covered in this document include the semantic distinction among rulesets, 
  180. the special uses of
  181. pre-defined macros, and the method of building configuration files.  To
  182. obtain this information, the reader is advised to refer to
  183. the Sendmail Installation and Operation Guide (SMM:7 in the 4.3 BSD
  184. UNIX System Manager's Manual),
  185. by Eric Allman.\fR
  186. X.FE
  187. X.PP
  188. At its highest level, \fBEase\fR can be viewed as a collection of 
  189. block-structures, where each block begins with a keyword and is followed by
  190. zero or more related definitions and/or declarations.  There are ten distinct 
  191. block types.  The following is 
  192. a list containing all ten block keywords and the block type it denotes.
  193. X.TS
  194. center;
  195. l l .
  196. X\fIbind\fR    -ruleset identifier bindings
  197. X\fImacro\fR    -macro definitions
  198. X\fIclass\fR    -class definitions
  199. X\fIoptions\fR    -\fIsendmail\fR option definitions
  200. X\fIprecedence\fR    -precedence definitions
  201. X\fItrusted\fR    -trusted users
  202. X\fIheader\fR    -mail header definitions
  203. X\fImailer\fR    -mailer definitions
  204. X\fIfield\fR    -address field definitions
  205. X\fIruleset\fR    -address rewriting rules
  206. X.TE
  207. X.sp 1
  208. In general,
  209. X.TS
  210. center ;
  211. l .
  212. X
  213. X* Letters are distinguished by case,
  214. X
  215. T{
  216. X* An \fBEase\fR identifier is defined to be a letter, followed by zero or 
  217. more letters, digits, underscores (_), or dashes (-),
  218. T}
  219. X
  220. T{
  221. X* A literal newline or double quotation (") character may be included in 
  222. any quoted string by preceding the character with a backslash (\\\\\), and
  223. T}
  224. X
  225. T{
  226. X* \fBEase\fR source is preprocessed by the C language preprocessor (cpp)
  227. if the program is executed with an option understood by cpp.
  228. Thus source comments (i.e., text enclosed by \*Q/*\*U and \*Q*/\*U) may appear 
  229. anywhere as part of \fBEase\fR whitespace.
  230. T}
  231. X.TE
  232. X.PP
  233. XFor notational convenience, this document specifies all reserved
  234. words of the \fBEase\fR language in italics.  In addition, quantities
  235. enclosed in angle brackets (<..>) represent arbitrary 
  236. identifiers, strings, or numbers.  
  237. X.NH 2
  238. Ruleset Identifier Bindings
  239. X.PP
  240. A ruleset (a set of rewriting rules) is identified solely by an integer 
  241. in \fIsendmail\fR's
  242. configuration file.  \fBEase\fR, however, allows each ruleset to be named with
  243. a meaningful identifier.  Since a special numeric association for each 
  244. ruleset is required by the address parsing scheme of \fIsendmail\fR, a \fIbind\fR
  245. block must be present in any \fBEase\fR file which defines one or more 
  246. rulesets.  A
  247. X\fIbind\fR block consists of the keyword \fIbind\fR, followed by zero or more
  248. statements of the form:
  249. X.TS
  250. center box;
  251. l .
  252. X<ruleset-id> = \fIruleset\fR <ruleset-number> ;
  253. X.TE
  254. The following example, 
  255. X.sp 1
  256. X\fIbind\fR
  257. X.PP
  258. XFINAL_RW = \fIruleset\fR 4;
  259. X.sp 1
  260. specifies that FINAL_RW, the final rewriting ruleset, is \fIsendmail\fR's ruleset 
  261. number 4.
  262. X.NH 2
  263. Macro Definitions
  264. X.PP
  265. A macro is an identifier which, when referenced in the text of a program,
  266. is replaced by its value, a string of zero or more characters.  The value
  267. of a macro may include references to other macros, but not itself!  \fISendmail\fR
  268. allows a maximum of 26 user-declared macros in its configuration file.  In 
  269. addition, there are a number of pre-declared macros which have special meaning
  270. to \fIsendmail\fR (see Appendix A).  \fBEase\fR macros are defined in 
  271. X\fImacro\fR blocks.  \fBEase\fR allows any macro to be declared 
  272. X(which is equivalent to simply referencing it) before it is defined.  A macro
  273. identifier is replaced by its value when it is preceded by the character
  274. X\*Q$\*U.  In addition, a macro reference inside a quoted string must always 
  275. include braces ({}) around the macro identifier (for delimiting purposes).  
  276. X.PP
  277. A \fImacro\fR block consists of the keyword \fImacro\fR, followed by zero
  278. or more statements taking either of the following forms:
  279. X.TS
  280. center box;
  281. l .
  282. X<macro-identifier> = "<macro-value>" ;
  283. X<macro-identifier> = \fBconditional-expression\fR ;
  284. X.TE
  285. The \fBconditional-expression\fR format will be discussed 
  286. later.  
  287. X.sp 1
  288. The following example,
  289. X.sp 1
  290. X\fImacro\fR
  291. X.PP
  292. first_name = "James";
  293. X.PP
  294. last_name = "Schoner";
  295. X.PP
  296. whole_name = "${first_name} ${last_name}";
  297. X.sp 1
  298. defines the macros first_name, last_name, and whole_name, where whole_name
  299. is the string, "James Schoner".
  300. X.NH 2
  301. Class definitions
  302. X.PP
  303. A class is denoted by an identifier representing a logical grouping of zero 
  304. or more names.  Classes are used to represent the range of values a token
  305. may assume in the pattern matching of an address.  Further discussion on the
  306. use of classes will be deferred until address fields are described.
  307. X.PP
  308. One identifier may be used to distinctly represent both a macro
  309. and class (i.e., the set of macro identifiers and the set of class identifiers
  310. may form a non-empty intersection).  A name, or class element, may 
  311. be an identifier or any quoted word.
  312. X.PP
  313. A \fIclass\fR block consists of the keyword \fIclass\fR, followed by zero
  314. or more statements taking any of the following forms:
  315. X.TS
  316. center box;
  317. l .
  318. X<class-identifier> = { <name1>, <name2>, <name3>, ... } ;
  319. X<class-identifier> = \fIreadclass\fR ( "<file-name>" ) ;
  320. X<class-identifier> = \fIreadclass\fR ( "<file-name>", "<read-format>" ) ;
  321. X.TE
  322. The second and third forms cause \fIsendmail\fR to read the names of the class 
  323. from the named
  324. file.  The third form contains a read format, which should be a \fIscanf\fR(3)
  325. pattern yielding a single string.
  326. X.sp 1
  327. The following example,
  328. X.sp 1
  329. X\fIclass\fR
  330. X.PP
  331. campus_hosts = { statistics, engineering, chemistry, physics, physics-2 } ;
  332. X.PP
  333. versions     = { "1.0", "1.1", "4.0", "4.2", latest-and-greatest } ;
  334. X.PP
  335. phone_hosts  = \fIreadclass\fR ( "/tmp/phonenet.list" ) ;
  336. X.sp 1
  337. defines the classes campus_hosts, versions, and phone_hosts.
  338. X.NH 2
  339. Sendmail option definitions
  340. X.PP
  341. A number of options to the \fIsendmail\fR program may be specified in 
  342. an \fIoptions\fR
  343. block.  For a description of the various \fIsendmail\fR options and their 
  344. values, see Appendix B.  
  345. X.PP
  346. An
  347. X\fIoptions\fR block consists of the keyword \fIoptions\fR, followed by zero
  348. or more statements taking any of the following forms:
  349. X.TS
  350. center box;
  351. l l .
  352. X<option-identifier>    = "<option-value>" ;
  353. X\fIo_delivery\fR    = \fBspecial-value\fR ;
  354. X\fIo_handling\fR    = \fBspecial-value\fR ;
  355. X.TE
  356. All but two options (\fIo_delivery\fR and \fIo_handling\fR) use the first 
  357. form.  To specify an option without a value, simply assign to it the null 
  358. string ("").  The \fBspecial-value\fR field of the second and third form
  359. refers to special values (non-quoted) which are specified in Appendix B.
  360. X.sp 1
  361. The following example,
  362. X.sp 1
  363. X\fIoptions\fR
  364. X.PP
  365. X\fIo_alias\fR = "/usr/lib/aliases" ;
  366. X.PP
  367. X\fIo_tmode\fR = "0600" ;
  368. X.PP
  369. X\fIo_delivery\fR = \fId_background\fR ;
  370. X.sp 1
  371. sets the options \fIo_alias\fR, \fIo_tmode\fR, and \fIo_delivery\fR.
  372. X.NH 2
  373. Precedence definitions
  374. X.PP
  375. Message headers may contain a \*QPrecedence:\*U field describing the precedence
  376. of the message class.  Identifiers which may appear in the precedence field of
  377. a message are given precedence values in a configuration file \fIprecedence\fR 
  378. definition.  This association will be illustrated below in an example.
  379. X.PP
  380. A \fIprecedence\fR block consists of the keyword \fIprecedence\fR, followed 
  381. by zero or more statements of the form:
  382. X.KS
  383. X.TS
  384. center box;
  385. l .
  386. X<precedence-identifier> = <precedence-integer> ;
  387. X.TE
  388. X.KE
  389. The following example,
  390. X.sp 1
  391. X\fIprecedence\fR
  392. X.PP
  393. special-delivery = 100;
  394. X.PP
  395. junk = -100;
  396. X.sp 1
  397. defines the precedence level for the names \*Qspecial-delivery\*U and 
  398. X\*Qjunk\*U.  Thus, whenever the name \*Qjunk\*U appears in 
  399. a \*QPrecedence:\*U field, the corresponding message class will be set to -100.
  400. X.NH 2
  401. Trusted users
  402. X.PP
  403. X\fISendmail\fR's \fB\-f\fR flag allows trusted users to override the sender's
  404. machine address.  Trusted users are listed in \fItrusted\fR blocks.  A 
  405. X\fItrusted\fR block consists of the keyword \fItrusted\fR, followed 
  406. by zero or more sets of users taking the form:
  407. X.TS
  408. center box;
  409. l .
  410. X{ <user1>, <user2>, <user3>, ... } ;
  411. X.TE
  412. The following example,
  413. X.sp 1
  414. X\fItrusted\fR
  415. X.PP
  416. X{ root, uucp, network } ;
  417. X.PP
  418. X{ acu, kcs, jss } ;
  419. X.sp 1
  420. specifies that the users root, uucp, network, acu, kcs, and jss can be trusted 
  421. to use the \fIsendmail\fR flag, \fB\-f\fR.
  422. X.NH 2
  423. Mail header definitions
  424. X.PP
  425. The format of the message headers inserted by \fIsendmail\fR is defined in one
  426. or more \fIheader\fR blocks in the configuration file.  A \fIheader\fR block
  427. consists of the keyword \fIheader\fR, followed by zero or more statements
  428. taking any of the following forms:
  429. X.TS
  430. center box;
  431. l
  432. l
  433. l
  434. l
  435. l
  436. l
  437. l
  438. l
  439. l
  440. l .
  441. X\fIfor\fR ( <mailer-flag1>, <mailer-flag2>, ... )
  442. X       \fIdefine\fR ( "<header-title>" , \fBheader-value\fR ) ;
  443. X
  444. X\fIfor\fR ( <mailer-flag1>, <mailer-flag2>, ... ) {
  445. X       \fIdefine\fR ( "<header-title>" , \fBheader-value\fR ) ;
  446. X       \fIdefine\fR ( "<header-title>" , \fBheader-value\fR ) ;
  447. X       .
  448. X       .
  449. X} ;
  450. X
  451. X\fIdefine\fR ( "<header-title>" , \fBheader-value\fR ) ;
  452. X.TE
  453. The first form is used to define one header for one or more mailer
  454. flags.  The second form differs from the first in that more than one
  455. header may be defined for a given set of flags.  The third form is used to 
  456. define a header,
  457. regardless of mailer flags.  Refer to Appendix C for a list of \fBEase\fR 
  458. identifiers representing mailer flags.  The header title is a simple
  459. string of characters (no macro references), whereas the \fBheader-value\fR
  460. is a series of one or more strings and
  461. X\fBconditional-expressions\fP (discussed later).
  462. Concatenation is implicit (as in \fIawk\fP).
  463. X.sp 1
  464. The following example,
  465. X.DS
  466. X\fIheader\fR
  467. X
  468. X    \fIdefine\fR ( "Subject:", "") ;
  469. X
  470. X    \fIfor\fR ( \fIf_return\fR )
  471. X        \fIdefine\fR ( "Return-Path:", "<${\fIm_sreladdr\fR}>" ) ;
  472. X
  473. X    \fIfor\fR ( \fIf_date\fR ) {
  474. X        \fIdefine\fR ( "Resent-Date:", "${\fIm_odate\fR}" ) ;
  475. X        \fIdefine\fR ( "Date:", "${\fIm_odate\fR}" );
  476. X    } ;
  477. X.DE
  478. defines a \*QSubject\*U field for all mailers, regardless of their flags, a
  479. X\*QReturn-Path\*U field for mailers whose definition specifies
  480. the flag, \fIf_return\fR, and the headers, \*QResent-Date\*U and \*QDate\*U,
  481. for mailers whose definition specifies the flag, \fIf_date\fR.
  482. X.NH 2
  483. Mailer Definitions
  484. X.PP
  485. X\fISendmail\fR's definition of a mailer (or an interface to one) occurs in a
  486. X\fImailer\fR block.  A \fImailer\fR block consists of the keyword \fImailer\fR,
  487. followed by zero or more statements of the form:
  488. X.TS
  489. center box;
  490. l .
  491. X<mailer-identifier> { \fBmailer-spec\fR } ;
  492. X.TE
  493. The field, \fBmailer-spec\fR, is a list of zero or more of the
  494. following attribute assignments (where successive assignment statements are
  495. separated by commas):
  496. X.TS
  497. center ;
  498. l l 
  499. l l
  500. l l
  501. l l
  502. l l
  503. l l
  504. l l .
  505. X\fIPath\fR    = \fBstring-attribute\fR
  506. X\fIArgv\fR    = \fBstring-attribute\fR
  507. X\fIEol\fR    = \fBstring-attribute\fR
  508. X\fIMaxsize\fR    = \fBstring-attribute\fR
  509. X\fIFlags\fR    = { <mailer-flag1>, <mailer-flag2>, ... } 
  510. X\fISender\fR    = <sender-ruleset-id>
  511. X\fIRecipient\fR    = <recipient-ruleset-id>
  512. X.TE
  513. The \fBstring-attribute\fR value can take the form of a quoted string
  514. X(possibly containing macro references) or a \fBconditional-expression\fR 
  515. X(discussed later).
  516. X.sp 1
  517. The following example,
  518. X.sp 1
  519. X\fImailer\fR
  520. X.DS
  521. X    local {
  522. X        \fIPath\fR        = "/bin/mail",
  523. X        \fIFlags\fR        = { \fIf_from\fR, \fIf_locm\fR },
  524. X        \fISender\fR    = Sender_RW,
  525. X        \fIRecipient\fR    = Recip_RW,
  526. X        \fIArgv\fR        = "mail -d ${\fIm_ruser\fR}",
  527. X        \fIMaxsize\fR    = "200000"
  528. X    } ;
  529. X.DE
  530. defines a mailer named \*Qlocal\*U.
  531. X.NH 2
  532. Address field definitions
  533. X.PP
  534. X\fISendmail\fR's address parsing scheme treats an address as a group of tokens
  535. X(an address token is precisely defined in the Arpanet protocol RFC822).  In
  536. general, \fIsendmail\fR divides an address into tokens based on a list of
  537. characters assigned as a string to the special macro \fIm_addrops\fR.  These
  538. characters will individually be considered as tokens and will separate tokens
  539. when parsing is performed. 
  540. X.PP
  541. XFor
  542. the \fBEase\fR language, there is a distinct set of address tokens (defined
  543. below) which are used in combination to represent generic forms of 
  544. addresses.  In 
  545. addition to literal address tokens, the pattern to be matched in a rewriting 
  546. rule (often referred to as the LHS) may
  547. include field identifiers which match one of five possibilities:
  548. X.DS
  549. X    - zero or more tokens
  550. X    - one or more tokens
  551. X    - one token exactly
  552. X    - one token which is an element of an arbitrary class \fBX\fR
  553. X    - one token which is not an element of an arbitrary class \fBX\fR
  554. X.DE
  555. A particular field type may be assigned to one or more identifiers.  Each
  556. field identifier is associated with (or defined to be) a field type in
  557. a \fIfield\fR declarations block.  A \fIfield\fR declarations block consists
  558. of the keyword \fIfield\fR, followed by zero or more field definitions of
  559. the form:
  560. X.TS
  561. center box;
  562. l .
  563. X\fBfield-id-list\fR : \fBfield-type\fR ;
  564. X.TE
  565. A \fBfield-id-list\fR is a list of one or more identifiers, each separated by
  566. a comma.  A \fBfield-type\fR, on the other hand, is a representation of 
  567. one of the five fields 
  568. described above.  The syntax for each of the five forms follows:
  569. X.DS
  570. X    \fImatch\fR ( 0* )
  571. X    \fImatch\fR ( 1* )
  572. X    \fImatch\fR ( 1 )
  573. X    \fImatch\fR ( 1 ) \fIin\fR <class-X>
  574. X    \fImatch\fR ( 0 ) \fIin\fR <class-X>
  575. X.DE
  576. The star in the first two forms means: "or more".  Thus, the first
  577. form would read: "match zero or more tokens".  The fourth form describes
  578. a field where one token is matched from an arbitrary class (class-X), whereas
  579. the fifth form describes a field where one token is matched if it is not of the
  580. given class (class-X).
  581. X.sp 1
  582. In addition, the Sun release 3.0 version of \fIsendmail\fR supports several
  583. new pattern matching operations represented by the following forms:
  584. X.DS
  585. X    \fImatch\fR ( 0 ) \fImap\fR <macro-identifier-X>
  586. X    \fImatch\fR ( 1 ) \fImap\fR <macro-identifier-X>
  587. X    \fImatch host\fR
  588. X.DE
  589. The macro \*Qmacro-identifier-X\*U should be assigned the name of the
  590. relevant YP map.
  591. X.sp 1
  592. The following example,
  593. X.sp 1
  594. X.DS
  595. X\fIfield\fR
  596. X    anypath        : \fImatch\fR ( 0* );
  597. X    recipient_host    : \fImatch\fR ( 1 );
  598. X    local_site        : \fImatch\fR ( 1 ) \fIin m_sitename\fR;
  599. X    remote_site        : \fImatch\fR ( 0 ) \fIin m_sitename\fR;
  600. X.DE
  601. defines the fields anypath, recipient_host, local_site, and remote_site.
  602. X.NH 2
  603. Address rewriting rules
  604. X.PP
  605. Address rewriting rules are grouped according to the function they perform.  For
  606. example, it is desirable to form a distinct group for those rewriting rules 
  607. which perform transformations on recipient addresses.
  608. X.PP
  609. Sets of rewriting rules are defined in \fIruleset\fR blocks.  A \fIruleset\fR
  610. block consists of the keyword \fIruleset\fR, followed by zero or more
  611. ruleset definitions of the form:
  612. X.TS
  613. center box;
  614. l .
  615. X<ruleset-id> { <rewriting-rule1> <rewriting-rule2> ... }
  616. X.TE
  617. The ruleset identifier, ruleset-id, must be defined in a \fIbind\fR block, as
  618. described earlier.  The rewriting rules have the form:
  619. X.DS
  620. X    \fIif\fR ( <match-pattern> )
  621. X        <match-action> ( <rewriting-pattern> ) ;
  622. X.DE
  623. where match-pattern, rewriting-pattern, and match-action are described below.
  624. An alternative form is available:
  625. X.DS
  626. X    \fIwhile\fR ( <match-pattern> )
  627. X        <match-action> ( <rewriting-pattern> ) ;
  628. X.DE
  629. which is somewhat more useful when the \*Qmatch-action\*U is \fIretry\fP
  630. X(see below).
  631. X.NH 3
  632. Match-patterns
  633. X.PP
  634. A match-pattern is a sequence of Ease address elements representing an
  635. address format.  If the address being rewritten matches the pattern
  636. X\*Qmatch-pattern\*U,
  637. then the address is reformatted using the pattern \*Qrewriting-pattern\*U, and 
  638. the corresponding
  639. action (\*Qmatch-action\*U) is performed.  The five distinct Ease address
  640. elements which may constitute a match-pattern are as follows:
  641. X.TS
  642. center ;
  643. l .
  644. X1. Field Identifiers (refer to previous section)
  645. T{
  646. X2. Non-alphanumeric characters (the exception is the case for literal 
  647. double quotes, which must be preceded by a backslash (\\\\\)
  648. T}
  649. X3. Macro references
  650. X4. Quoted strings ("...")
  651. X5. \fBConditional-expressions\fR (discussed later)
  652. X.TE
  653. Below are two sample match-patterns, each describing the same address format:
  654. X.DS
  655. X    user-id @ hostname . $arpa_suffix
  656. X    user-id @ hostname ".ARPA"
  657. X.DE
  658. where user-id and hostname are field identifiers, and arpa_suffix is a 
  659. user-defined macro with the value \*QARPA\*U.
  660. X.NH 3
  661. Rewriting-patterns
  662. X.PP
  663. A rewriting-pattern specifies the form in which to rewrite a matched 
  664. address.  The seven distinct elements which may be used to form 
  665. a rewriting-pattern are as follows:
  666. X.TS
  667. center ;
  668. l .
  669. X
  670. T{
  671. X1. Non-alphanumeric characters (the exception is the case for literal
  672. double quotes, left parentheses, or right parentheses, each of which 
  673. must be preceded by a backslash (\\\\\). 
  674. T}
  675. X
  676. T{
  677. X2. A call to another ruleset.  This is used to perform rewrites
  678. on a suffix of the rewriting-pattern.  The proper use of this
  679. feature will be demonstrated by example below. 
  680. T}
  681. X
  682. X3. Quoted strings ("...").
  683. X
  684. X4. \fBConditional-expressions\fR (discussed later).
  685. X
  686. X5. A macro reference.
  687. X
  688. T{
  689. X6. A positional reference in the matched address.  A positional 
  690. reference takes the form: $<integer-position>.  For example, 
  691. X$3 references the value of the third \fBEase\fR address 
  692. element in the matched address.
  693. T}
  694. X
  695. T{
  696. X7. Canonicalized host names of the form \fIcanon\fR (<id-token-list>),
  697. where \*Qid-token-list\*U is a list of one or more \*Qid-tokens.\*U
  698. An \*Qid-token\*U is a regular identifier, a quoted identifier (with
  699. double quotes), a macro reference yielding an identifier,
  700. a numeric internet specification (see below),
  701. a literal character (such as a \*Q.\*U or a \*Q[\*U), or a 
  702. positional reference in the matched address.  The canonicalization of 
  703. a host name is simply a mapping to its canonical (or official) form.
  704. T}
  705. X
  706. X.TE
  707. Below are two sample rewriting-patterns:
  708. X.DS
  709. X    $1 % $2 < @ $3 ".ARPA" >
  710. X    OLDSTYLE_RW ( $1 )
  711. X.DE
  712. The first form specifies an address such as a%b<@c.ARPA>, where a, b, and c
  713. represent matched identifiers or paths.  The second form specifies a call to
  714. the ruleset \*QOLDSTYLE_RW\*U, for old-style rewriting on the parameter 
  715. X$1, which probably references the entire matched address.  This will become 
  716. clear in later examples.
  717. X.NH 3
  718. Match-actions
  719. X.PP
  720. When a ruleset is called, the address to be rewritten is compared (or matched)
  721. sequentially against the match-address of each rewriting rule.  When a
  722. match-address describes the address \fIsendmail\fR is attempting to rewrite, the
  723. address is rewritten (or reformatted) using the rule's 
  724. rewriting-pattern.  Following this rewrite, the corresponding match-action
  725. is performed.  There are four match-actions:
  726. X.TS
  727. center ;
  728. l l .
  729. X\fIretry\fR    T{
  730. X-a standard action which causes the rewritten address
  731. to be again compared to the match-address of the current rule. 
  732. T}
  733. X
  734. X\fInext\fR    T{
  735. X-an action which causes the rewritten address to be
  736. compared to the match-address of the next rewriting rule of the current 
  737. ruleset.  If the end of the list is reached, the ruleset returns the 
  738. rewritten address.
  739. T}
  740. X
  741. X\fIreturn\fR    T{
  742. X-an action which causes an immediate return of the 
  743. ruleset with the current rewritten address.
  744. T}
  745. X
  746. X\fIresolve\fR    T{
  747. X-an action which specifies that the address has been
  748. completely resolved (i.e., no further rewriting is necessary).  The 
  749. X\fIresolve\fR action is described in more detail below. 
  750. T}
  751. X.TE
  752. X.PP
  753. The match-action, \fIresolve\fR, is special in that it terminates
  754. the address rewriting altogether.  The semantic structure of \fIsendmail\fR's
  755. rewriting scheme requires that a \fIresolve\fR action appear only in the 
  756. ruleset whose numerical binding is to the number zero.  The \fIresolve\fR action
  757. must specify three parameters: \fImailer\fR, \fIhost\fR, and \fIuser\fR.  If
  758. the \fImailer\fR is local, the \fIhost\fR parameter may be omitted.  The
  759. X\fImailer\fR argument must be specified as a single word, macro, or positional
  760. reference in the matched address.  The \fIhost\fR argument may be specified as 
  761. a single word or as an expression which expands to a single word (e.g.,
  762. X\fIhost\fR ($1 ".ARPA")).  In addition, the \fIhost\fR argument may be a
  763. canonicalization (as described above) or a numeric internet specification.  The
  764. keyword \fIhostnum\fR is used for numeric internet specifications, as in 
  765. X\fIhostnum\fR ("128.61.1.1") or \fIhostnum\fR ( $2 ).  The \fIuser\fR 
  766. specification is a rewriting-pattern, as described above.  
  767. X.PP
  768. In general, the format of a \fIresolve\fR action will be as follows:
  769. X.DS
  770. X    \fIresolve\fR (    \fImailer\fR ( <mailer-name> ),
  771. X            \fIhost\fR   ( <host-name> ),
  772. X            \fIuser\fR   ( <user-address>)   );
  773. X.DE
  774. XExamples of the match-action statement are shown below:
  775. X.DS
  776. X\fIfield\fR
  777. X    anypath    : \fImatch\fR (0*);
  778. X    usr, path    : \fImatch\fR (1*);
  779. X    hostname    : \fImatch\fR (1);
  780. X    phone_host    : \fImatch\fR (1) \fIin\fR phonehosts;
  781. X.DE
  782. X.DS
  783. X\fIruleset\fR
  784. X
  785. X    EXAMPLE_RW {
  786. X    
  787. X        \fIif\fR ( anypath < path > anypath )   /* basic RFC821/822 parse */
  788. X            \fIretry\fR ( $2 );
  789. X        \fIif\fR ( usr " at " path )        /* \*Qat\*U -> \*Q@\*U */
  790. X            \fInext\fR ( $1 @ $2 );
  791. X        \fIif\fR ( @path: usr )
  792. X            \fIreturn\fR ( LOCAL_RW ( < @$1 > : $2 ) );
  793. X        \fIif\fR ( anypath < @phone_host".ARPA" > anypath )
  794. X            \fIresolve\fR (    \fImailer\fR ( tcp ),
  795. X                    \fIhost\fR ( relay.cs.net ),
  796. X                    \fIuser\fR ( $1 % $2 < @"relay.cs.net" > $3 ) );
  797. X    }
  798. X.DE
  799. X.PP
  800. The example above defines the ruleset \*QEXAMPLE_RW\*U, which contains four
  801. rewriting rules.  The first rewriting rule discards all tokens of an address
  802. which lie on either side of a pair of angle brackets (<>), thereby 
  803. rewriting the address as
  804. the sequence of tokens contained within the angle brackets ($2).  Following the
  805. address rewrite, the rule is applied again (\fIretry\fR).  When the first rule
  806. fails to match the address being rewritten, the second rule is applied.  
  807. X.PP
  808. The second 
  809. rule simply replaces the word \*Qat\*U by the symbol \*Q@\*U.  The \*Q\fInext\fR\*U
  810. action specifies that if a match is made, a rewrite is performed and 
  811. matching continues at the next (or following) rule.  
  812. X.PP
  813. The third rule illustrates
  814. the use of the \*Q\fIreturn\fR\*U action, which is executed if the 
  815. pattern \*Q@path: usr\*U
  816. describes the current format of the address being rewritten.  In this example,
  817. the \fIreturn\fR action returns the result of a call to ruleset \*QLOCAL_RW\*U,
  818. which rewrites the address \*Q<@$1>:$2\*U, where $1 and $2 are substituted
  819. with the token(s) matched respectively by \*Qpath\*U and \*Qusr\*U.
  820. X.PP
  821. The fourth (and final) rule signals a resolution (and termination) of the
  822. rewriting process if the given pattern is matched.  The resolution specifies
  823. that the mailer \*Qtcp\*U will be used to deliver the message to the host
  824. X\*Qrelay.cs.net\*U.
  825. The \fIuser\fR parameter specifies the final form of the address
  826. which \fIsendmail\fR has just resolved.
  827. X.sp 2
  828. X.PP
  829. The \fBEase\fR construct which remains to be examined is the 
  830. X\fBconditional-expression\fR.  The \fBconditional-expression\fR provides a 
  831. method for
  832. constructing strings based on the condition that some test macro is (or is not)
  833. set.  The general form begins with the concatenation of a string and a
  834. X\fBstring-conditional\fR:
  835. X.DS
  836. X    \fIconcat\fR ( <quoted-string>, \fBstring-conditional\fR )
  837. X    \fIconcat\fR ( \fBstring-conditional\fR, <quoted-string> )
  838. X.DE
  839. A \fBstring-conditional\fR assumes either of the following forms:
  840. X.DS
  841. X    \fIifset\fR ( <macro-name>, <ifset-string> )
  842. X    \fIifset\fR ( <macro-name>, <ifset-string>, <notset-string> )
  843. X.DE
  844. A \fBstring-conditional\fR of the first form evaluates to \*Qifset-string\*U 
  845. if the macro \*Qmacro-name\*U has been assigned a value; otherwise it
  846. evaluates to the null string.  The second form behaves similarly, except
  847. that the \fBstring-conditional\fR evaluates to \*Qnotset-string\*U, instead
  848. of the null string, if the macro \*Qmacro-name\*U has no value.
  849. X.sp 1
  850. The following \fBconditional-expression\fR,
  851. X.DS
  852. X    \fIconcat\fR ( "New ", \fIifset\fR ( city, "York", "Jersey" ) )
  853. X.DE
  854. evaluates to the string "New York", if the macro \*Qcity\*U is set.  Otherwise,
  855. the \fBconditional-expression\fR evaluates to the string "New Jersey".
  856. X.NH 2
  857. Latest Changes
  858. The first two releases of \fBEase\fP provided a good starting point
  859. for managing \fIsendmail\fP  files. However, the translation wasn't
  860. perfect. Some editing needed to be done before \fBEase\fB could be
  861. used.
  862. Bruce G. Barnett made modifications to Arnold Robbin's \fBEase\fP to
  863. sendmail convertor \fIcfc\fP and tested these changes to verify a
  864. X\fIsendmail\fP configuration fle could be translated into \fBEase\fP
  865. and back with no errors: at least for the more common versions of
  866. X\fIsendmail\fP.
  867. In case this translation is not perfect, \fBEase\fP version 3 supports
  868. the \fIasm("...")\fP command, which passes the contents of the string
  869. directly to the \fIsendmail.cf\fP file.
  870. Also - support for SunOS and Ultrix sendmail were added.
  871. New options and flags were added, and well as the \fIypmap\fP (SunOS),
  872. X\fIypalias\fP and \fIyppasswd\fP (Ultrix) functions.
  873. X.NH
  874. XEase Translation
  875. X.PP
  876. It is important to note that \fBEase\fR is translated by a stand-alone
  877. translator to the raw configuration file format.  No modifications were
  878. made to the \fIsendmail\fR program itself.  As a result, syntactical verification
  879. of a configuration file can be performed without invoking \fIsendmail\fR.
  880. X.PP
  881. The \fBEase\fR language is translated by invoking 
  882. the \fBEase\fR translator (\fIet\fR). If the command line options include a flag understood by the C language preprocessor (cpp), \fIet\fP automatically 
  883. pipes input through \fIcpp\fP.
  884. The \fBEase\fR
  885. translator may be invoked on the command line in one of four ways:
  886. X.TS
  887. center box ;
  888. l l .
  889. X\fIet\fR <options>  <input-file>  <output-file>    [read from a file, write to a file]
  890. X\fIet\fR  <options> <input-file>    [read from a file, write to standard output]
  891. X\fIet\fR  <options> -  <output-file>    [read from standard input, write to a file]
  892. X\fIet\fR <options>    [read from standard input, write to standard output]
  893. X.TE
  894. X.NH
  895. Conclusion
  896. X.PP
  897. X\fBEase\fR is [ed - this information is old] currently in use at the
  898. Purdue University Computing Center.  Source code for the \fBEase\fR
  899. translator (\fIet\fR) may be obtained on request by writing to:
  900. X.DS
  901. U.S. Mail:
  902. X        James S. Schoner
  903. X        c/o Kevin S. Braunsdorf
  904. X        Purdue University Computing Center
  905. X        Purdue University
  906. X        West Lafayette, Indiana  47907
  907. X
  908. XElectronic Mail:
  909. X        ksb@j.cc.purdue.edu
  910. X.DE
  911. X.PP
  912. Much of the success of this project is attributable to the constant support 
  913. and insight offered by Mark Shoemaker.  To him, I owe a debt of gratitude.  In 
  914. addition, I would like to thank Kevin Smallwood, Paul Albitz, and Rich Kulawiec
  915. for their many notable suggestions and valuable insight.
  916. X.NH
  917. Acknowledgements
  918. X.PP
  919. Arnold Robbins would like to acknowledge contributions from
  920. Stephen Schaefer of Bowling Green State University,
  921. Jeff Stearns of John Fluke Manufacturing Company,
  922. Raymond A. Schnitzler of Bellcore,
  923. Andrew Partan of the Corporation for Open Systems,
  924. and
  925. Bruce G. Barnett, of General Electric.
  926. The good intentions of Rich Salz, of Bolt Beranak, and Newman,
  927. are also acknowledged.
  928. X.PP
  929. The most up to date version of \fBEase\fR should be gotten from the
  930. nearest USENET \fBcomp.sources.unix\fR archive site.
  931. X# Local variables:
  932. X# mode: nroff
  933. X# end:
  934. END_OF_FILE
  935. if test 32946 -ne `wc -c <'doc/ease.paper'`; then
  936.     echo shar: \"'doc/ease.paper'\" unpacked with wrong size!
  937. fi
  938. # end of 'doc/ease.paper'
  939. fi
  940. echo shar: End of archive 5 \(of 6\).
  941. cp /dev/null ark5isdone
  942. MISSING=""
  943. for I in 1 2 3 4 5 6 ; do
  944.     if test ! -f ark${I}isdone ; then
  945.     MISSING="${MISSING} ${I}"
  946.     fi
  947. done
  948. if test "${MISSING}" = "" ; then
  949.     echo You have unpacked all 6 archives.
  950.     rm -f ark[1-9]isdone
  951. else
  952.     echo You still need to unpack the following archives:
  953.     echo "        " ${MISSING}
  954. fi
  955. ##  End of shell archive.
  956. exit 0
  957.