Annotation of researchv10no/cmd/upas/smtp/Notes, revision 1.1

1.1     ! root        1: ALL command line arguments that are addresses will be !-format:
        !             2: !-format addresses: h1!h2!u
        !             3:        means route to host h1, from there to h2, and user u there.
        !             4:        a "uucp" as host means the bangs on the right will remain
        !             5:                after translation to %@-format.
        !             6: 
        !             7: 822-format: @h1,@h2:u%h5%h4@h3
        !             8:        means h1!h2!h3!h4!h5!u
        !             9: 
        !            10: %@-format addresses: u%h3%h2@h1
        !            11:        822-format without using the source-routing list at the beginning.
        !            12:        We understand the full 822-format coming in, but send out
        !            13:                only %@-format.
        !            14: 
        !            15: remote-from-line: From fpath date remote from sys
        !            16:        where fpath, date, and sys are non-whitespace.  fpath in !-format
        !            17: 
        !            18: local-from-line: From fpath date
        !            19: 
        !            20: Unix-mail-format: a remote-from-line followed by message
        !            21: 
        !            22: 822-mail-format: group of headers (format "tag: stuff", stuff can go
        !            23:        over multiple lines), including at least "From:" and "Date:",
        !            24:        then blank line, then message.  Addresses in headers are in
        !            25:        822-format.
        !            26: 
        !            27: rmail [-#] [-d] to1 to2 ...
        !            28: 
        !            29:        -# means just print action
        !            30:        -d means print rewrite actions
        !            31:        to1 to2 etc. are in !-format
        !            32:        stdin has Unix-mail-format
        !            33: 
        !            34:        reads stdin into message structure *mp
        !            35:        parses first line as remote-from-line
        !            36:                sets mp->sender=sys!fpath (or just fpath, if "remote from ")
        !            37:                        and mp->date to date
        !            38:                if fails, uses "upasname" environment var, else
        !            39:                        logname of caller, else Liz.Bimmler
        !            40:        (the send program is just like rmail, but doesn't expect a first
        !            41:         remote-from-line, so mp->sender is upasname or logname of caller)
        !            42:        gateway code changes a sender like a!b!c!d!u to c!d!u if
        !            43:                a and b are in /usr/lib/upas/equivlist or are equal
        !            44:                to the local system, and c is not.  Then, if remainder
        !            45:                (say c!d!u) is such that rewriting u gives c!d!u, then
        !            46:                mp->sender will just be u.
        !            47:        mp->replyaddr set to copy of mp->sender, unless there
        !            48:                are shell characters in it: then "postmaster"
        !            49:        bind(to1, to2, ...) follows rewrite rules (see man 8 upas and
        !            50:                man 7 mail).  \s in rules replaced by mp->sender.
        !            51:                forwarding allowed only if all machines on mp->sender
        !            52:                or all machines on dest are in /usr/lib/upas/forwardlist
        !            53:                (or if that file doesn't exist)
        !            54:        for each bound address, one of:
        !            55:                cat it to mbox, with local-from-line (fpath=mp->sender)
        !            56:            or  pipe message (with remote-from-line, fpath=mp->sender,
        !            57:                        sys=sysname_read(), changing "^From " to ">From ")
        !            58:                        to a command
        !            59:            or  complain about mail (if ontty, report error, else
        !            60:                        make a message to mp->replyaddr from "postmaster"
        !            61:                        with appropriate error message
        !            62: 
        !            63: 
        !            64: fromsmtp [-h host] [-s defaultsender] [-d] to1 to2 ...
        !            65: 
        !            66:        -d means just print the command that will be piped to, and
        !            67:                the standard input that will be given to it
        !            68:        if no -h, host is NULL
        !            69:        if no -s, defaultsender is NULL
        !            70:        to1, to2, ...  in !-format (shouldn't have cur host at beginning,
        !            71:                unless have upas rewrite rules to handle that)
        !            72:        stdin in 822-mail-format
        !            73: 
        !            74:        starts up
        !            75:                /bin/rmail to1 to2 ...
        !            76:        calls from822(host, pointer to rmail pipe, defaultsender) to filter the
        !            77:                stdin message into Unix-mail-format, and
        !            78:                into the rmail command
        !            79: 
        !            80: from822(net, file pointer, defsender)
        !            81:        stdin in 822-mail-format or Unix-mail-format
        !            82: 
        !            83:        if first line is "From x y remote from z", then
        !            84:                unixfrom=z!x, unixdate=y
        !            85:        if it is "From x y" then unixfrom=x, unixdate=y
        !            86:        reads header lines (have ':' after only non-whitespace) from stdin
        !            87:        from is first non-null in this list:
        !            88:                unixfrom, Reply-To:-header', From:-header', Sender:-header',
        !            89:                defsender, "unknown"
        !            90:                (where header' means the value of the field modified as follows:
        !            91:                 take first whitespace delimited token or the first thing
        !            92:                 enclosed in <...>, and convert it to !-format from 822-format,
        !            93:                 then prepend "net!" if net is non-NULL (i.e., if -h net was
        !            94:                 given on command line to fromsmtp)
        !            95:        date is Date:-header (with juggled field order) or unixdate
        !            96:        write remote-from-line, with fpath=from, date=date, sys=""
        !            97:        write header lines, in order they were gotten, with no change
        !            98:        copy out the rest of stdin
        !            99: 
        !           100: tosmtp [-d domain] [-H helohost] [-f] [-n] [-u] [tohost from to1 to2 ...]
        !           101: 
        !           102:        Pass -d, -H along along to smtp (if no -f)
        !           103:        if -f, just act as filter to stdout
        !           104:        from, to1, to2 in !-format (with current host, tohost respect.)
        !           105:        stdin in Unix-mail-format
        !           106: 
        !           107:        sender=from, or if from has no ! in it, then sysname_read()!from
        !           108:        if not -f, starts up
        !           109:            smtp [-d domain] [-H helohost] sender tohost from to1 to2 ...
        !           110:        if -u (unixformat) then copy stdin to smtp or stdout
        !           111:        else call to822(pointer to smtp pipe or stdout, sender, domain, rcvrs)
        !           112:                (where domain is NULL if no -d, and rcvrs is NULL if -n
        !           113:                 else rcvrs is "to1', to2', ... ton'" and to1' is the
        !           114:                 conversion of to1 to %@-format, etc.)
        !           115: 
        !           116: to822(file pointer, sender, domain, rcvrs)
        !           117:        stdin in Unix-mail-format
        !           118:        output goes to file pointer
        !           119: 
        !           120:        read first line, parse as remote-from-line (fpath, date, sys)
        !           121:        (exit if couldn't parse as such)
        !           122:        read any 822 headers
        !           123:        caddr=sender converted to %@-format, with .domain added to end
        !           124:                if domain is non-NULL and sender's last component has
        !           125:                not '.' in it
        !           126:        if there's a From:-header, let faddr be the first token or
        !           127:                thing enclosed in <...>.  If faddr ends doesn't end in
        !           128:                .domain (if domain!=NULL) and faddr isn't the same as caddr,
        !           129:                then print "From: caddr" and turn original into >From:
        !           130:        else (there's not From:-header)
        !           131:                print "From: caddr"
        !           132:        [we ignore fpath]
        !           133:        if there's no Date:-header, use date from above, juggled order
        !           134:        if there's no To:-header and rcvrs is non-NULL, use that
        !           135:        write the headers, in original order (perhaps changing From: to >From:)
        !           136:        write a newline
        !           137:        write rest of stdin
        !           138: 
        !           139: smtpqer [-g] [-H  helohost] [-d domain] [-u] from tohost to...
        !           140: 
        !           141:        from, to in !-format
        !           142:        stdin in Unix-mail-format
        !           143: 
        !           144:        unless -g, add HOSTNAME! to from address (HOSTNAME= this host)
        !           145:        unless -u, run
        !           146:                tosmtp [-H  helohost] [-d domain] from tohost to...
        !           147:                        > /usr/spool/smtpq/x.y.msg (x, y are numbers)
        !           148:                (to convert message into 822 format)
        !           149:        make a shell script called /usr/spool/smtpq/x.y.sh that:
        !           150:                runs smtp [-H helohost] [-d domain] from tohost to...
        !           151:                removes files if ok
        !           152:                runs returnsmtpmail if no such user or host
        !           153:        start runsmtpq to run all shell scripts in spool directory
        !           154: 
        !           155: smtp [-H helohost] [-d domain] [-D] sender targethost to1 to2 ...
        !           156: 
        !           157:        if no -H,  use sysname_read() is used for helohost
        !           158:        if no -d domain, use 0
        !           159:        -D for debugging
        !           160:        sender !-format (with cur host)
        !           161:        to1, to2, ... in !-format (with targethost)
        !           162:        stdin in any format that receiver can understand
        !           163: 
        !           164:        convert sender to %@-format, adding .domain if it is non-NULL and
        !           165:                the last component has no '.'
        !           166:        convert to1, to2, ... to %@-format
        !           167:        connect to smtp port on targethost
        !           168:        sends
        !           169:                HELO helohost
        !           170:                MAIL FROM:<sender'>
        !           171:                RCPT TO:<to1'>
        !           172:                RCPT TO:<to2'>
        !           173:                ...
        !           174:                DATA
        !           175:                stdin, adding \r after \n and making . transparent
        !           176:                .
        !           177:                QUIT
        !           178: 
        !           179: smtpd [-d] [-H helohost] [-h thishost]
        !           180: 
        !           181:        -d sets socket debugging
        !           182:        if no -H, use sysname_read()
        !           183:        if no -h, NULL
        !           184: 
        !           185:        listens on smtp port for connections, forking when get one
        !           186:        expect                          send
        !           187:                HELO                    250 helohost
        !           188:                MAIL FROM:<sender>      250 OK
        !           189:                RCPT TO:<to1>           250 OK
        !           190:                RCPT TO:<to2>           250 OK
        !           191:                ...
        !           192:                DATA                    354 Start mail input; end with .        
        !           193:                message in 822-format, with hidden dots
        !           194:                .
        !           195:        message gets put into a tmp file
        !           196:        sender and to's should be in 822-format
        !           197:        then runs
        !           198:                fromsmtp [-s sender] [-h thishost] to1' to2' ... < tmp file
        !           199:        and sends either 250 OK  or  554 Transaction failed
        !           200:        where to1' to2' are gotten from to1 to2 by converting to
        !           201:                !-format, with the first machine stripped off
        !           202:                (since it should be the local machine)
        !           203:        the -s usually appears (unless there's an error parsing MAIL FROM)
        !           204:                [MISTAKE? should convert to !-format??]
        !           205:        the -h appears if it appeared in command line
        !           206: 
        !           207: 

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.