op.me
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· ME 代码 · 共 2,890 行 · 第 1/5 页
ME
2,890 行
b The current date in Arpanet formatc The hop countd The date in UNIX (ctime) formatf The sender (from) addressg The sender address relative to the recipienth The recipient hosti The queue idp Sendmail's pidr Protocol useds Sender's host namet A numeric representation of the current timeu The recipient userv The version number of sendmailw The hostname of this sitex The full name of the sendery The id of the sender's ttyz The home directory of the recipient.)b.ppThere are three types of dates that can be used.The.b $aand.b $bmacros are in Arpanet format;.b $ais the time as extracted from the.q Date:line of the message(if there was one),and.b $bis the current date and time(used for postmarks).If no.q Date:line is found in the incoming message,.b $ais set to the current time also.The.b $dmacro is equivalent to the.b $amacro in UNIX(ctime)format..ppThe.b $fmacro is the id of the senderas originally determined;when mailing to a specific hostthe.b $gmacro is set to the address of the sender.ulrelative to the recipient.For example,if I send to.q bollard@matissefrom the machine.q ucbarpathe.b $fmacro will be.q ericand the.b $gmacro will be.q eric@ucbarpa..ppThe.b $xmacro is set to the full name of the sender.This can be determined in several ways.It can be passed as flag to.i sendmail.The second choice is the value of the.q Full-name:line in the header if it exists,and the third choice is the comment fieldof a.q From:line.If all of these fail,and if the message is being originated locally,the full name is looked up in the.i /etc/passwdfile..ppWhen sending,the.b $h ,.b $u ,and.b $zmacros get set to the host, user, and home directory(if local)of the recipient.The first two are set from the.b $@and.b $:part of the rewriting rules, respectively..ppThe.b $pand.b $tmacros are used to create unique strings(e.g., for the.q Message-Id:field).The.b $imacro is set to the queue id on this host;if put into the timestamp lineit can be extremely useful for tracking messages.The.b $ymacro is set to the id of the terminal of the sender(if known);some systems like to put thisin the Unix.q Fromline.The.b $vmacro is set to be the version number of.i sendmail ;this is normally put in timestampsand has been proven extremely useful for debugging.The.b $wmacro is set to the name of this hostif it can be determined.The.b $cfield is set to the.q "hop count,"i.e., the number of times this message has been processed.This can be determinedby the.b \-hflag on the command lineor by counting the timestamps in the message..ppThe.b $rand.b $sfields are set to the protocol used to communicate with sendmailand the sending hostname;these are not supported in the current version..ppConditionals can be specified using the syntax:.(b$?x text1 $| text2 $..)bThis interpolates.i text1if the macro.b $xis set,and.i text2otherwise.The.q else(\c.b $| )clause may be omitted..sh 3 "Special classes".ppThe class.b $=wis set to be the set of all namesthis host is known by.This can be used to delete local hostnames..sh 3 "The left hand side".ppThe left hand side of rewriting rules contains a pattern.Normal words are simply matched directly.Metasyntax is introduced using a dollar sign.The metasymbols are:.(b.ta \w'\fB$=\fP\fIx\fP 'u\fB$*\fP Match zero or more tokens\fB$+\fP Match one or more tokens\fB$\-\fP Match exactly one token\fB$=\fP\fIx\fP Match any token in class \fIx\fP\fB$~\fP\fIx\fP Match any token not in class \fIx\fP.)bIf any of these match,they are assigned to the symbol.b $ \c.i nfor replacement on the right hand side,where.i nis the index in the LHS.For example,if the LHS:.(b$\-:$+.)bis applied to the input:.(bUCBARPA:eric.)bthe rule will match, and the values passed to the RHS will be:.(b.ta 4n$1 UCBARPA$2 eric.)b.sh 3 "The right hand side".ppWhen the right hand side of a rewriting rule matches,the input is deleted and replaced by the right hand side.Tokens are copied directly from the RHSunless they are begin with a dollar sign.Metasymbols are:.(b.ta \w'$#mailer 'u\fB$\fP\fIn\fP Substitute indefinite token \fIn\fP from LHS\fB$>\fP\fIn\fP \*(lqCall\*(rq ruleset \fIn\fP\fB$#\fP\fImailer\fP Resolve to \fImailer\fP\fB$@\fP\fIhost\fP Specify \fIhost\fP\fB$:\fP\fIuser\fP Specify \fIuser\fP.)b.ppThe.b $ \c.i nsyntax substitutes the corresponding value from a.b $+ ,.b $\- ,.b $* ,.b $= ,or.b $~match on the LHS.It may be used anywhere..ppThe.b $> \c.i nsyntaxcauses the remainder of the line to be substituted as usualand then passed as the argument to ruleset.i n .The final value of ruleset.i nthen becomesthe substitution for this rule..ppThe.b $#syntax should.i onlybe used in ruleset zero.It causes evaluation of the ruleset to terminate immediately,and signals to sendmail that the address has completely resolved.The complete syntax is:.(b\fB$#\fP\fImailer\fP\fB$@\fP\fIhost\fP\fB$:\fP\fIuser\fP.)bThis specifies the{mailer, host, user}3-tuple necessary to direct the mailer.If the mailer is localthe host part may be omitted.The.i mailerand.i hostmust be a single word,but the.i usermay be multi-part..ppA RHS may also be preceeded by a.b $@or a.b $:to control evaluation.A.b $@prefix causes the ruleset to return with the remainder of the RHSas the value.A.b $:prefix causes the rule to terminate immediately,but the ruleset to continue;this can be used to avoid continued application of a rule.The prefix is stripped before continuing..ppThe.b $@and.b $:prefixes may preceed a.b $>spec;for example:.(b.ta 8nR$+ $:$>7$1.)bmatches anything,passes that to ruleset seven,and continues;the.b $:is necessary to avoid an infinite loop..sh 3 "Semantics of rewriting rule sets".ppThere are five rewriting setsthat have specific semantics.These are related as depicted by figure 2..(z.hl.ie t .sp 2i.el \{\.(c +---+ -->| 0 |-->resolved address / +---+ / +---+ +---+ / ---->| 1 |-->| S |-- +---+ / +---+ / +---+ +---+ \e +---+addr-->| 3 |-->| D |-- --->| 4 |-->msg +---+ +---+ \e +---+ +---+ / +---+ --->| 2 |-->| R |-- +---+ +---+.)c.ceFigure 2 \*- Rewriting set semantics.(cD \*- sender domain additionS \*- mailer-specific sender rewritingR \*- mailer-specific recipient rewriting.)c.\}.hl.)z.ppRuleset threeshould turn the address into.q "canonical form."This form should have the basic syntax:.(blocal-part@host-domain-spec.)bIf no.q @sign is specified,then thehost-domain-spec.i maybe appended from thesender address(if the.b Cflag is set in the mailer definitioncorresponding to the.i sendingmailer).Ruleset threeis applied by sendmailbefore doing anything with any address..ppRuleset zerois applied after ruleset threeto addresses that are going to actually specify recipients.It must resolve to a.i "{mailer, host, user}"triple.The.i mailermust be defined in the mailer definitionsfrom the configuration file.The.i hostis defined into the.b $hmacrofor use in the argv expansion of the specified mailer..ppRulesets one and twoare applied to all sender and recipient addresses respectively.They are applied before any specificationin the mailer definition.They must never resolve..ppRuleset four is applied to all addressesin the message.It is typically usedto translate internal to external form..sh 3 "Mailer flags etc.".ppThere are a number of flags that may be associated with each mailer,each identified by a letter of the alphabet.Many of them are assigned semantics internally.These are detailed in Appendix C.Any other flags may be used freelyto conditionally assign headers to messagesdestined for particular mailers..sh 3 "The \*(lqerror\*(rq mailer".ppThe mailer with the special name.q errorcan be used to generate a user error.The (optional) host field is a numeric exit status to be returned,and the user field is a message to be printed.For example, the entry:.(b$#error$:Host unknown in this domain.)bon the RHS of a rulewill cause the specified error to be generatedif the LHS matches.This mailer is only functional in ruleset zero..sh 2 "Building a Configuration File From Scratch".ppBuilding a configuration table from scratch is an extremely difficult job.Fortunately,it is almost never necessary to do so;nearly every situation that may come upmay be resolved by changing an existing table.In any case,it is critical that you understand what it is that you are trying to doand come up with a philosophy for the configuration table.This section is intended to explain what the real purposeof a configuration table isand to give you some ideasfor what your philosophy might be..sh 3 "What you are trying to do".ppThe configuration table has three major purposes.The first and simplestis to set up the environment for.i sendmail .This involves setting the options,defining a few critical macros,etc.Since these are described in other places,we will not go into more detail here..ppThe second purpose is to rewrite addresses in the message.This should typically be done in two phases.The first phase maps addresses in any formatinto a canonical form.This should be done in ruleset three.The second phase maps this canonical forminto the syntax appropriate for the receiving mailer..i Sendmaildoes this in three subphases.Rulesets one and twoare applied to all sender and recipient addresses respectively.After this,you may specify per-mailer rulesetsfor both sender and recipient addresses;this allows mailer-specific customization.Finally,ruleset four is applied to do any default conversionto external form..ppThe third purposeis to map addresses into the actual set of instructionsnecessary to get the message delivered.Ruleset zero must resolve to the internal form,which is in turn used as a pointer to a mailer descriptor.The mailer descriptor describes the interface requirementsof the mailer..sh 3 "Philosophy".ppThe particular philosophy you choose will depend heavilyon the size and structure of your organization.I will present a few possible philosophies here..ppOne general point applies to all of these philosophies:it is almost always a mistaketo try to do full name resolution.For example,if you are trying to get names of the form.q user@hostto the Arpanet,it does not pay to route them to.q xyzvax!decvax!ucbvax!c70:user@hostsince you then depend on several links not under your control.The best approach to this problemis to simply forward to.q xyzvax!user@hostand let xyzvaxworry about it from there.In summary,just get the message closer to the destination,rather than determining the full path..sh 4 "Large site, many hosts \*- minimum information".ppBerkeley is an example of a large site,i.e., more than two or three hosts.We have decided that the only reasonable philosophyin our environmentis to designate one host as the guru for our site.It must be able to resolve any piece of mail it receives.The other sites should have the minimum amount of informationthey can get away with.In addition,any information they do haveshould be hints rather than solid information..ppFor example,a typical site on our local ether network is.q monet.Monet has a list of known ethernet hosts;if it receives mail for any of them,it can do direct delivery.If it receives mail for any unknown host,it just passes it directly to.q ucbvax,our master host.Ucbvax may determine that the host name is illegaland reject the message,or may be able to do delivery.However, it is important to note that when a new ethernet host is added,the only host that.i musthave its tables updatedis ucbvax;the others.i maybe updated as convenient,but this is not critical..ppThis picture is slightly muddieddue to network connections that are not actually locatedon ucbvax.For example,our TCP connection is currently on.q ucbarpa.However,monet.i "does not"know about this;the information is hidden totally between ucbvax and ucbarpa.Mail going from monet to a TCP hostis transfered via the ethernetfrom monet to ucbvax,then via the ethernet from ucbvax to ucbarpa,and then is submitted to the Arpanet.Although this involves some extra hops,we feel this is an acceptable tradeoff..ppAn interesting point is that it would be possibleto update monetto send TCP mail directly to ucbarpaif the load got too high;if monet failed to note a host as a TCP hostit would go via ucbvax as before,and if monet incorrectly sent a message to ucbarpait would still be sent by ucbarpato ucbvax as before.The only problem that can occur is loops,as if ucbarpa thought that ucbvax had the TCP connectionand vice versa.For this reason,updates should.i alwayshappen to the master host first..ppThis philosophy results as much from the needto have a single source for the configuration files(typically built using.i m4 \|(1)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?